The collectFee function in Snow.sol performs external calls (transfer and call) to send the contract’s entire WETH and ETH balance to s_collector before updating any state variables or performing checks (aside from the onlyCollector modifier). Currently, the function does not modify any internal state variables, so a reentrancy attack cannot cause direct financial loss. However, the pattern violates the Checks-Effects-Interactions principle and creates a dangerous precedent: if any state variable (e.g., a fee counter, a withdrawal lock, or a rate limiter) is added in the future without moving it before the external call, the contract will become critically vulnerable.
An attacker can deploy a malicious contract set as s_collector that re-enters collectFee() during the ETH transfer.
Malicious Collector Contract:
solidity
Steps:
Deploy MaliciousCollector with the address of Snow.
Set the collector in Snow to the malicious contract (requires governance approval or exploit of the setter).
Someone calls collectFee() legitimately. The function sends ETH to MaliciousCollector, its receive() triggers collectFee() again.
Currently, the second call does nothing harmful because balances are zero. However, if a state variable like totalFeesCollected were decremented after the call, the attacker could drain extra funds or bypass limits.
The contest is live. Earn rewards by submitting a finding.
Submissions are being reviewed by our AI judge. Results will be available in a few minutes.
View all submissionsThe contest is complete and the rewards are being distributed.