The StabilityPool contract contains a vulnerability that allows users to repeatedly deposit and withdraw funds to maximize their reward claims unfairly. This exploit enables users to perform a sandwich attack on rewards, where they can manipulate their deposit timing to disproportionately increase their RAAC token earnings.
The vulnerability exists in the way RAAC rewards are calculated and distributed. Specifically, the calculateRaacRewards function determines a user's share of the rewards pool based on their deposit at the time of calculation.
A user can repeatedly deposit right before a reward distribution and withdraw immediately after, ensuring their deposit is considered for the reward calculation while avoiding long-term exposure. The withdraw function enables this behavior.
Since RAAC rewards are calculated at the time of withdrawal, an attacker can deposit right before the reward distribution to ensure a high share, then withdraw immediately after the distribution to claim rewards without maintaining a long-term deposit. This process can be repeated continuously to drain the reward pool unfairly. By exploiting the reward calculation formula in this way, a user can manipulate the system to maximize their earnings repeatedly, significantly disadvantaging long-term participants.
PoC
Add the following test to test/unit/core/pools/StabilityPool/StabilityPool.test.js.
This test demonstrates that a user can repeatedly call the deposit and withdraw functions to increase their raacToken rewards.
This vulnerability leads to an unfair reward distribution, as users exploiting it can claim a disproportionate amount of RAAC rewards compared to long-term depositors. As a result, the reward pool can be rapidly depleted, preventing honest users from receiving their fair share. Additionally, attackers could use a flashloan to maximaze their share of the rewards pool, leaving the rest of the user with little to no rewards.
Manual review
Implement a MasterChef-style staking rewards system to ensure fair and transparent distribution of rewards. The system will allocate rewards based on both the user's deposited balance and the duration of their staking period, promoting long-term engagement and equitable reward distribution.
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.