DittoETH

Ditto
DeFiFoundryOracle
55,000 USDC
View results
Submission Details
Severity: medium
Invalid

Overflow in Allows Orders Below Minimum Size

Summary

see the vulnerability details it's contain the explaining

Vulnerability Details

this line in code contain vulnerability if (eth < minAskEth) revert Errors.OrderUnderMinimumSize();
the condition checks if the product of price and eth is less than minAskEth. This condition is intended to ensure that the order being created meets a minimum size requirement, it doesn't account for potential overflow.
the overflow in the first condition can lead to the contract not reverting when it should, allowing orders that don't meet the minimum size requirement to be created

  • here is a scenario show the issue
    let's say that an attacker submits a transaction to create an order with the following parameters:

  • *asset to address

  • *price = 1

  • *ercAmount = MAX_UINT256

  • The contract calculates eth as price * ercAmount, which results in eth being set to the maximum possible uint256 value, essentially causing an overflow.

  • minAskEth is a smaller value, let's say 10.

  • Since an overflow has occurred, the condition if (eth < minAskEth) mistakenly evaluates to false because the maximum possible uint256 value is not less than 10.

  • As a result, the contract does not revert as intended and proceeds with the order creation, even though the order size is far below the minimum requirement.

Impact

a malicious users can create orders that don't meet the minimum size requirement, potentially disrupting the intended operation of the contract and causing financial losses.

Tools Used

manual review

Recommendations

add checks before comparing eth and minAskEth as an example :

if (price == 0 || ercAmount == 0) {
revert Errors.InvalidInput(); // here an error code for invalid input values
}
uint256 eth = price.mul(ercAmount);
uint256 minAskEth = LibAsset.minAskEth(asset);
// here Ensure that eth and minAskEth are within valid ranges
if (eth < minAskEth || eth > MAX_ETH_VALUE || minAskEth > MAX_ETH_VALUE) {
revert Errors.OrderUnderMinimumSize();
}
Updates

Lead Judging Commences

0xnevi Lead Judge
over 1 year ago
0xnevi Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

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