-
Notifications
You must be signed in to change notification settings - Fork 13
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(protect): add onlyInitiated modifier #313
Conversation
38aafd8
to
2f9f492
Compare
2f9f492
to
c38104f
Compare
@QGarchery @MathisGD can one of you review this PR? |
@Rubilmax can you update this branche please? |
…undlers into feat/only-initiated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this one is merged among the last ones, but I reviewed still
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many conflicts, sorry :/
…undlers into feat/only-initiated
feat(protect): add onlyInitiated modifier
🚨 Vulnerabilities Summary
For more details view the full report in OpenZeppelin Code |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Conflicts to fix cc @Rubilmax |
…into feat/only-initiated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM except one point on native transfers that I think we should discuss.
The goal of the onlyInitiated
modifier is to:
-
explicit the error in case of an accidental usage of the bundler. In most cases it is not a safety measure, because the
UNSET_INITIATOR
address would be used instead, which would lead to a revert anyway. -
The
onlyInitiated
modifier is also used in theWNativeBundler
. Here I assume that the reasoning is that native tokens could be used without having been sent by a previous transfer in the same multicall. Indeed, without the modifier, one could make a direct call towrapNative
with a positivemsg.value
and it would result to lost funds most likely (wrapped tokens could be skimmed by anyone). In this case it is a safety measure against accidentally sending native tokens.
I think that the goal 2 is not consistent in the current state, because of the following functions:
wrapNative
is gated byonlyInitiated
, which is useful against accidental native transfersunwrapNative
is unnecessarily gated, because it already assumes that funds are on the bundler. It is similar to the wrap/unwrap stETH functions (which are not gated)stakeEth
is not gated, but it would be useful against accidental native transfer, similarly towrapNative
I think we can either:
a. remove goal 2 entirely, by removing the onlyInitiated
modifier to the functions mentioned above
b. implement goal 2 everywhere. Notice that we could also gate the receive
function if we go that route
Thanks @QGarchery for pointing out that the change wasn't consistent. I removed |
@@ -52,7 +51,6 @@ abstract contract WNativeBundler is BaseBundler { | |||
} | |||
|
|||
/// @notice Unwraps the given `amount` of wNative to the native token. | |||
/// @notice Warning: should only be called via the bundler's `multicall` function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still remove this comment because in this case we're not using initiator()
. The goal of this comment wasn't to avoid losing funds, otherwise this comment should be duplicated on all functions. In any case, #354 will protect the user from everything
51a250b
to
0a052d8
Compare
_checkInitiated
in actions that require initialization #270