Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: high
Invalid

Reentrancy can be done in the `initVault()::Vault.sol` contract.

Summary

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.

Vulnerability Details

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.

Impact

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.

Tools Used

Manually

Recommendations

To mitigate this issue, follow CEI

function initVault(ILoveToken loveToken, address managerContract) public {
if (vaultInitialize) revert Vault__AlreadyInitialized();
+ vaultInitialize = true;
loveToken.initVault(managerContract);
- vaultInitialize = true;
}

OR

Use ReentrancyGaurd library and nonReentrant modifier from the OpenZeppelin contracts.

Updates

Lead Judging Commences

0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.