OrderBook

First Flight #43
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: medium
Likelihood: medium
Invalid

Decimals Mismatch/Manipulation

Problem:
Decimals are set in the constructor and can be any value, but the contract does not enforce a reasonable range (e.g., 0–18).
Protocols may assume 6 or 18 decimals, leading to calculation errors or overflows.

Risk:

  • Protocols interacting with this token may miscalculate values, leading to overflows, underflows, or loss of funds.

  • Attacker can deploy a token with extreme decimals (e.g., 255), breaking integrations.

constructor(uint8 _tokenDecimals) ERC20("MockUSDC", "mUSDC") {
tokenDecimals = _tokenDecimals;
}

Proof of Concept

function testExtremeDecimals() public {
MockUSDC token = new MockUSDC(255); // Max uint8
token.mint(address(this), 1);
// token.balanceOf(address(this)) is now huge (1 * 10**255)
}

Recommended Mitigation

constructor(uint8 _tokenDecimals) ERC20("MockUSDC", "mUSDC") {
- tokenDecimals = _tokenDecimals;
+ require(_tokenDecimals <= 18, "Decimals too high");
+ tokenDecimals = _tokenDecimals;
}
Updates

Lead Judging Commences

yeahchibyke Lead Judge
about 2 months ago
yeahchibyke Lead Judge about 1 month ago
Submission Judgement Published
Invalidated
Reason: Out of scope

Support

FAQs

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