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

Collateral ERC20 interaction will revert for many tokens

Summary

DSCEngine.sol assumes that all ERC20 tokens used as collateral will return a success bool.

Vulnerability Details

DSCEngine.sol assumes that all ERC20 tokens used as collateral will return a success bool. This isn't true. Many popular ERC20 tokens like Tether return nothing on successful transfer and instead reverts on failure.

Impact

DSCEngine will fail to use popular tokens like Tether as collateral as the depositCollateral, _redeemCollateral methods will revert even though the transfer/transferFrom call on the collateral actually succeeded.

Tools Used

Recommendations

I recommend wrapping the collateral ERC20 token with SafeERC20(from OpenZeppelin) and using the safeTransfer/safeTransferFrom methods instead.

These will handle both cases of:

  1. ERC20 tokens returning a boolean representing the success state

  2. ERC20 tokens not returning a boolean and instead just reverting on failure state

SafeERC20 docs: https://docs.openzeppelin.com/contracts/4.x/api/token/erc20#SafeERC20

Support

FAQs

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