HardhatDeFi
15,000 USDC
View results
Submission Details
Severity: high
Invalid

Lack of access control allows draining whole liquidity pool

Summary

Missing access control in _removeLiquidity::AaveDIVAWrapperCore.sol causes malicious user draining the whole liqudity pool with total balance of the colateral token.

Vulnerability Details

In this function, malicious user gives _poolId with relevant collateral token, random input from 0 to type(uint256).max - 1 for _positionTokenAmoun and his address. It is bypassing every check and all code implementation.
_wTokenAmountReturned will be the balance of total collateral token in this contract, which is parameter used in _redeemWTokenPrivate, which withdraws collateral token to recepient address.

uint256 _amountReturned = _redeemWTokenPrivate(
_pool.collateralToken, // wToken
_wTokenAmountReturned,
_recipient,
address(this)
);
return _amountReturned;

Impact

The missing check causes malicious user to bypass the code implementation and withdraw the whole pool.

Tool used

Manual Review

Recommendation

  1. Add a new mapping in AAVEWrapperCore contract to track each user's collateral contribution for every pool:

mapping(bytes32 => mapping(address => uint256)) private userCollateralBalance;
  1. Modify _addLiquidity::AaveDIVAWrapperCore.sol to update the userCollateralBalance mapping when a user adds liquidity:

userCollateralBalance[_poolId][msg.sender] += _collateralAmount;
  1. Before calling _redeemWTokenPrivate, add a check to ensure that the user has sufficient collateral balance before proceeding and update balances upon removal:

require(userCollateralBalance[_poolId][msg.sender] >= _positionTokenAmountToRemove, "Insufficient collateral balance");
userCollateralBalance[_poolId][msg.sender] -= _positionTokenAmountToRemove;
Updates

Lead Judging Commences

bube Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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