Trick or Treat

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

Reentrancy in `TrickOrTreat::SpookySwap.withdrawFees` function

Summary : The TrickOrTreat::SpookySwap.withdrawFees function lets the contract owner withdraw funds, but it has a reentrancy vulnerability. This means that if the owner is a contract, it could potentially exploit this function to withdraw more money than intended

Vulnerability Details : When the function transfers the contract's balance to the owner, it doesn’t update the state (like emitting an event) until after the transfer. If the owner's address is a contract, it can re-enter the function before the state changes, allowing it to withdraw additional funds.

Impact : An attacker could drain funds from the contract by repeatedly calling TrickOrTreat::SpookySwap.withdrawFees function, leading to a loss of trust in the contract’s security.

Tools Used : Slither & Manual Review

Recommendations :

function withdrawFees() public onlyOwner {
uint256 balance = address(this).balance;
+ emit FeeWithdrawn(owner(), balance);
payable(owner()).transfer(balance);
- emit FeeWithdrawn(owner(), balance);
}
Updates

Appeal created

bube Lead Judge 9 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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