The collectFee() function in Snow.sol allows the collector to withdraw accumulated WETH and ETH fees from the contract to the designated collector address
The function performs external calls (i_weth.transfer and payable.call) before completing all state updates, creating a reentrancy vulnerability that allows malicious collectors to drain contract funds repeatedly in a single transaction
Likelihood:
The collector address calls collectFee() during normal fee collection operations
A malicious collector deploys a contract with a fallback function that re-enters collectFee() when receiving ETH via the low-level call
Impact:
Attackers drain all WETH and ETH balances from the Snow contract through recursive calls
Legitimate users lose their accumulated fees permanently as the contract balance reaches zero
The attack exploits the reentrancy vulnerability in collectFee() by deploying a malicious collector contract. When the Snow contract sends ETH via the low-level call, it triggers the attacker's receive() fallback function before completing execution. This callback re-enters collectFee() recursively, draining all funds.
Attack Flow:
Attacker deploys MaliciousCollector and gets set as the collector address
Attacker calls startAttack() to initiate collectFee()
Snow.collectFee() transfers WETH, then sends ETH via payable.call
The ETH transfer triggers MaliciousCollector.receive()
receive() immediately calls collectFee() again (reentrancy)
Steps 3-5 repeat 10 times, draining the contract
After 10 iterations, the attack completes with all funds stolen
Expected Result: The attacker drains 10x the normal fee amount in a single transaction. If the Snow contract holds 100 ETH, the attacker extracts 1000 ETH worth of value through recursive calls.
Add OpenZeppelin's ReentrancyGuard contract and apply the nonReentrant modifier to the collectFee function. This prevents recursive calls during execution and protects against reentrancy attacks.
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.