The RAAC protocol's calculateHealthFactor
function contains a critical precision vulnerability in its minimum debt check. When a user's debt approaches but doesn't quite reach zero, the function fails to properly handle the precision scaling between RAY (1e27) and regular (1e18) units, allowing positions to avoid liquidation even when they should be liquidated.
Impact: HIGH
Direct financial impact through prevention of necessary liquidations
Affects core protocol safety mechanism
Potential for significant value extraction
Protocol-wide risk due to accumulation of bad debt
Likelihood: HIGH
Can be exploited through normal protocol operations
No special permissions required
Consistently reproducible
Low technical barrier to exploit
This vulnerability allows users to manipulate their positions to become "unliquidatable" by maintaining a minimal debt amount that triggers precision inconsistencies between RAY and regular units. When the debt is small enough (but greater than 1 wei), the health factor calculation produces inflated results, preventing legitimate liquidations even when the collateral value has significantly decreased.
Financial Loss: A malicious user could lock significant collateral value while maintaining minimal debt, effectively preventing liquidation even during market crashes.
Protocol Insolvency Risk: Multiple exploited positions could lead to protocol-wide insolvency if collateral values drop significantly.
Market Impact: Exploiters could profit from market movements while being protected from liquidation.
Similar precision-based vulnerabilities have led to significant exploits:
Compound Finance (2020): $500k exploit due to precision handling in liquidation calculations
Venus Protocol (2021): $11M loss partially due to precision issues in health factor calculations
The following test demonstrates how a user can exploit the precision vulnerability to avoid liquidation:
The vulnerability occurs because:
The minimum debt check (if (userDebt < 1)
) is too simplistic
The interaction between RAY math (rayMul
) and regular math creates precision gaps
The health factor calculation doesn't properly normalize these precision differences
Implement proper minimum debt threshold with RAY precision:
Add proper validation in the borrow and repay functions:
Immediate (24h):
Add minimum debt threshold
Implement forced full repayment for dust amounts
Add event logging for threshold violations
Short-term (1 week):
Add comprehensive precision tests
Implement monitoring for dust positions
Update documentation and risk parameters
Manual code review
Foundry for PoC testing
Echidna for property-based testing
Tenderly for transaction simulation
Total: 10 hours
Initial Analysis: 3h
Math Validation: 3h
PoC Development: 2h
Documentation: 2h
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.