A reentrancy vulnerability was identified in SablierFlow.sol. This vulnerability allows an attacker to repeatedly call the deposit function before the initial function call completes, potentially draining funds from the contract. The vulnerability was demonstrated using a test case with a amount of 1000 ether.
The SablierFlow contract contains a deposit function that is vulnerable to reentrancy attacks. The attacker can exploit this vulnerability by creating a malicious contract that repeatedly calls the deposit function before the initial function call completes. This allows the attacker to drain funds from the contract.
Code snippet affected
Copy the POC to a new file in tests/integration/concrete/batch/StabilerFlowTest.t.sol
Test Output
Explanation:
The test code sets up the SablierFlow contract and an Attacker contract. The Attacker contract exploits the reentrancy vulnerability by repeatedly calling the deposit function before the initial function call completes. The test logs show that the attacker's balance increased from 0 to 1000 ether after the attack, indicating that the reentrancy attack was successful.
The reentrancy vulnerability allows an attacker to drain funds from the SablierFlow
contract. This can result in significant financial losses for the contract's users and the contract owner. Specifically, the attacker can repeatedly call the deposit
function, draining the contract's balance and transferring the funds to the attacker's address. This can lead to a complete loss of funds for the contract's users and a significant financial impact on the contract owner.
Foundry
Use the Checks-Effects-Interactions Pattern: Ensure that all state changes (checks and effects) are made before any external calls (interactions). This prevents reentrancy attacks by ensuring that the contract's state is updated before any external calls are made.
Use Reentrancy Guards: Implement reentrancy guards using the ReentrancyGuard contract from OpenZeppelin. This contract provides a modifier that can be applied to functions to prevent reentrancy attacks.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.