Core Contracts

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

Flawed reward distribution mechnism can be manipulated to drain the reward RAAC token from stability pool

Summary

attacker could drain rewad tokens from stability pool due to its flawed reward distribution mechnism

Vulnerability Details

Users deposit RToken/RcrvUSD to stability pool and get reward RAAC tokens propotional to their deposit when withdrawing, as in :

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);
}
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; //@audit

The reward amount is calculated as proportional to total RAAC balance the pool hold, where the proportion is the user deposits devided by total deposits. Notice that there is no other constrains such as deposits period as factor to contribute to reward split. Therefor an attack could monitor the reward tick() event and then deposit(or borrow) a large amount of RcrvToken to share the large portion of the totalRewards, after that he can immediately withdraw/repay his deposit, in this way, an attack could drain almost all rewards.

Impact

rewards raac token could be drained by attacker

Tools Used

manual

Recommendations

consider modifying the reward distribution mechanism

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!