The depositEggToVault()
function in EggHuntGame
is vulnerable to reentrancy attacks because it calls transferFrom()
on the NFT contract before updating the vault's state.
The function calls transferFrom()
before updating vault storage:
This order allows malicious contracts to exploit reentrancy attacks.
An attacker could deploy a malicious contract that triggers reentrancy, leading to:
Excessive token deposits
Inconsistent contract states
Potential token theft
Solidity
OpenZeppelin Contracts
Reentrancy Attack Simulation
Apply the Checks-Effects-Interactions pattern:
Update the vault state before transferring the token:
Use ReentrancyGuard to prevent reentrancy:
This refactor ensures secure handling of state updates and external calls.
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.