Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: high
Valid

Rebalancing in the LendingPool will fail to withdraw assets due to wrong owner passed

Summary

If the desiredBuffer of liquidity in the protocol is not met, assets are to be withdrawn from the Curve Vault. But due to the wrong shares owner passed, the function will revert and fail.

Vulnerability Details

When users deposit/withdraw from the LendingPool, _rebalanceLiquidity() is called at the end of the function flow to check if the desiredBuffer is met, and if not, withdraw liquidity from the Curve Vault:

function _rebalanceLiquidity() internal {
...
uint256 totalDeposits = reserve.totalLiquidity; // Total liquidity in the system
uint256 desiredBuffer = totalDeposits.percentMul(liquidityBufferRatio);
uint256 currentBuffer = IERC20(reserve.reserveAssetAddress).balanceOf(reserve.reserveRTokenAddress);
if (currentBuffer > desiredBuffer) {
uint256 excess = currentBuffer - desiredBuffer;
// Deposit excess into the Curve vault
_depositIntoVault(excess);
} else if (currentBuffer < desiredBuffer) {
uint256 shortage = desiredBuffer - currentBuffer;
// Withdraw shortage from the Curve vault
@> _withdrawFromVault(shortage);
}
...
}

But if we look at _withdrawFromVault(), we will see it passes msg.sender as the shares owner:

function _withdrawFromVault(uint256 amount) internal {
curveVault.withdraw(amount, address(this), msg.sender, 0, new address[](0));
totalVaultDeposits -= amount;
}

This is incorrect, since the LendingPool contract is the one which deposits them into the Curve Vault (in case the assets deposited in the protocol are in excess of the desired buffer), and is their owner.

Impact

Withdrawing assets from the Curve Vault to meet the desired buffer will just not work. This is quite problematic since it can and will revert when users attempt to withdraw their assets, and I believe users not being able to withdraw warrants High severity.

Tools Used

Manual Review

Recommendations

Pass address(this) as the shares owner when withdrawing from the Curve Vault.

Updates

Lead Judging Commences

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

LendingPool::_withdrawFromVault incorrectly uses msg.sender instead of address(this) as the owner parameter, causing vault withdrawals to fail

inallhonesty Lead Judge 7 months ago
Submission Judgement Published
Validated
Assigned finding tags:

LendingPool::_withdrawFromVault incorrectly uses msg.sender instead of address(this) as the owner parameter, causing vault withdrawals to fail

Support

FAQs

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

Give us feedback!