In StabilityPool
, An attacker can exploit the reward distribution mechanism by depositing and withdrawing in a single transaction immediately after a reward is deposited into the contract via depositRAACFromPool
. This allows the attacker to unfairly claim a portion of the rewards without maintaining a long-term stake.
The contract allows users to deposit funds and immediately become eligible for rewards.
If rewards are distributed via an external deposit like depositRAACFromPool
,
an attacker can execute the following sequence in a single transaction:
Wait for a reward deposit event.
Deposit a large amount right after the reward deposit.
Trigger reward calculation, receiving an unfair share of the rewards.
Immediately withdraw the deposit, keeping the earned rewards.
Please see the calculateRaacRewards
which is called in withdraw()
The reaward is called by multiplying raacToken
with userDeposit
.
An attacker perform this attack multiple times to drain the raacToken
balance from the contract.
Immediate reward extraction: The attacker can gain rewards unfairly in the same transaction.
Drains the reward pool: The rewards meant for long-term stakers are stolen by an attacker who does not maintain a legitimate stake.
Manual Review
To mitigate this attack, consider implementing the following solutions:
Impose a minimum staking duration before rewards are claimable.
Use a snapshot mechanism: Calculate rewards based on a user’s balance before their deposit.
Prevent same-block deposit & withdrawal: Introduce a lastActionBlock
variable to enforce a time delay between deposit and withdrawal.
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.