-
Notifications
You must be signed in to change notification settings - Fork 11
unforgiven - [Medium] Function PreCheckWithdrawals() doesn't uniquify withdrawal items, this may cause double spend parameters like gas limit set differently for those duplicate items #223
Comments
Comment from Optimism Description: DoS during the migration process Reason: Good catch if accurate. Just need validation. Would call this a medium severity if so. |
Escalate for 111 USDC This issue is not duplicate of the #105 This issue is about // At this point, we know that the list of filtered withdrawals MUST be exactly the same as the
// list of withdrawals in the state. If we didn't have enough withdrawals, we would've errored
// out, and if we had too many, we would've filtered them out.
return filtered, nil
} So code perform 2 action to filter the withdrawals:
the logic of the an example: |
You've created a valid escalation for 111 USDC! To remove the escalation from consideration: Delete your comment. You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final. |
Escalation rejected and keeping duplication state, the comment fails to show a detailed explanation how the faulty state can be reached |
This issue's escalations have been rejected! Watsons who escalated this issue will have their escalation amount deducted from their next payout. |
unforgiven
medium
[Medium] Function PreCheckWithdrawals() doesn't uniquify withdrawal items, this may cause double spend parameters like gas limit set differently for those duplicate items
Summary
Function
PreCheckWithdrawals()
checks that the given list of withdrawals represents all withdrawals made in the legacy system and filters out any extra withdrawals not included in the legacy system but code don't check for duplicate items and it may add single message multiple times. This can be a problem if other parts of the code treat them as different messages. This can cause the deployment script to exit with error or generate suspicious logs that can cause migration to be halted. also double spend may happen if for those message code set different nonce or gas limit for them L2ToL1MessagePasser hash calculation. the list of withdrawals shouldn't have duplicate items after filtering.Vulnerability Detail
This is
PreCheckWithdrawals()
code:As you can see code checks that all the cross domain messages are included in the withdrawals and only select withdrawals that their hash has been set to true in the LegacyMessagePasserAddr storage. but code don't uniquify the withdrawal list and if the initial list had duplicate items then the final list would have duplicate items too.
The legacy message in L2CrossDomainMessage includes this information: (Target, Sender, Data and Nonce) and the new withdraw message has this information: (Target, Sender, Data, Nonce, Value, GasLimit). so the parameters (Value, GasLimit) are new and specially parameter GasLimit is set by the deployment script.
The new L2ToL1MessageParser has this information: (Nonce, Sender, Target, Value, Gaslimit, Data) and GasLimit and Value and Nonce are new and set by the deployment script.
so if
PreCheckWithdrawals()
return duplicate items then functionMigrateWithdrawal()
which is responsible for migrating withdrawal message to new format may create duplicate message for single old message by setting different values for Gaslimit or Nonce in the L2ToL1MessageParser.Impact
first impact is that the issue can cause migration to be interrupted as the messages count would be higher than the real amount of the message, and even if the hashed values were equal for duplicate messages and couldn't cause double spend but the bigger number of message would be sign of suspicious withdrawals.
also possible double spend if duplicate message generate different hash because of the added new field to messages that their values calculated by deployment script.
Code Snippet
https://github.com/ethereum-optimism/optimism/blob/3f4b3c328153a8aa03611158b6984d624b17c1d9/op-chain-ops/crossdomain/precheck.go#L13-L77
Tool used
Manual Review
Recommendation
uniquify the withdrawal items
Duplicate of #105
The text was updated successfully, but these errors were encountered: