StabilityPool's withdrawal mechanism contains a potential accounting error where user balances may not decrease correctly after withdrawal. There's a discrepancy between the expected and actual balance changes. This could impact the protocol's stability and user funds. When a user withdraws funds, the contract should:
Decrease their userDeposits balance by the withdrawn amount
Burn the corresponding deTokens
Transfer the underlying rTokens back to the user
However, the balance decrease may not exactly match the withdrawal amount. This happen due to:
Rounding errors in the exchange rate calculations
Potential interference from the reward distribution mechanism
Missing synchronization between deToken burns and deposit tracking
The StabilityPool serves as the backbone of RAAC's stability mechanism, allowing users to deposit rTokens and earn RAAC rewards while providing liquidation support. However, i come across an edge case in the withdrawal logic.
When Alice deposits 1000 rTokens into the StabilityPool, she receives deTokens representing her share. Later, when attempting to withdraw 500 rTokens, something unexpected happens. The contract's internal accounting shows her balance decreasing by 500, but the actual token movements don't perfectly align, because the contract allows withdrawals where the balance reduction doesn't exactly match the withdrawn amount. This breaks a fundamental accounting principle in RAAC's stability mechanism. Let's see how the withdraw() function works and see the root cause.
The vulnerability arises in the interaction between these state changes, particularly in how rcrvUSDAmount relates to deCRVUSDAmount through the exchange rate calculations.
The StabilityPool's deposit tracking
DEToken's supply management
The RAACMinter's reward distribution
This creates a scenario where the mathematical invariant: balanceBefore - balanceAfter == withdrawnAmount doesn't hold true in all cases.
Think of it like an account where your withdrawal amount doesn't exactly match the decrease in your balance, a small discrepancy that could compound over time.
At its core, the StabilityPool acts as a buffer, allowing users to deposit rTokens (real estate-backed tokens) in exchange for deTokens (deposit tokens) while earning RAAC rewards. This creates a vital stability layer for the protocol's lending operations.
The core mistake emerges in the withdrawal process. Notice how the StabilityPool handles user withdrawals, look at this simplified example.
This means that when Alice deposits 1000 rTokens and later withdraws 500, the contract's accounting can become misaligned with reality.
The misalignment stems from the complex interaction between three core protocol components as i mentioned earlier above.
The StabilityPool's deposit tracking
The DEToken's supply management
The RAACMinter's reward distribution through the dual-gauge system
This creates a ripple effect through RAAC's real estate stability mechanism. When users provide liquidation support or when the protocol needs to maintain its peg, these small discrepancies could amplify, potentially affecting the protocol's ability to maintain stable real estate backing.
Implement precise accounting that maintains the relationship between rTokens and deTokens throughout the protocol's operations, ensuring RAAC's real estate stability mechanism remains robust and trustworthy.
The precise implementation would track the relationship
This exchange rate calculation needs to maintain precision through all state changes, particularly during reward distributions and liquidations.
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.