The SablierV2LockupTranched::_calculateStreamedAmount
function relies on block.timestamp
to determine the streamed amount. A malicious actor can manipulate block.timestamp
to claim the upcoming tranche prematurely, defrauding a buyer.
The withdrawal of tokens in SablierV2LockupTranched
depends on the SablierV2LockupTranched::_calculateStreamedAmount
function, which uses block.timestamp
for calculations. Combined with the fact that ERC721::transferFrom
, ERC721::safeTransferFrom
, and other transfer functions do not enforce a minimum withdrawable balance on the stream, a malicious user can exploit this vulnerability as follows:
Scenario Setup: Consider a stream with two tranches of 𝑥 tokens each (total of 2𝑥 tokens). The first tranche has already been claimed, and the next tranche is imminent.
Listing for Sale: The malicious user lists the NFT, indicating a SablierV2NFTDescriptor::streamedPercentage
of 50% (𝑥 tokens left), at a discounted price of 0.8𝑥 (20% off) just before the next tranche timestamp.
User Purchase: Another user (User2) sees the discounted stream and purchases it for 0.8𝑥, perceiving it as a risk-free trade.
Timestamp Manipulation and Withdrawal: The malicious user front-runs User2's purchase transaction, manipulates block.timestamp to withdraw the next tranche, and calls the SablierV2Lockup::withdrawMax
function.
Result: User2's transaction, not accounting for this "slippage," goes through, leaving him with a stream that has zero withdrawable funds. The malicious user profits by gaining both the 0.8𝑥 from the sale and 1𝑥 from the withdrawal.
This vulnerability allows scammers to defraud users, resulting in significant financial losses. Over time, this could diminish user trust and reduce the popularity of trading streams within the protocol.
Manual Review
override the transfer functions and implement a Slippage Mechanism: Add a slippage mechanism to the transfer functions to ensure buyers receive at least a minimum withdrawable amount of tokens. For example (pseudo code):
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.