Failed transfer with low level call won’t revert
A low-level call in the swap function can return success even when the target contract does not exist, so a failed swap does not revert. An attacker could use this to make a user's funds be transferred to the contract without receiving anything in return.
Originally disclosed on Code4rena
Submitted by GeekyLumberjack, also found by CertoraInc
swap is used throughout the code via _executeSwaps in Swapper.sol. According to Solidity Docs the call may return true even if it was a failure. This may result in user funds lost because funds were transferred into this contract in preparation for the swap. The swap fails but doesn’t revert. There is a way this can happen through GenericSwapFacet.sol due to a missing require that is present in the other facets which is a separate issue but gives this issue more relevance.
Proof of Concept
- Alice uses Generic swap with 100 DAI
- Alice’s 100 DAI are sent to the Swapper.sol contract
- The call on swap
_swapData.callTo.call{ value: msg.value }(_swapData.callData);fails but returns success due to nonexisting contract - postSwapBalance = 0
- Alice receives nothing in return
Recommended Mitigation Steps
Check for contract existence.
A similar issue was awarded a medium here.
Sponsor confirmed with fix.
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 low-level call does not check whether the target address actually contains a contract, so a call to a non-existent contract returns success.
Impact
User funds could be lost because the swap fails without reverting, leaving the transferred funds stuck in the contract.
What the attacker needed
A swap to a non-existent contract address
The fix
The contract should check that the target address contains code before making the low-level call.
How it was found
- Alice uses Generic swap with 100 DAI
- Alice's 100 DAI are sent to the Swapper.sol contract
- The call on swap fails but returns success due to nonexisting contract
- postSwapBalance = 0
- Alice receives nothing in return
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 a smart contract sends a low-level call to another address, the call can report success even if the target address has no code. This means a swap that should fail might not trigger an error, and the user's tokens could be sent to the contract without anything coming back.
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.