There is a vulnerability in the Starknet bridge contract where the escrow
flag is not reset when an NFT is withdrawn. This flaw prevents the NFT from being withdrawn again in the future, creating a risk of permanent loss for the owner.
The issue occurs in the withdraw_auto_from_l1
function within the Starknet bridge contract. This function checks whether the escrow
flag is set for a given NFT. If the flag is set, the contract transfers the NFT from the bridge contract to the intended recipient. If the flag is not set, the contract assumes the NFT does not exist on Starknet and mints a new one instead. The relevant code is as follows:
The problem arises because, after the NFT is successfully withdrawn, the contract does not reset the escrow
flag. This oversight leads to a situation where the NFT cannot be withdrawn again if it is transferred back to the Starknet bridge.
Here’s a step-by-step example of how this issue could manifest:
An NFT is first transferred from Starknet to Ethereum via the Starknet bridge. This action sets the escrow
flag for the original owner on Starknet.
The user then transfers the NFT from Ethereum back to Starknet. The NFT is moved from the bridge contract to the user, but the escrow
flag remains set, as it is not reset after the withdrawal.
Later, the same NFT is bridged back to Ethereum, but this time through a different bridge service, not the Ark bridge.
Finally, the user attempts to bring the NFT back to Starknet once more.
Because the escrow
flag is still set, and the NFT is no longer in the contract, the system fails to recognize the NFT's existence on Starknet, preventing any further withdrawals.
As a result, the user may lose access to the NFT permanently.
This vulnerability can lead to a situation where users are unable to withdraw their NFTs, potentially resulting in the permanent loss of their assets.
Manual Review
To resolve this issue, the escrow
flag should be reset after an NFT is withdrawn, similar to how it is handled in the corresponding Solidity bridge contract. This will ensure that the NFT can be withdrawn again in the future without any issues.
Impact: Incorrect state without any other impact, which deserves a Low according to CodeHawks documentation.
Impact: Incorrect state without any other impact, which deserves a Low according to CodeHawks documentation.
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.