15,000 USDC
View results
Submission Details
Severity: low
Valid

Some ERC20 revert on zero value transfer

Summary

Consider checking that the sended value is not zero. Example: https://github.com/d-xo/weird-erc20#revert-on-zero-value-transfers.

Vulnerability Details

During our analysis, we identified a potential vulnerability related to the absence of checks for zero-value transfers. Specifically, in the _redeemCollateral function and the depositCollateral function, there is no verification to ensure that the amountCollateral being sent is not zero. This vulnerability may lead to unintended behavior or reverts when interacting with tokens that do not support zero-value transfers.

In the _redeemCollateral function, the amountCollateral parameter is not checked for zero before proceeding with the transfer. Similarly, in the depositCollateral function, there is no validation to prevent the transfer of zero amountCollateral.

function _redeemCollateral(address from, address to, address tokenCollateralAddress, uint256 amountCollateral)
private
{
s_collateralDeposited[from][tokenCollateralAddress] -= amountCollateral;
emit CollateralRedeemed(from, to, tokenCollateralAddress, amountCollateral);
bool success = IERC20(tokenCollateralAddress).transfer(to, amountCollateral);
if (!success) {
revert DSCEngine__TransferFailed();
}
}

In this depositCollateral function there is no check of sending zero value of amountCollateral

function depositCollateral(address tokenCollateralAddress, uint256 amountCollateral)
public
moreThanZero(amountCollateral)
isAllowedToken(tokenCollateralAddress)
nonReentrant
{
s_collateralDeposited[msg.sender][tokenCollateralAddress] += amountCollateral;
emit CollateralDeposited(msg.sender, tokenCollateralAddress, amountCollateral);
bool success = IERC20(tokenCollateralAddress).transferFrom(msg.sender, address(this), amountCollateral);
if (!success) {
revert DSCEngine__TransferFailed();
}
}

Impact

Some tokens (e.g. LEND) revert when transferring a zero value amount.

Tools Used

Manual Review

Recommendations

Implementing checks to verify that the amountCollateral being sent is not zero before proceeding with the transfer.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.