-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
L2Sender reinit fix #8864
L2Sender reinit fix #8864
Conversation
packages/contracts-bedrock/src/universal/CrossDomainMessenger.sol
Outdated
Show resolved
Hide resolved
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #8864 +/- ##
===========================================
- Coverage 34.81% 25.90% -8.91%
===========================================
Files 165 117 -48
Lines 7100 4821 -2279
Branches 1198 1050 -148
===========================================
- Hits 2472 1249 -1223
+ Misses 4476 3466 -1010
+ Partials 152 106 -46
Flags with carried forward coverage won't be shown. Click here to find out more.
|
packages/contracts-bedrock/test/L1/L1CrossDomainMessenger.t.sol
Outdated
Show resolved
Hide resolved
f876428
to
eb9210f
Compare
WalkthroughWalkthroughThe updates across various contracts in the Optimism bedrock package focus on incrementing semantic versions and enhancing security. The version increments reflect new features or fixes. Security improvements include additional checks to prevent reentrancy attacks and ensure that messages are not relayed multiple times. A specific fix ensures that if an Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Semgrep found 1
Please create a GitHub ticket for this TODO. Ignore this finding from todos_require_linear. |
5df233c
to
97400a2
Compare
97400a2
to
d03df25
Compare
// We only want to set the xDomainMsgSender to the default value if it hasn't been initialized yet, | ||
// meaning that this is a fresh contract deployment. | ||
// This prevents resetting the xDomainMsgSender to the default value during an upgrade, which would enable | ||
// a reentrant withdrawal to sandwhich the upgrade replay a withdrawal twice. |
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.
nit 😅
// a reentrant withdrawal to sandwhich the upgrade replay a withdrawal twice. | |
// a reentrant withdrawal to sandwich the upgrade to replay a withdrawal twice. |
Replaces #8797 which was accidentally closed.
Description
Fixes an issue which would allow for a single messages to be replayed twice by intercepting an upgrade.
This is addressed in two ways:
xDomainMsgSender
if it is not the default value.successfulMessages
for the message is still false after theexternal call.
Exploit Description
To perform the exploit, the following steps must be taken by the attacker:
withdrawal transaction.
upgrade transaction and then re-enter
relayMessage()
with their own samewithdrawal message.
xDomainMsgSender
has been reset by the upgrade.The attacker must also satisfy the following with their withdrawal message:
relayMessage()
. A fresh withdrawalcannot reenter as it checks
failedMessages[versionedHash]
is true.drain from the contract.