The StabilityPool's reward distribution mechanism has a critical flaw where users can exploit the reward calculation logic to unfairly earn RAAC rewards in a single transaction without maintaining deposits over time. An attacker can use flash loans to maximize profits by depositing and withdrawing large amounts of rTokens within the same transaction.
To understand the vulnerability, let's first understand how the reward distribution works:
The StabilityPool rewards depositors with RAAC tokens for providing liquidity (RTokens).
The reward minting process:
The RAACMinter's tick() function:
From the code above we see that New rewards are minted whenever a block number increases, which happens with each new transaction.
When a user deposits, the StabilityPool immediately mints new RAAC rewards and includes the depositor's share in the reward calculation calculateRaacRewards() also it doesn't consider any deposit duration or cooldown.
Also the current implementation allows users withdraw immediately after depositing.
An attacker can exploit this by:
Taking a flash loan for a large amount of rTokens
Depositing these rTokens into the StabilityPool
Immediately withdrawing the deposit and rewards in the same transaction
Repaying the flash loan
Keeping the RAAC rewards as profit
The exploit is particularly severe because:
The attacker's large deposit temporarily gives them a massive share of the reward pool
They can repeat this across multiple blocks
Flash loans allow them to do this with minimal capital
Unfair distribution of RAAC rewards
Attacker can use flash loans to maximize the RAAC rewards emitted there by causing the RAACToken supply to be inflated which damages for the tokenomics of protocol.
Depletion of protocol incentives meant for legitimate long-term liquidity providers
Discouragement of legitimate staking behavior
Manual code review
Foundry for testing and PoC
These are just some rough ideas :)
Implement a minimum staking period before rewards can be claimed
Find creative ways to prevent deposit and withdraw from happening in a single tx
Add vesting periods for 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.