Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(multicall): prevent double initiation #284

Merged
merged 1 commit into from
Oct 30, 2023

Conversation

Rubilmax
Copy link
Collaborator

@Rubilmax Rubilmax commented Oct 5, 2023

@Rubilmax Rubilmax marked this pull request as ready for review October 5, 2023 09:19
Copy link
Contributor

@QGarchery QGarchery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't find any use case to having embedded multicalls, so I'm in favor of this

Copy link
Contributor

@MerlinEgalite MerlinEgalite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So after a callback you can't anything than just one action?

@Jean-Grimal
Copy link
Contributor

So after a callback you can't anything than just one action?

Yes you are right I didn't think about it. Morpho callbacks don't work anymore (as they call multicall), that's a problem

@Rubilmax
Copy link
Collaborator Author

Rubilmax commented Oct 5, 2023

So after a callback you can't anything than just one action?

Why do you say so?

As you can see, the test suite passes: yes callbacks do execute the multicall, but does not execute the external multicall function, only the internal one

I have highlighted this in the issue

Copy link
Contributor

@MerlinEgalite MerlinEgalite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving but putting this PR on hold

@MerlinEgalite MerlinEgalite changed the base branch from main to review-cantina October 23, 2023 12:57
@MerlinEgalite
Copy link
Contributor

I changed the base FYI

Copy link
Contributor

@MerlinEgalite MerlinEgalite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we're missing those 2 things to fix the issue:

  1. Unless there is a very specific use case, Morpho should not allow the initiator to re-enter a recursive multicall transaction (that could end up anyway to revert as soon as the second one exits the multicall and the following actions are executed with initiator = address(0)).

  2. Morpho should anyway document all these possible worst-case scenarios when the original caller executes multicall operations that interact with arbitrary contracts that could re-enter in a malicious way the Bundler flow.

taken from https://github.com/cantinasec/review-morpho-blue-1/issues/64

For 1. I'm not sure how to prevent in the general while still allowing to use callbacks on Blue.

@Rubilmax
Copy link
Collaborator Author

Rubilmax commented Oct 23, 2023

I think we're missing those 2 things to fix the issue:

  1. Unless there is a very specific use case, Morpho should not allow the initiator to re-enter a recursive multicall transaction (that could end up anyway to revert as soon as the second one exits the multicall and the following actions are executed with initiator = address(0)).
  2. Morpho should anyway document all these possible worst-case scenarios when the original caller executes multicall operations that interact with arbitrary contracts that could re-enter in a malicious way the Bundler flow.

taken from cantinasec/review-morpho-blue-1#64

For 1. I'm not sure how to prevent in the general while still allowing to use callbacks on Blue.

1 is actually specifically addressed in this PR

Callbacks don't re-enter multicall but use the internal _multicall function

I need to add comments to specify that indeed, some addresses can re-enter the bundler flow in a malicious way

@MerlinEgalite
Copy link
Contributor

Callbacks don't re-enter multicall but use the internal _multicall function

So 1 & 2 are actually addressed in this PR

But the example of the nativeTransfer is not covered no?

@Rubilmax Rubilmax force-pushed the feat/prevent-nested-multicall branch from 6a2a0ef to 828405a Compare October 24, 2023 12:50
@Rubilmax Rubilmax force-pushed the feat/prevent-nested-multicall branch from 828405a to 28fdcfb Compare October 24, 2023 12:54
@MerlinEgalite
Copy link
Contributor

But the example of the nativeTransfer is not covered no?

Not sure you read it @Rubilmax

@Rubilmax
Copy link
Collaborator Author

Rubilmax commented Oct 24, 2023

But the example of the nativeTransfer is not covered no?

Not sure you read it @Rubilmax

Indeed, I missed it. What do you want me to do about the possible re-entrancy in nativeTransfer? I think it is the purpose of #315

The goal of this PR is to prevent entering multicall specifically ; and it's been what was disclosed in the aforementioned issue
If it is about documenting possible reentrancies, then there is another dedicated issue for it

@MerlinEgalite
Copy link
Contributor

Agree, approving!

Copy link
Contributor

@QGarchery QGarchery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but it does not close https://github.com/cantinasec/review-morpho-blue-1/issues/64 as the description suggests

@Rubilmax Rubilmax self-assigned this Oct 26, 2023
@MerlinEgalite MerlinEgalite merged commit d647e88 into review-cantina Oct 30, 2023
8 checks passed
@MerlinEgalite MerlinEgalite deleted the feat/prevent-nested-multicall branch October 30, 2023 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Potentially dangerous initiator value
4 participants