Unhandled return value of transferFrom in timeLockERC20() could lead to fund loss for recipients
The timeLockERC20 function calls transferFrom without checking its return value, so a failed transfer can be ignored while the contract still records the tokens as locked. An attacker could exploit this to make a recipient believe funds are locked when they are not, leading to loss for the recipient.
Submitted by 0xRajeev, also found by Sherlock, pauliax, shw, and JMukesh
ERC20 implementations are not always consistent. Some implementations of transfer and transferFrom could return ‘false’ on failure instead of reverting. It is safer to wrap such calls into require() statements or use safe wrapper functions implementing return value/data checks to handle these failures. For reference, see similar Medium-severity finding from Consensys Diligence Audit of Aave Protocol V2.
While the contract uses Uniswap’s TransferHelper library function safeTransfer in other places for ERC20 tokens, or OpenZeppelin’s saferTransferFrom for ERC721 tokens (both of which call the token’s transfer/transferFrom functions and check return value for success and return data), it misses using TransferHelper.safeTransferFrom in this one case on L610 in timeLockERC20() when tokens are transferred from owner to the vault and instead directly uses the token’s transferFrom() call without checking for its return value.
The impact can be that for an arbitrary ERC20 token, this transferFrom() call may return failure but the vault logic misses that, assumes it was successfully transferred into the vault and updates the timelockERC20Balances accounting accordingly. The timeUnlockERC20(), transferERC20() or delegatedTransferERC20() calls for that token will fail because the vault contract balance would have less tokens than accounted for in timelockERC20Balances because of the previously failed (but ignored) transferFrom() call.
- Let’s say Alice owes Bob 100 USD after a week, for which they agree that Alice will pay in 100 tokens of USD stablecoin tokenA.
- Alice, the vault owner, calls
timeLockERC20()for recipient=Bob, token=tokenA, amount=100 and expiry=1-week-from-then (corresponding Unix timestamp) but tokenA’s implementation does not revert on failure but instead returns true/false. If thetransferFromfailed, say because Alice did not have those 100 tokenAs, the return value is ignored on L610 intimeLockERC20()and vault logic considers that it indeed has 100 tokenAs locked for Bob. - Bob looks at the
TimeLockERC20event emitted in the successfultimeLockERC20()transaction from Alice and assumes 100 tokenAs are indeed locked by Alice in the vault for him which can be withdrawn after expiry. - After timelock expiry, Bob tries to transfer the 100 tokenAs Alice locked in the vault for him. The
TransferHelper.safeTransfer()call on L637 intimeUnlockERC20()fails because the vault has 0 tokenAs because they were never successfully transferred in Step 2. - Bob could thus be tricked into thinking that 100 tokenAs are locked in the vault for him by Alice but they never were. This leads to loss of funds for Bob.
Recommend replacing use of
IERC20(token).transferFrom(msg.sender, address(this), amount);
with
TransferHelper.safeTransferFrom(token, msg.sender, address(this), amount);
This will revert on transfer failure for e.g. if msg.sender does not have a token balance >= amount.
xyz-ctrl (Visor) acknowledged:
sponsor acknowledged disagree with severity 0 While we may include refactor in next version, this is all foreseen behavior and is component of many stable ethereum project. The onus here is on client
I’m going to make it medium as the risk is there but it could be mitigated by UI and tokens that are used.
fixed patch link
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
The contract uses the token's transferFrom directly without checking its return value, unlike other places where it uses a safe wrapper that verifies success.
Impact
A recipient could be tricked into thinking tokens are locked for them when they are not, leading to loss of funds for the recipient; the risk could be mitigated by UI and the tokens used.
What the attacker needed
Token returns false on failure instead of reverting; vault owner initiates a timelock; recipient relies on the event
How it was found
- Alice calls timeLockERC20 for Bob with a token that returns false on failure instead of reverting.
- The transferFrom fails (e.g., Alice lacks balance), but the return value is ignored and the vault records the tokens as locked.
- Bob sees the TimeLockERC20 event and believes the tokens are locked for him.
- After expiry, Bob tries to unlock, but the safeTransfer fails because the vault never received the tokens.
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 signal failure by returning false instead of stopping the program with an error. If the contract ignores that false, it may think a transfer succeeded when it did not. This can trick someone into believing they have funds locked in the contract when they actually do not.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.