The _stale_check_latest_round_data function in oracle_lib.vy validates staleness but does not check that the returned price is positive:
Missing: assert price > 0, "DSCEngine_InvalidPrice"
This affects two downstream functions:
1. _get_usd_value (line 315): If price = 0, convert(0, uint256) * ADDITIONAL_FEED_PRECISION * amount = 0. All collateral is valued at $0, making every user's health factor 0.
2. _get_token_amount_from_usd (line 361): If price = 0, usd_amount * PRECISION // (0 * ADDITIONAL_FEED_PRECISION) causes division by zero, reverting the transaction. Since liquidate() calls this function, liquidation becomes impossible.
3. Negative price: If Chainlink returns a negative price (technically possible as int256), convert(negative_int256, uint256) in Vyper 0.4.0 will revert due to overflow protection, freezing the entire protocol.
Likelihood: Low -- Chainlink is designed to never return 0 or negative prices. However, oracle malfunctions, misconfiguration, or contract upgrades could theoretically trigger this.
Impact: High -- If triggered:
All positions appear unhealthy (collateral worth $0), but liquidation reverts (division by zero)
Users cannot redeem collateral (health factor check fails)
All funds locked permanently until the oracle recovers
Real-World Precedent: Chainlink documentation explicitly recommends require(price > 0) after every latestRoundData() call.
How the attack works:
Chainlink price feed malfunctions and returns price = 0
_get_usd_value returns 0 for all collateral -- every user's health factor drops to 0
Anyone calling liquidate() triggers _get_token_amount_from_usd, which divides by zero and reverts
Users calling redeem_collateral have their health factor checked -- with collateral worth $0, the check fails
Protocol is in a deadlock: positions are underwater, liquidation is impossible, collateral is trapped
Expected outcome: Complete protocol freeze. All collateral locked until oracle returns a valid price.
Add a price positivity check in the oracle library:
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.