The Swivel protocol assumes that token transfers always deliver the exact amount specified, so it fails with fee-on-transfer tokens. If a fee is activated on an underlying token like USDT, functions such as redeeming the underlying would revert, blocking users from accessing their funds.
The current implementation doesn’t work with fee-on-transfer underlying tokens. Considering that Compound can have these kind of tokens (ex. USDT can activate fees), this issue can affect the protocol.
The problem arises when transferring tokens, basically blocking all functions in Swivel.sol for that particular token, since the contract wrongly assumes balances values. This becomes particularly problematic in the following scenario: a market for USDT is running without problems, then they activate the fee: this effectively blocks users from redeeming the underlying.
Proof of Concept
grep 'transfer' Swivel.sol for a complete list of affected lines (basically every tranfer or transferFrom of underlying tokens). Also grep 'redeemUnderlying' Swivel.sol.
For example:
require(CErc20(mPlace.cTokenAddress(u, m)).redeemUnderlying(redeemed) == 0, 'compound redemption failed');
// transfer underlying back to msg.sender
Erc20(u).transfer(msg.sender, redeemed);
This would fail (revert) since the contract would have received less than redeemed tokens.
Tools Used
editor
Recommended Mitigation Steps
If the protocol wants to use all possible Compound tokens, a way to handle these tokens must be implemented. A possible way to do it is to check the balance of the contract before and after every time a token is transferred to see the effective quantity. To help keeping the code clear, a function like Compound’s doTransferIn can be implemented.
2 — Med: Assets not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.
based on this “leaking value” I would say it qualifies as a med-severity.
We can account for the transfers in with a similar balance before transferFrom, and balance after check, in order to prevent additional deposits after a fee has been turned on.
That said, Im not sure we can account for redeemUnderlying easily because should a fee be turned on, all funds would just be stuck in our contract if we added a similar check? (a != balance2-balance1)
If a fee is turned on for USDT markets, there would be lost fee value, so if adding a check wouldn’t work, the most reasonable response is just to make sure the market is pausable.
The original report as published on Code4rena, by 0xsanson. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 40 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
The contract does not account for fee-on-transfer tokens, assuming the received amount equals the transferred amount.
Impact
If a fee is activated on an underlying token, functions like redeeming the underlying would revert, blocking users from accessing their funds; the impact is limited to tokens with such fees.
What the attacker needed
Underlying token has fee-on-transfer enabled
The fix
The contract should measure the actual balance change before and after each transfer, similar to Compound's doTransferIn, and consider making the market pausable.
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.
Generating the AI write-up for this report.
This usually takes about 40 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
Some tokens take a small fee when they are transferred, so the receiver gets less than the sender sent. The Swivel contract assumed it always received the full amount, so its balance checks failed and transactions reverted. This meant users could not redeem their tokens if such a fee was turned on.
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.