The reentrancy attack can occur when a contract calls an external contract before it resolves its state. In the given code, the initVault()
function calls the initVault()
function of the loveToken contract before setting vaultInitialize
to true.
The vaultInitialize
is set to true before the external call to loveToken.initVault(managerContract)
. If there is an another external call back to the initVault function, it will immediately revert because vaultInitialize
is already set to true.
If the state variable is not updated before doing an external call, then attacker will do an external call again and again that leads to distributing of total supply amount to the airdrop and staking contracts.
Manually
To mitigate this issue, follow CEI
OR
Use ReentrancyGaurd
library and nonReentrant
modifier from the OpenZeppelin contracts.
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.