Core Contracts

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

Potential denial of service in `_withdrawFromVault` affecting lending operations

Summary

The _withdrawFromVault function calls curveVault::withdraw with a maxLoss parameter of 0, which can cause the function to revert if the vault has a strategy experiencing losses. This can lock funds indefinitely until the loss is repaid or socialized, potentially causing a denial of service (DoS). Additionally, this issue extends to LendingPool::borrow and LendingPool::withdraw, both of which rely on _ensureLiquidity, which in turn calls _withdrawFromVault. If maxLoss is set to 0, these critical lending operations can also become unavailable.

Vulnerability Details

Problem description

  • The function _withdrawFromVault interacts with a Curve Vault, which integrate with Yearn Vaults.

  • Yearn Vaults impose a loss policy where withdrawals with a maxLoss value of 0 can be blocked if a strategy has an unrealized loss.

  • The function currently calls:

function _withdrawFromVault(uint256 amount) internal {
curveVault.withdraw(amount, address(this), msg.sender, 0, new address[](0)); // @audit-issue Hardcoded `maxLoss` of 0
totalVaultDeposits -= amount;
}
  • The maxLoss parameter is set to 0, meaning withdrawals will revert if any strategy has an unrealized loss.

  • This can prevent both normal withdrawals and emergency withdrawals, causing a major issue for users relying on liquidity.

  • Furthermore, the issue propagates to lending operations due to _ensureLiquidity, which attempts to withdraw funds from the Curve Vault when liquidity is insufficient.

Affected lending operations
function _ensureLiquidity(uint256 amount) internal {
// if curve vault is not set, do nothing
if (address(curveVault) == address(0)) {
return;
}
uint256 availableLiquidity = IERC20(reserve.reserveAssetAddress).balanceOf(reserve.reserveRTokenAddress);
if (availableLiquidity < amount) {
uint256 requiredAmount = amount - availableLiquidity;
// Withdraw required amount from the Curve vault
_withdrawFromVault(requiredAmount); // @audit-issue May revert due to maxLoss = 0
}
}
  • _ensureLiquidity is called in LendingPool::borrow and LendingPool::withdraw, meaning a failed vault withdrawal will result in these operations being blocked.

Steps to reproduce
  1. Deposit funds into the Curve Vault.

  2. The underlying Yearn strategy suffers a loss.

  3. Call _withdrawFromVault, which will revert due to the maxLoss set to 0.

  4. This failure propagates to LendingPool::borrow and LendingPool::withdraw, blocking user operations.

Impact

  • Denial of service (DoS): Withdrawals are blocked if any strategy experiences a loss.

  • Liquidity risk: Users may not be able to retrieve their funds during critical moments.

  • Protocol disruption: Lending operations (borrowing and withdrawals) are also affected, reducing system resilience.

Tools Used

  • Manual code review

  • Reference to Yearn Vault’s loss-handling mechanisms

Reference: https://github.com/code-423n4/2023-07-tapioca-findings/issues/1456

Recommendations

Allow configurable loss threshold
  1. Modify _withdrawFromVault to allow a configurable maxLoss parameter instead of hardcoding 0.

  2. Introduce an admin-controlled setting for adjusting the maxLoss value dynamically.

  3. Ensure that _ensureLiquidity gracefully handles vault withdrawal failures, preventing lending operations from becoming unavailable.

Updates

Lead Judging Commences

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

LendingPool::_withdrawFromVault hardcodes maxLoss to 0, causing reverts when Curve vault applies any fees or slippage to withdrawals

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

LendingPool::_withdrawFromVault hardcodes maxLoss to 0, causing reverts when Curve vault applies any fees or slippage to withdrawals

Support

FAQs

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