Core Contracts

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

Raac rewards distribution can be manipulated

Summary

When the user withdraws Rtokens from the stability pool, they also get a share of raac rewards in the contract which depends on their share of the Rtokens in the pool. However, the raac rewards claim can be manipulated by a malicious user to claim a large share of the rewards

Vulnerability Details

The user calls the withdraw function to withdraw an amount of rToken and raac rewards

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);
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);
}

The amount of raac rewards to claim depends on rToken share of the user in the pool

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;
}

Since the rewards are calculated based on the user's proportion of total deposits. A malicious user can temporarily inflate their share by making a large deposit which will allow the malicious user to have a large share of the total deposits and also claim a large share of the raac rewards once they withdraw their rTokens.
Also, since each withdrawal calculates and transfers rewards independently, the malicious user can make multiple small withdrawals to claim large rewards repeatedly.

Attack Flow:

  1. Attacker deposits a large amount of RTokens

  2. Makes multiple small withdrawals

  3. Each withdrawal claims rewards based on their large total deposit

  4. Can potentially drain most or all RAAC rewards

Impact

  • Disproportionate distribution of RAAC rewards

  • Potential drainage of protocol rewards

  • Loss of rewards for legitimate users

Tools Used

Manual

Recommendations

Updates

Lead Judging Commences

inallhonesty Lead Judge 3 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.