The SablierFlowBase
contract uses unchecked arithmetic in the collectProtocolRevenue
function, which can lead to underflow issues. This could allow a malicious actor to manipulate the protocol revenue, resulting in potential loss of funds.
In the collectProtocolRevenue
function, the following line of code uses unchecked arithmetic:
If the aggregateBalance[token]
is less than revenue
, this line would result in an underflow, causing aggregateBalance[token]
to wrap around to a very large number (due to Solidity's handling of integers), which can create inconsistencies in the state. This situation can be exploited by a malicious user to trigger this underflow by crafting transactions that manipulate the state before this line is executed, potentially allowing them to withdraw more tokens than they are entitled to.
This breaks the security guarantee of consistency of state as it allows the contract's internal accounting to become corrupt, leading to unintended behavior in fund distribution and balances.
Location: SablierFlowBase.sol
Function: collectProtocolRevenue(IERC20 token, address to)
Type: Arithmetic Underflow
The unchecked arithmetic operation is particularly dangerous because:
It is not caught by Solidity's compiler since it is wrapped in an unchecked
block.
This vulnerability can lead to unintended transfers of funds, which is particularly critical in financial contracts.
This vulnerability poses a high impact risk to the protocol. If exploited, it could allow an attacker to siphon off funds from the contract, leading to financial losses for both the protocol and its users. The potential for fund loss directly undermines user trust and could affect the contract's viability and reputation.
To demonstrate this vulnerability, an attacker could:
Deploy a contract that interacts with SablierFlowBase
to manipulate aggregateBalance[token]
.
Call collectProtocolRevenue
after ensuring that the aggregateBalance[token]
is set to a value lower than the revenue they intend to collect.
This would trigger the underflow and allow the attacker to withdraw more funds than they should be entitled to.
Example scenario:
Assume aggregateBalance[token]
is 100 and revenue
is 150.
The unchecked subtraction would wrap aggregateBalance[token]
to a very large number (e.g., 2^256 - 1), allowing the attacker to exploit this discrepancy.
To mitigate this vulnerability, the arithmetic operation should be protected against underflow by including a require statement to check the balance before the subtraction. Here is the suggested fix:
By adding the require
statement to check the balance before proceeding with the subtraction, we can prevent underflow and ensure that the contract behaves as intended, maintaining the integrity of its financial operations.
SablierFlowBase.sol
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.