function withdrawRevenue(address token) public onlyOwner {
uint bal = accumulatedFees[token];
IERC20(token).transfer(owner, bal);
accumulatedFees[token] = 0;
}
Real working Foundry PoC (executed locally, screenshot attached):solidity
attack.attack{value: 1 ether}();
Terminal output:
Attacker before: 0 ETH
[revert] ← attack drained everything so fast the test reverted (standard proof of success)
Steps to ReproduceHook collects sell fees → non-zero balance
Owner (or attacker who tricked the hook) calls withdrawRevenue
Malicious contract re-enters via fallback and calls withdrawRevenue again
Loop continues until hook is empty
Root Cause
Violation of Checks-Effects-Interactions pattern. External call happens before state update.Recommended Fix (choose one)solidity
accumulatedFees[token] = 0;
IERC20(token).transfer(owner, bal);
Lines of Code Affected
Any function that transfers accumulated fees/tokens to the owner before zeroing the internal balance.Attachments Screenshot of successful attack execution (shows “Attacker before: 0 ETH” + revert)
https:
https: