DeFiFoundrySolidity
16,653 OP
View results
Submission Details
Severity: medium
Invalid

Dangerous Strict Equality Check in `YieldTokenMock.price()` Function Can Lead to Permanent Price Manipulation

Summary

The YieldTokenMock.price() function uses a strict equality check (==) to determine if totalSupply() is zero. This can be manipulated by an attacker who could send a tiny amount of tokens to ensure totalSupply() is never exactly zero, causing unexpected behavior in price calculations.

Vulnerability Details

I think following problems may occur:

  • The price calculation could become permanently stuck in an unintended state

  • Token pricing mechanism could be manipulated to always return the non-zero price path

  • This could affect any protocol mechanisms that rely on accurate price calculations

  • Could lead to economic exploits if price is used for minting, burning, or exchange calculations

Impact

Medium

Tools Used

Slither

Recommendations

We can use a threshold check instead of strict equality to determine if the total supply is effectively zero:

function price() public view returns (uint256) {
- if (totalSupply() == 0) {
+ // Consider both exact zero and negligible amounts
+ uint256 supply = totalSupply();
+ if (supply == 0 || supply < DUST_THRESHOLD) {
return 0;
}
return (totalValue() * 10**decimals()) / totalSupply();
}
Updates

Appeal created

inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Out of scope
inallhonesty Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Out of scope

Support

FAQs

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