Lack of access control allows initialize
front running in first deploy or successive implementation upgrade that leads to blackhat owning the L1 bridge, NFT duplication or NFT stealing.
The bridge has a check to only execute initialize once per implementation but anyone can call the initialize method first after the first deploy or in successive implementation upgrade.
There are 2 cases:
First time the contract is deployed: a user can frontrun initialize and be the owner of the bridge leading to NFT duplication in case the L2 bridge is already deployed in starknet. Attack path:
L2 Bridge
already deployed
Blackhat
owns the L1 bridge
by frontrunning, upgrading with attack implementation and crafting a deposit message with a NFT id=1000 that doesn't own.
L2 Bridge
receives the message and mint the NFT id=1000 for the blackhat. L2 bridge
also can create the ERC721 contract if it doesn't exist.
Blackhat
quickly sells NFT id=1000 in L2 to profit.
Successive implementation upgrades: It depends on the implementation changes that ark will do, but if the initialize logic doesn't change it can be owned. Attack path if initialze logic doesn't change:
Ark
upgrade a new implementation
Blackhat
frontrun initialize and owns the bridge
Blackhat
Steal NFTS and sell them for profit.
The POC shows how the bridge can be owned after an implementation upgrade if the initialize logic doesn't change:
First time deploy: NFT duplication if L2 bridge deployed and L1 owned by frontrunning.
Successive upgrades: NFT stealing if L1 initialise logic doesn't change.
VS Code
Use _disableInitializers
method of Initializable.sol
from of OpenZeppelin Contracts to avoid the frontrun
Also use battle tested initializer
modifier of Initializable.sol
from OpenZeppelin Contracts to guarantee initializable is call only once.
If frontrun at the first deployment, protocol will deploy again, no real impact: informational. Moreover it is already deployed and initialize on mainnet. For the upgrades, `initialize` can/will change for the next update since the owner is already set. A lot of protocol make that change. That’s why I consider it like a future feature and it is out of scope.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.