Core Contracts

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

Attacker can drain the RAAC reward by flash loan attack

Summary

The user deposits rToken to stability pool and receive RAAC token as reward. However, there is not a time tracking mechanism for RAAC distribution in stability pool. Therefore, malicious user can drain RAAC reward of the pool by flash loan attack.

Vulnerability Details

In the both StabilityPool.deposit() and StabilityPool.withdraw() function, there is no a time tracking mechanism for user deposit and withdraw. This makes attacker possible to do flash loan attack.

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

Attack path:

  • Attacker buy rToken in LendingPool with flash loan.

  • Attacker deposit rToken to StabilityPool.

  • Attacker invokes StabilityPool.withdraw(). There is no time track for deposit and withdraw time, attacker can withdraw full deposited amount and receive reward for full deposited amount. Also it drains the RAAC reward of the pool.

  • Attacker withdraw rToken from LendingPool and receive flash loan.

  • Attacker repays the flash loan, all within a single transaction.

This scenario is possible since there is no time delay between deposit and withdraw and also could drain the RAAC rewards.

Impact

The RAAC reward of the stability pool can be drained by flash loan attack.

Tools Used

Manual Review

Recommendations

Implement time tracking for deposit and withdraw in stability pool and calculates the RAAC reward based on depositing time.

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.