Moonwell

Moonwell
DeFiFoundry
15,000 USDC
View results
Submission Details
Severity: high
Invalid

Unchecked Math Operations in MErc20DelegateFixer.sol

Summary

The provided Solidity smart contract, MErc20DelegateFixer, exhibits a high-severity vulnerability due to unchecked math operations, particularly in the getCashPrior function. This vulnerability may lead to arithmetic overflow or underflow, posing a significant risk to the integrity of financial calculations within the contract.

Vulnerability Details

The critical vulnerability lie 134 in the following line of code within the getCashPrior function:

return EIP20Interface(underlying).balanceOf(address(this)) + badDebt;

The addition operation lacks proper overflow and underflow checks, creating a scenario where unexpected behavior and potential financial loss can occur

Impact

Exploiting this vulnerability could have severe consequences, including the manipulation of cash calculations, loss of funds, or even a denial-of-service attack. The getCashPrior function plays a crucial role in determining the available cash in the market, and an unchecked addition operation significantly jeopardizes the accuracy of this calculation.

Tools Used

The vulnerability was identified through manual code review.

Recommendations

1.Immediate Patching: Prioritize an urgent update to the contract code by implementing proper overflow and underflow checks in the vulnerable line of code.
Example:

return SafeMath.add(EIP20Interface(underlying).balanceOf(address(this)), badDebt);
  1. Use SafeMath Library or Solidity Built-in Checks: Incorporate the OpenZeppelin SafeMath library or leverage the built-in overflow and underflow checks available in Solidity versions >=0.6.0 and <0.8.0 to ensure secure arithmetic operations.

  2. Upgrade to the Latest Solidity Version: Consider upgrading the Solidity version to the latest stable release to benefit from improved language features, security enhancements, and bug fixes.

Updates

Lead Judging Commences

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.