malicious actor can deposit a large amount and withdraw and claim majority of the accrued reward, stealing rewards from honest users.
User can deposit RToken into the stability to get RAAC token as a reward. The RAAC token is accrued based on a block passed since the last deposit or withdraw. The RAAC reward comes from RAACMinter when RAACMinter:tick is called. This tick function is called only when someone deposit or withdraw in stability pool using _update function.
Two user stake 100 RToken at block 1.
There is no other deposit till block 7200.
according to emission rate of 1000 / 7200, the reward should be 1000 RAAC.
Now a malicious user came in and deposit 10000 RToken.
He now withdraws in a same block, according to calculateRaacRewards the reward RAAC he will get will be
totalRewards(1000) * userDeposit(10000) / totalDeposits(10100) = 990 RAAC
As you can see attacker was able to get majority of emission stealing from the honest user by just depositing for 1 transaction.
Here is a POC with logs to show the issue. past this in StabilityPool.t.ts -> Deposits
Honest depositors will lose rewards discouraging them from depositing in the stability pool.
Either use a minimum delay for the user before withdrawing so a sandwich is not possible or use a SNX-style staking contract.
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.