2025-02-raac/contracts/core/pools/StabilityPool/StabilityPool.sol at main · Cyfrin/2025-02-raac
The StabilityPool contract contains a critical vulnerability in its getExchangeRate()
function. Instead of dynamically calculating the exchange rate based on the actual supply and demand of rToken
and deToken
, it always returns a constant 1e18
. This allows an attacker to mint deTokens at an artificially low cost and later withdraw more than their fair share, draining funds from the pool.
You can spot the usage of this function in the withdraw and deposit functions:
2025-02-raac/contracts/core/pools/StabilityPool/StabilityPool.sol at main · Cyfrin/2025-02-raac
2025-02-raac/contracts/core/pools/StabilityPool/StabilityPool.sol at main · Cyfrin/2025-02-raac
The getExchangeRate()
function should compute the exchange rate dynamically based on total deposits and available liquidity:
However, the current implementation ignores this logic and simply returns 1e18
:
2025-02-raac/contracts/core/pools/StabilityPool/StabilityPool.sol at main · Cyfrin/2025-02-raac
The POC test demonstrates how an attacker can deposit at an artificially low rate, then withdraw an excessive amount, extracting free value.
Its a High, as this bug allows users to withdraw more than their fair share, leading to pool depletion and loss of funds for other depositors.
Attackers will continuously deposit and withdraw to extract extra funds.
Users who deposit later could face losses as exploiters drain liquidity.
Hardhat
Uncomment the lines of code in the getExchangeRate function to dynamically calculate exchange rates based on liquidity:
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.