First Flight #21: KittyFi

First Flight #21
Beginner FriendlyDeFiFoundry
100 EXP
View results
Submission Details
Severity: high
Invalid

Unchecked Token Approval Leading to Race Conditions

Summary

The purrrCollateralToAave function has a potential issue related to the approval of tokens for the Aave pool. Specifically, the function sets the approval amount without checking the current allowance, which can lead to a race condition and potential security vulnerabilities.

Vulnerability Details

The approve method sets the allowance of a spender over the caller's tokens. If a malicious actor observes a call to approve, they can front-run it by quickly spending the approved amount before the legitimate transaction completes.
This is possible because the current allowance and the new allowance are not checked together atomically, allowing a window for the attack.

function purrrCollateralToAave(uint256 _ameowntToSupply) external onlyMeowntainer {
totalMeowllateralInVault -= _ameowntToSupply;
>> IERC20(i_token).approve(address(i_aavePool), _ameowntToSupply);
i_aavePool.supply( { asset: i_token, amount: _ameowntToSupply, onBehalfOf: address(this), referralCode: 0 } );

Impact

The function directly sets the approval amount for the Aave pool without checking the current allowance. This can lead to race conditions if multiple transactions are executed simultaneously, potentially causing unexpected behavior or security issues. If an attacker can manipulate the approval process, they might be able to exploit the contract by front-running or other means.

Tools Used

Manual Review

Recommendations

Leverage OpenZeppelin's SafeERC20 library, which includes safeIncreaseAllowance and safeDecreaseAllowance functions to prevent potential race conditions.

Updates

Lead Judging Commences

shikhar229169 Lead Judge about 1 year ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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