DeFiLayer 1Layer 2
14,723 OP
View results
Submission Details
Severity: low
Invalid

Lack of Input Validation in Price Functions

Description

The price_v0, price_v1, and price_v2 functions accept an _i parameter intended to be either 0 or 1, but don't validate this assumption. If _i is greater than 1, the functions will return incorrect results.

Affected Code

https://github.com/CodeHawks-Contests/2025-03-curve/blob/198820f0c30d5080f75073243677ff716429dbfd/contracts/scrvusd/oracles/ScrvusdOracleV2.vy#L107-L143

@view
@external
def price_v0(_i: uint256 = 0) -> uint256:
return self._price_v0() if _i == 0 else 10**36 // self._price_v0()

Vulnerability Details

The price_v0, price_v1, and price_v2 functions are designed to return either the price per share (_i = 0) or the price per asset (_i = 1). However, these functions do not validate the _i parameter, meaning that any value greater than 1 will result in incorrect calculations. For example, if _i = 2, the function will return 10**36 // self._price_v0(), which is not a valid price. This could lead to incorrect price data being returned to downstream systems that rely on the oracle, potentially causing financial losses or disruptions. While this issue is unlikely to be exploited directly, it introduces unnecessary risk and could lead to unexpected behavior in the protocol.

Tools Used

Manual Review

Recommended Mitigation Steps

Add input validation to ensure _i is either 0 or 1:

assert _i <= 1, "Invalid input: _i must be 0 or 1"
Updates

Lead Judging Commences

0xnevi Lead Judge
3 months ago
0xnevi Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.