Issue Description
The _raw_price
function computes the price as:
Here, _total_supply
is defined as:
If the unlocked shares become equal to or greater than p.total_supply
—or if the supplied parameters are maliciously set—the resulting effective supply could be zero, leading to a division by zero error.
Denial of Service:
If an attacker (or a misbehaving prover) can supply parameters that cause _total_supply
to be zero, any call to _raw_price
(and consequently update_price
) will revert with a division error. This can halt price updates and disrupt dependent protocols.
Mitigation:
The oracle should either validate that the effective supply is nonzero before performing division or include a fallback mechanism.
Add Check for Zero Supply:
Before performing the division in _raw_price
, add a require statement or conditional check to ensure that _total_supply(parameters, ts)
is greater than zero. For example:
Note that `total_supply` and `profit_unlocking_rate` is initially set to 1 and 0 respectively when the `ScrvusdOracleV2.vy` is deployed 1. `total_supply` and `profit_unlocking_rate` is part of the price param updates within `update_price`, which must have gone through verification via the OOS `StateProofVerifier` contract, so there is no evidence that a 0 supply is allowed either via a 0 supply update or an extremely high `profit_unlocking_rate`. 2. Since price is retrieved via values retrived from the V3Vault, if there is no supply, there is arguably no price to be posted. As such, reverting is arguably the correct choice since a 0 price value is not expected from scrvUSD, which is a stable coin.
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.