Core Contracts

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

An attacker can steal the pool depositors profit

Summary

The calculation of a user's share of rewards from the pool relies solely on userDeposits[user], which can be manipulated through a flashloan attack, leading to unfair or inflated reward distributions.

Vulnerability Details

  • When users want to withdraw their funds from the contract they get also rewards with it. As we can see the function calls calculateRaacRewards to calculate the accrued amount.

function withdraw(uint256 deCRVUSDAmount) external nonReentrant whenNotPaused validAmount(deCRVUSDAmount) {
_update();
if (deToken.balanceOf(msg.sender) < deCRVUSDAmount) revert InsufficientBalance();
uint256 rcrvUSDAmount = calculateRcrvUSDAmount(deCRVUSDAmount);
uint256 raacRewards = calculateRaacRewards(msg.sender); <@ audit
if (userDeposits[msg.sender] < rcrvUSDAmount) revert InsufficientBalance();
userDeposits[msg.sender] -= rcrvUSDAmount;
if (userDeposits[msg.sender] == 0) {
delete userDeposits[msg.sender];
}
deToken.burn(msg.sender, deCRVUSDAmount);
rToken.safeTransfer(msg.sender, rcrvUSDAmount);
if (raacRewards > 0) {
raacToken.safeTransfer(msg.sender, raacRewards);
}
emit Withdraw(msg.sender, rcrvUSDAmount, deCRVUSDAmount, raacRewards);
}
  • But, the issue arise when calculateRaacRewards function try to rely only userDeposits[user] which is something can easily manipulated using flashloan.

function calculateRaacRewards(address user) public view returns (uint256) {
uint256 userDeposit = userDeposits[user]; <@
uint256 totalDeposits = deToken.totalSupply();
uint256 totalRewards = raacToken.balanceOf(address(this));
if (totalDeposits < 1e6) return 0;
return (totalRewards * userDeposit) / totalDeposits; <@
}
  • The missing of time factor make this attack possible in single Tx.

Impact

Stealing other users profit from depositing in the pool.

Tools Used

Manual audit

Recommendations

The most preferable way to prevent flashloan attack is by using time factor in withdraw function.

Updates

Lead Judging Commences

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

StabilityPool::calculateRaacRewards is vulnerable to just in time deposits

Support

FAQs

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

Give us feedback!