An issue was identified in the SablierFlow
smart contract where a stream can be created with a zero ratePerSecond
. This could lead to unintended behavior, logical errors, or potential exploitation since a zero rate per second doesn't make practical sense in streaming payments.
In the SablierFlow
contract, the createAndDeposit
function allows users to create a payment stream specifying the ratePerSecond
. However, there's no check to ensure that the ratePerSecond
is non-zero. Allowing a zero value could cause division by zero errors or faulty calculations in functions that depend on this rate.
Below is a Proof of Concept (PoC) demonstrating the issue:
Explanation:
Setup Phase:
Deploys necessary contracts (MockFlowNFTDescriptor
, SablierFlow
, ERC20Mock
).
Mints tokens to Alice and sets approval for SablierFlow
.
Logs deployment addresses and actions for clarity.
Test Phase (testZeroRatePerSecondReverts
):
Starts a prank as Alice to simulate her actions.
Attempts to create a stream with a zero ratePerSecond
, which should fail (but does not)
Asserts that current streamID is now 1, meaning that the stream was created successfully
Logs the current streamID, which is now 1
Attempts to create second stream with a zero ratePerSecond
, which should fail (but does not)
Assert that current streamID is now 2, meaning that the stream was created successfully
Logs the current streamID, which is now 2
Logs each step to provide a detailed trace.
Logical Errors: Functions relying on ratePerSecond
may malfunction, causing incorrect calculations or division by zero errors.
Potential Exploitation: Malicious actors could exploit this to disrupt contract functionality or manipulate streams for unintended benefits.
Financial Loss: Users may experience loss of funds due to incorrect streaming or failure of the contract to enforce proper payment schedules.
Foundry: A blazing fast, portable, and modular toolkit for Ethereum application development written in Rust.
Solidity Compiler (solc): Version 0.8.22 for compiling smart contracts.
Forge Std Library: For enhanced testing capabilities and console logging.
Input Validation: Modify the createAndDeposit
function to include a check ensuring ratePerSecond
is greater than zero.
Comprehensive Testing: Implement additional unit tests to cover edge cases and ensure that invalid inputs are correctly handled.
Code Review: Conduct a thorough audit of all functions that utilize ratePerSecond
to ensure they are robust against zero or invalid values.
User Documentation: Update user guidelines to inform about valid input ranges for creating streams.
By addressing this issue, the SablierFlow
contract will be more secure and function as intended, preventing potential misuse or errors arising from zero ratePerSecond
values.
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.