When a user withdraws deposited RToken from StabilityPool, the pool transfers corresponding RAACToken rewards to the user. The reward amount is calculated currently deposited RToken pro rata. This means if an attacker withdraws 1 wei from StabilityPool multiple times, they can get nearly the same reward share for all the withdrawals. This way, the attacker gain major portion of RAACToken rewards, and ultimately will gain significant voting power and can disrupt the protocol.
Root Cause Analysis
Users can deposit RToken into StabilityPool to receive RAACToken rewards.
RAACToken is minted from RAACMinter on certain emission rate and transferred to StabilityPool.
Users can claim RAACTokens when they withdraw deposited RToken from StabilityPool.
The vulnerability lies in the fact that how RToken reward amount is calculated:
In other words, the user receives totalRewards * userDeposit / totalDeposits when they withdraw from StabilityPool.
Consider the following scenario:
StabilityPool currently has 1000 RAACToken, i.e. totalRewards = 1000
User has 100 RToken deposits, i.e. userDeposit = 100
DETokenhas 1000 total supply i.e. totalDeposits = 1000
User withdraws 1 wei from StabilityPool
User's raac rewards would be 100 - (1e-18) / 1000 * 1000 = 100 - (1e-18)
User receives nearly 100 RAACToken
StabilityPool now has 900 RAACToken
User withdraws another 1 weifrom StabiltyPool
User's raac rewards would be 100 - (2e-18) / 900 * (1000 - 1e-18) = 90
User receives nearly 90 RAACToken
StabiltyPool now has 810 RAACToken
User can repeats dust withdrawal process as many times as they want, and they will always receive around 1/10 of total rewards.
After repeating above process for enough times, user can siphon most of the rewards the StabilityPool holds
Scenario
Alice has 10000 RToken and deposits 10000 RToken to StabilityPool
Eve has 1000 RToken and deposits 1000 RToken to StabilityPool
7 days pass, and StabilityPool accrues some rewards
Eve withdraws 1 wei from StabilityPool for 100 times
Alice withdraws 5000 RToken from StabiltyPool
Eve has most of the RAAC rewards, Alice only receives dust amount of rewards
How to run POC
Create a file test/poc.t.sol with the following content and run forge test poc.t.sol -vvv
Console Output
Attackers can steal RAAC rewards from other users
Attackers can gain significant voting power and can inflict damage to the protocol with voting system
Manual Review, Foundry
RAAC rewards should be calculated like the following:
Already claimed rewards should be deducted from reward amount
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.