Missing from validation in ZeroXSwapVerifier.verifySwapCalldata() enables direct theft of approved funds
The ZeroXSwapVerifier's transferFrom check only confirmed the token matched the expected token and ignored the from and to addresses. An attacker could craft a 0x route that pulls a victim's approved tokens straight to an attacker-controlled address.
Originally disclosed on Immunefi
- Disclosed after under an hour
58079 sc low missing from validation in zeroxswapverifier verifyswapcalldata enables direct theft of approved funds
Submitted on Oct 30th 2025 at 13:33:25 UTC by @Novathemachine for Audit Comp | Alchemix V3
- Report ID: #58079
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/alchemix-finance/v3-poc/blob/immunefi\\_audit/src/utils/ZeroXSwapVerifier.sol
- Impacts:
- Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield
Description
Brief/Intro
ZeroXSwapVerifier approves malicious 0x routes because _verifyTransferFrom() never checks that the from address equals the owner. Once verified, a route can call transferFrom(owner, attacker, amount) and drain the owner’s approved tokens.
Vulnerability Details
-
Where: src/utils/ZeroXSwapVerifier.sol ,
_verifyTransferFrom(bytes action, address owner, address targetToken, uint256 targetAmount). -
What happens: The function decodes
(token, from, to, amount)but only enforcestoken == targetToken. It ignoresfromandto.Solidity (address token, , , uint256 amount) = abi.decode( _slice(action, 4), (address, address, address, uint256) ); require(token == targetToken, "IT"); -
Why it’s bad: Any
transferFromembedded in a 0x route that pulls from the victim will pass verification as long as the token matches. With an existing allowance to the 0x spender, funds move directly to an attacker-controlled address.
Impact Details
- Impact chosen: Direct theft of any user funds, whether at-rest or in-motion, other than unclaimed yield.
- Any user who approved the 0x spender can lose their entire approved balance in a single verified route. No market or timing constraints limit the loss.
References
- Vulnerable code: src/utils/ZeroXSwapVerifier.sol (
_verifyTransferFrom()).
Proof of Concept
Proof of Concept
-
Add this test to src/test/ZeroXSwapVerifier.t.sol:
Solidity function testTransferFromArbitraryRecipientPassesVerification() public { address attacker = address(0xBEEF); uint256 amountToSteal = 10e18; vm.prank(owner); token.approve(spender, type(uint256).max); bytes memory maliciousAction = abi.encodeWithSelector( TRANSFER_FROM, address(token), owner, attacker, amountToSteal ); ZeroXSwapVerifier.SlippageAndActions memory saa = ZeroXSwapVerifier.SlippageAndActions({ recipient: attacker, buyToken: address(0), minAmountOut: 0, actions: new bytes[](1) }); saa.actions[0] = maliciousAction; bytes memory calldata_ = abi.encodeWithSelector(EXECUTE_SELECTOR, saa, new bytes[](0)); bool verified = ZeroXSwapVerifier.verifySwapCalldata( calldata_, owner, address(token), 10_000 ); assertTrue(verified, "verification unexpectedly failed"); vm.prank(spender); token.transferFrom(owner, attacker, amountToSteal); assertEq(token.balanceOf(attacker), amountToSteal, "attacker did not receive stolen funds"); assertEq(token.balanceOf(owner), 100e18 - amountToSteal, "owner balance mismatch after theft"); } -
Run the test:
Bash forge test --match-path src/test/ZeroXSwapVerifier.t.sol --match-test testTransferFromArbitraryRecipientPassesVerification -
Expected result:
verifySwapCalldata()returns true, proving the malicious route is accepted.transferFrom(owner, attacker, amountToSteal)succeeds, and balances reflect the theft.
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 verifier decoded the transferFrom arguments but only compared the token address, leaving the sender and recipient unchecked.
Impact
Any user who approved the 0x spender could lose their entire approved balance in a single verified route, with no market or timing constraints.
What the attacker needed
Victim has approved the 0x spender; attacker can submit a crafted route
The fix
The verifier should also require that the from address equals the owner and that the recipient is the expected one.
How it was found
- Approve the spender for the maximum amount as the owner.
- Build a malicious action that calls transferFrom with the owner as sender and the attacker as recipient.
- Wrap the action in the swap structure and encode the execute call.
- Call verifySwapCalldata and observe it returns true.
- Execute the transferFrom as the spender and confirm the attacker receives the funds.
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.
A verifier is meant to inspect a swap route before it runs and reject anything suspicious. Here it checked only which token was being moved, not who was sending it or where it went, so a route could take tokens from someone who had approved the spender and send them to the attacker.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.