In the SablierV2 contracts, several instances of ERC20 token transfers do not account for zero value transfers, which can cause transactions to revert unexpectedly. This report identifies the affected lines in different contract files and suggests best practices to handle zero value transfers safely.
The issue arises due to the use of safeTransferFrom
and safeTransfer
functions in several contract files without checking if the transfer amount is zero. According to the ERC20 standard, while some implementations allow zero value transfers, others may revert. The following lines in the SablierV2 contracts are affected:
https://github.com/Cyfrin/2024-05-Sablier/tree/main/v2-core/src/SablierV2LockupDynamic.sol#L357
https://github.com/Cyfrin/2024-05-Sablier/tree/main/v2-core/src/SablierV2LockupDynamic.sol#L361
https://github.com/Cyfrin/2024-05-Sablier/tree/main/v2-core/src/SablierV2LockupLinear.sol#L277
https://github.com/Cyfrin/2024-05-Sablier/tree/main/v2-core/src/SablierV2LockupLinear.sol#L281
https://github.com/Cyfrin/2024-05-Sablier/tree/main/v2-core/src/abstracts/SablierV2Lockup.sol#L599
https://github.com/Cyfrin/2024-05-Sablier/tree/main/v2-core/src/abstracts/SablierV2Lockup.sol#L652
https://github.com/Cyfrin/2024-05-Sablier/tree/main/v2-periphery/src/SablierV2BatchLockup.sol#L341
The inability to handle zero value transfers can cause legitimate transactions to fail, leading to disruptions in the functionality of the protocol . This can affect user experience and the reliability of the contracts, potentially causing a loss of confidence in the platform.
Manual code review
Implement Zero Value Checks: Before calling safeTransferFrom
or safeTransfer
, check if the value is zero and handle it appropriately. For example:
https://docs.codehawks.com/hawks-auditors/how-to-determine-a-finding-validity
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.