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

Incorrect change in ```params.total_supply``` when the ```params.balance_of_self``` is greater.

Summary

The vulnerability exist when params.balance_of_self is greater than params.total_supply due to forcefully sent amaount. Therefore when we implement the formula trying to reduce from params.total_supply will return zero. A mallicious attacker could exploit this attacking vector to prevent reducing the params.total_supply.

Vulnerability Details

Link to the vulnerability: https://github.com/CodeHawks-Contests/2025-03-curve/blob/198820f0c30d5080f75073243677ff716429dbfd/contracts/scrvusd/oracles/ScrvusdOracleV2.vy#L266

params.total_supply -= (
params.balance_of_self * params.balance_of_self // params.total_supply

Impact

Example:
params.total_supply = 20 000
params.balance_of_self = 10 000

params.total_supply -= (
params.balance_of_self * params.balance_of_self // params.total_supply )
# 10 000 * 10 000 // 20 000 = 5 000 (Expected)

params.total_supply - 5 000 = 20 000 - 5 000 = 15 000 (Expected)
Now the attacker sends forcefully 10 500
params.total_supply = 20 000
params.balance_of_self = 20 500

params.total_supply -= (
params.balance_of_self * params.balance_of_self // params.total_supply )
# 20 500 * 20 500 // 20 000 = 21 012 ( Unexpected)

params.total_supply- 21 012 = 20 000 - 21 012 = 0 ( total_supply remains 20 000)

Tools Used

Mannual review

Recommendations

Use safe checks before calculation:

if params.balance_of_self > params.total_supply:
params.balance_of_self = params.total_supply # Cap it to avoid issues

Ensure that the subtraction does not result in underflow:

params.total_supply = max(
params.total_supply - (params.balance_of_self * params.balance_of_self // params.total_supply),
MINIMUM_TOTAL_SUPPLY
)
# Never goes zero or unchanged
Updates

Lead Judging Commences

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

Support

FAQs

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