claimTokens
updates the user's bid balance after transferring tokens. This exposes the contract to a reentrancy attack, allowing a user to claim more tokens than they are entitled
The critical issue is that the function transfers tokens to the user before setting the user's bid balance to zero. If the transferred token’s contract (or another contract in the call chain) has a callback that can re-enter the claimTokens()
function before the state is updated, the user can effectively call claimTokens()
again with the same balance,
A malicious user could call the claimTokens()
function and use a reentrancy attack to repeatedly call the function before the bids[msg.sender]
balance is set to 0
. This allows them to withdraw more tokens than they are entitled to, as the balance check is performed only after the transfer.
This attack can be executed if the auctionToken
contract's transfer
function calls back into the claimTokens()
function, reentering the same logic and allowing the attacker to drain the contract of tokens.
vs code
The user’s bid balance is set to 0
before any external interaction occurs, ensuring that even if a reentrancy attack is attempted, the attacker cannot withdraw more tokens than they are supposed to.
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.