The function KittyConnect::bridgeNftToAnotherChain
is designed to facilitate the bridging of Non-Fungible Tokens (NFTs) from one blockchain to another. However, it suffers from a critical flaw where the user's NFT is burned before ensuring the successful completion of the bridging process. This creates a vulnerability where if the bridging operation fails after the user's NFT is burned, the asset is irreversibly lost.
In the following code, you could notice the process of the function with added comments.
You can add the following test to the KittyTest.t.sol
test suite (Note: the test will fail and that's ok for the following inspections). Run it with the command forge test --mt test_bridgeNftBurnOnRevert -vvv
.
The output of the test would be like the following. Notice the emission of the event emit Transfer(from: catOwner: [0x9E472C0AD173aef746b6635407B2D22cD835e428], to: 0x0000000000000000000000000000000000000000, tokenId: 0)
coming from _burn(tokenId);
in the function KittyConnect::bridgeNftToAnotherChain
.
If i_kittyBridge.bridgeNftWithData
reverts, the user's NFT is burned and lost without the possibility to recover it.
VSCodium, Foundry
It is adivsable to ensure i_kittyBridge.bridgeNftWithData
succeed before proceeding with burning the user's NFT. The fixed function might look like this:
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.