safeTransferFrom is recommended instead of transfer (1)
The contract used the plain ERC20 transfer function rather than a safe wrapper, so tokens that do not return a boolean on transfer (such as USDT) could cause funds to become stuck in the contract with no way to retrieve them. The submitter recommends using safeTransferFrom from SafeERC20 instead.
Originally disclosed on Code4rena
Submitted by MaratCerby, also found by berndartmueller, broccolirob, CertoraInc, cryptphi, danb, gzeon, horsefacts, hyh, joestakey, leastwood, throttle, VAD37, wuwe1, and z3s
ERC20 standard allows transferF function of some contracts to return bool or return nothing. Some tokens such as USDT return nothing. This could lead to funds stuck in the contract without possibility to retrieve them. Using safeTransferFrom of SafeERC20.sol is recommended instead.
Proof of Concept
illuzen (FactoryDAO) commented:
We support ERC20 contracts, not SafeERC20. Contracts that do not conform to the standard are not supported.
illuzen (FactoryDAO) confirmed and resolved:
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the contract called the token's transfer function directly and assumed it returns a boolean, which non-standard tokens such as USDT do not do.
Impact
Tokens that do not return a value on transfer could leave funds stuck in the contract, though the project stated it only supports tokens that conform to the standard.
What the attacker needed
Contract holds a non-standard ERC20 token
The fix
The project resolved the issue by switching to the SafeERC20 wrapper, as shown in the linked pull request.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Some tokens behave slightly differently from the official token standard: when you ask them to move funds, they do not send back a yes/no answer. If a contract expects that answer, the transfer can fail in a way that leaves the money trapped inside the contract. The fix is to use a helper library that copes with both kinds of token.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.