You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The L2 collection address for a BAYC on L1 can be predicted because of weak salt usage. So, before the creation of L2 collection address, the attacker can deploy a malicious contract and change the state to his favor (like allowance, mints, owner of IDs) and then self-destruct it. After that wait till someone locks up their BAYC on Rift above on L1, and then backrun on the next block to unlock it by calling returnFromThreshold on Rift below on L2.
The previous issues with similar bug had more harder way to collide because salt is chosen from input param, so they had to brute force. But here, the salt is L1 collection address. So salt to all famous NFT collections are the collection addresses itself.
Likelihood :
The feasibility, as well as detailed technique and hardware requirements of finding a collision, are sufficiently described in multiple references:
1: A past issue on Sherlock describing this attack. 2: EIP-3607, which rationale is this exact attack. The EIP is in final state.
The hashrate of the BTC network has reached 6 × 10 ** 20 hashes per second as of time of writing, taking only just 33 minutes to achieve 2^80 hashes. A fraction of this computing power will still easily find a collision in a reasonably short timeline.
Issue flow :
since on L1 we all know the BAYC collection address, so _l1CollectionAddress is known to all, which is used as a salt to deploy the L2 collection address using create 2 clone library.
So fuzz or use your compulaton power to deploy a bot contract on the same address L2 BAYC collection going to be created, and change the state that can extract maximum value and self-destruct the contract deployed there.
Then officially call thresholdCross from l1, to deploy the collection genuinely. The maximum extraction that can be done is, for example, to mint token 6800 to the attacker and so that he can lock it in L2 and release it on l1. Or choose to change the state in a way mint all the tokens from 8000 tpo 10k on his address as owner.
Then as soon as your 9999 is locked in L1 by a victim, this attacker can lock his 9999 on L2 (that he got by changing the slot by deploying a malicious BAYC contract due to weak salt and create2 usage). He can lock in L2 and release it on L1.
So, by the end, he got a BAYC 9999 on l1, by manipulating the storage of BAYC collection on l2.
Implement salt by hashing the encoded values like, block time, block number, user-supplied custom salt, also the L1 collection address and also the gas left() for more randomness. Or deploy with create1 instead of create2.
The text was updated successfully, but these errors were encountered:
sherlock-admin2
changed the title
Fancy Emerald Lark - Collison attack on l2CollectionAddress
Ironsidesec - Collison attack on l2CollectionAddressOct 9, 2024
Ironsidesec
Medium
Collison attack on
l2CollectionAddress
Summary
The L2 collection address for a BAYC on L1 can be predicted because of weak salt usage. So, before the creation of L2 collection address, the attacker can deploy a malicious contract and change the state to his favor (like allowance, mints, owner of IDs) and then self-destruct it. After that wait till someone locks up their BAYC on Rift above on L1, and then backrun on the next block to unlock it by calling
returnFromThreshold
on Rift below on L2.The previous issues with similar bug had more harder way to collide because salt is chosen from input param, so they had to brute force. But here, the salt is L1 collection address. So salt to all famous NFT collections are the collection addresses itself.
Go look at the latest issues with similar weak salt issues. scroll below the comment and go to the bottom
Vulnerability Detail
Likelihood :
The feasibility, as well as detailed technique and hardware requirements of finding a collision, are sufficiently described in multiple references:
1: A past issue on Sherlock describing this attack.
2: EIP-3607, which rationale is this exact attack. The EIP is in final state.
The hashrate of the BTC network has reached 6 × 10 ** 20 hashes per second as of time of writing, taking only just 33 minutes to achieve 2^80 hashes. A fraction of this computing power will still easily find a collision in a reasonably short timeline.
Issue flow :
_l1CollectionAddress
is known to all, which is used as a salt to deploy the L2 collection address using create 2 clone library.thresholdCross
from l1, to deploy the collection genuinely. The maximum extraction that can be done is, for example, to mint token 6800 to the attacker and so that he can lock it in L2 and release it on l1. Or choose to change the state in a way mint all the tokens from 8000 tpo 10k on his address as owner.So, by the end, he got a BAYC 9999 on l1, by manipulating the storage of BAYC collection on l2.
https://github.com/sherlock-audit/2024-08-flayer/blob/0ec252cf9ef0f3470191dcf8318f6835f5ef688c/moongate/src/InfernalRiftBelow.sol#L77-L82
https://github.com/sherlock-audit/2024-08-flayer/blob/0ec252cf9ef0f3470191dcf8318f6835f5ef688c/moongate/src/InfernalRiftBelow.sol#L242-L280
Impact
Loss of funds (high value NFTs). So high impact and the likelihood is medium (only computation power is needed). So, Medium severity
Code Snippet
https://github.com/sherlock-audit/2024-08-flayer/blob/0ec252cf9ef0f3470191dcf8318f6835f5ef688c/moongate/src/InfernalRiftBelow.sol#L77-L82
https://github.com/sherlock-audit/2024-08-flayer/blob/0ec252cf9ef0f3470191dcf8318f6835f5ef688c/moongate/src/InfernalRiftBelow.sol#L242-L280
Tool used
Manual Review
Recommendation
Implement salt by hashing the encoded values like, block time, block number, user-supplied custom salt, also the L1 collection address and also the gas left() for more randomness. Or deploy with create1 instead of create2.
The text was updated successfully, but these errors were encountered: