Trick or Treat

First Flight #27
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: medium
Invalid

Trick or Treat findings

Summary

There are 3 submissions on this report.

  1. function withdrawFees doesn't check if balance is > 0 so added that check at the begining.

  2. On line 70 in the fuction "function trickOrTreat(string memory _treatName)" there is possible division by zero and overflow on the same line. Specially for older versions, I undestand this contract is ^0.8.24.

  3. Also on line 70 of the same function indicated above, there is possibility of overflow to the left of the assignment.

Vulnerability Details

#1 issue above
function withdrawFees() public onlyOwner {
// Below line added to check balance is greater than zero
require(address(this).balance > 0, "Cant withdraw below zero!.");
uint256 balance = address(this).balance;
payable(owner()).transfer(balance);
emit FeeWithdrawn(owner(), balance);
}
#2 issue, division by zero line # 70 from code
uint256 requiredCost = (treat.cost * costMultiplierNumerator) / costMultiplierDenominator;
# Division checks:
require(costMultiplierDenominator != 0, "division by zero");
uint256 requiredCost = (treat.cost * costMultiplierNumerator) / costMultiplierDenominator;
#3 overflow fix on line 70
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
using SafeMath for uint256;
uint256 requiredCost = SafeMath.mul(treat.cost, costMultiplierNumerator) / SafeMath.div(costMultiplierDenominator, 1);
require(treat.cost * costMultiplierNumerator < type(uint256).max, "Overflow detected");

Impact

Tools Used

foundry test in playing with inputs

Recommendations

Updates

Appeal created

bube Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
sala1 Submitter
7 months ago
bube Lead Judge
7 months ago
bube Lead Judge 7 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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