OrderBook

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

Lack of Input Validation (Overflow/Underflow on Mint)

Problem:
No checks on the value parameter in mint.
If value is extremely large, value * 10 ** updateDecimals can overflow, even in Solidity 0.8.x (which reverts on overflow, but still leads to DoS).

Risk:

  • Attacker can cause mint to revert for all users by passing a value that overflows.

  • Potential for DoS or protocol disruption.

function mint(address to, uint256 value) public {
uint256 updateDecimals = uint256(tokenDecimals);
_mint(to, (value * 10 ** updateDecimals));
}

Proof of Concept

function testMintOverflow() public {
MockUSDC token = new MockUSDC(18);
// This will revert due to overflow
token.mint(address(this), type(uint256).max);
}

Recommended Mitigation

function mint(address to, uint256 value) public onlyOwner {
- uint256 updateDecimals = uint256(tokenDecimals);
- _mint(to, (value * 10 ** updateDecimals));
+ uint256 updateDecimals = uint256(tokenDecimals);
+ require(value <= type(uint256).max / (10 ** updateDecimals), "Overflow");
+ _mint(to, (value * 10 ** updateDecimals));
}
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.