The claimNft function lacks proper checks for ERC20 token balance and allowance, and does not verify that the burn operation was successful. This can lead to inconsistent state changes and potential loss of funds if the burn operation fails.
Lack of Balance and Allowance Checks
The function does not explicitly verify whether the user has enough balance or allowance to burn the required amount of ERC20 tokens. If the user doesn't have sufficient tokens or allowance, the transaction could fail, but this isn't properly handled, leading to potential inconsistencies.
Burn Failure Not Verified
The burn operation is executed without verifying whether it succeeded. If the burn fails or does not reduce the user's balance as expected, the state could be updated incorrectly, resulting in lost tokens or NFTs.
State Updated Before Burn Success
The state (i.e., token balances and minted amounts) is updated before confirming the burn was successful. If the burn fails, the state would not be reverted, leading to inconsistent contract state.
State Inconsistency: If the burn fails or the user doesn't have sufficient balance/allowance, the contract may update the state incorrectly.
Potential Loss of Funds: Users could lose their ERC20 tokens or NFTs if the burn operation is not properly verified, and the state updates incorrectly.
Misleading Behavior: The contract will emit the NftClaimed
event and transfer the NFT even if the burn fails, which is misleading to the user and off-chain services.
Manual code review
Check ERC20 Balance and Allowance: Explicitly verify the user's balance and allowance before attempting to burn tokens.
Use Try/Catch for Burn Operation: Wrap the burn operation in a try/catch
block to handle any potential errors during the burn process.
Verify Burn Success: After the burn, check that the user's balance was correctly reduced to ensure the burn was successful.
Update State After Successful Burn: Only update the state (balances, minted amounts) after confirming that the burn succeeded.
Emit Events After Successful Operations: Only emit the NftClaimed
event after the burn and state updates have been successfully confirmed.
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.