Hi,
I have found out a potential bug in contract 'ScrvusdOracleV2.vy' in which the function _smoothed_price
uses unsafe_sub
for calculation of raw_price + max_change - last_price
which can create unreleable results and ultimately cause integer overflow/underflow issue.
The key details of this potential vulnerability can be given as follows:
In the function _smoothed_price
, it uses unsafe_sub
to calculate max_change
in which bypassing of vyper's underflow/overflow checks is possible (although it's possible to get negative results in investment value yet it's important to maintain security norms and checks).
If last_price
is too large, subtraction wraps around and mechanism behaves incorrectly which allows the attacker to manipulate prices and bypassing smoothing limits.
**Reference: **https://security.snyk.io/vuln/SNYK-PYTHON-VYPER-5880665
Manual Code Analysis
It's good to do some changes in code and get checks for each scenario for price change:
If underflow occurs, it must have meant that `raw_price` has deviated from `last_price` by more than `max_change`, meaning it is correct to restrict the `last_price` increment to `max_change`
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.