redeemToken can fail for certain tokens
The redeemToken function uses transferFrom to move tokens from the contract to the user, which can fail for some ERC20 tokens that check allowances even when the sender is the from address. This could cause the transaction to revert and the user's deposited funds to become unrecoverable.
Submitted by cmichel, also found by hickuphh3, pauliax and jonah1005XXX
The SwappableYieldSource.redeemToken function transfers tokens from the contract back to the sender, however, it uses the ERC20.transferFrom(address(this), msg.sender, redeemableBalance) function for this. Some deposit token implementations might fail as transferFrom checks if the contract approved itself for the redeemableBalance instead of skipping the allowance check in case the sender is the from address.
This can make the transaction revert and the deposited funds will be unrecoverable for the user.
It’s recommended to use _depositToken.safeTransfer(msg.sender, redeemableBalance) instead.
PierrickGT (PoolTogether) commented:
Duplicate of https://github.com/code-423n4/2021-07-pooltogether-findings/issues/25
re-opening this issue and marking #25 as a duplicate of this issue which clearly articulates the potential severity of unrecoverable user funds.
PierrickGT (PoolTogether) resolved:
This issue has been fixed and we are now using
safeTransfer: https://github.com/pooltogether/swappable-yield-source/blob/bf943b3818b81d5f5cb9d8ecc6f13ffecd33a1ff/contracts/SwappableYieldSource.sol#L235
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 used transferFrom instead of safeTransfer to send tokens back, which fails for tokens that require an allowance even when the sender and owner are the same.
Impact
For certain deposit tokens, the redemption transaction could revert, leaving the user's deposited funds unrecoverable.
What the attacker needed
Deposit token with allowance check on transferFrom
The fix
The issue was fixed by using safeTransfer instead of transferFrom.
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.
When you deposit tokens into a smart contract, you expect to get them back later. This contract tried to send tokens back using a method that some tokens reject unless the contract has given itself permission first. That mistake could lock your tokens forever.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.