Don't Get Rekt

Smart contract bugs / What does it trust?

Arbitrary external calls

A router, aggregator or zap contract calls any address with any data that the user gives. The attacker makes it call transferFrom on tokens that users approved.

OWASP SC06:2026 · 64 real exploits · $686.4M lost

How the attack works

  1. Users give the contract an unlimited token approval, so it can swap for them.
  2. A function such as swap(target, data) or multicall calls target.call(data) with values that the caller chooses.
  3. The attacker sets target to a token and data to transferFrom(victim, attacker, amount).
  4. The token sees the router as the spender, and the router has the approval. The attacker drains every wallet that approved the router.

Vulnerable and fixed code

Vulnerable
function swap(address target, bytes calldata data) external {
    (bool ok,) = target.call(data);   // caller picks target and calldata
    require(ok, "call failed");
}
Fixed
mapping(address => bool) public allowedTarget;  // DEX routers only

function swap(address target, bytes calldata data) external {
    require(allowedTarget[target], "target");
    bytes4 sel = bytes4(data[:4]);
    require(sel != IERC20.transferFrom.selector &&
            sel != IERC20.approve.selector, "selector");
    // Better: pull tokens from msg.sender only, inside this contract,
    // and never hold user approvals in a contract that makes free calls.
    (bool ok,) = target.call(data);
    require(ok, "call failed");
}

Review checklist

  • Never let a caller choose both the target and the calldata of a call from a contract that holds approvals or funds.
  • Split the contracts: the one that holds approvals must not make arbitrary calls. Use an executor with no approvals.
  • Whitelist targets and function selectors.
  • Always use msg.sender as the from of transferFrom, never a parameter.
  • After an exploit, tell users to revoke approvals (revoke.cash). Old routers keep their approvals for years.

How to test for it

  • Write a test where the attacker passes a token address and transferFrom calldata. It must revert.
  • Slither detectors arbitrary-send-erc20 and controlled-delegatecall find many cases.

Real exploits (64)

  • Aug 10, 2021Ethereum$611.0M

    Poly Network: Poly Network lost about $611M across Ethereum, BSC and Polygon because its cross-chain manager could be tricked into calling the privileged EthCrossChainData contract and replacing the keeper public keys.

    Root cause and fix

    Vulnerable code: EthCrossChainManager · verifyHeaderAndExecuteTx

    The EthCrossChainManager's verifyHeaderAndExecuteTx calls executeCrossChainTx, which lets a cross-chain message call any contract with a user-supplied method name. It only checks that the target is a contract. EthCrossChainManager owned EthCrossChainData, so a message targeting that contract passed its onlyOwner check. The attacker ground a "_method" string whose 4-byte sighash matched putCurEpochConPubKeyBytes(bytes) (0x41973cd9), replaced the keeper public keys with their own, and then signed withdrawals from the lock proxy contracts on three chains.

    What would have stopped it: Do not let a cross-chain relay contract own privileged contracts, and block relayed messages from targeting them (for example with a target allowlist or denylist). Do not let the caller choose the method name, because a 4-byte selector is easy to collide.

    rekt.news article ↗Run the exploit (Foundry PoC) ↗

  • Oct 2, 2022Ethereum$21.2MAudited, bug out of scope

    Transit Swap: Transit Swap lost about $21M (over 70% later returned) because its swap contract let callers control a transferFrom call and drain users' approved tokens.

    Root cause and fix

    Vulnerable code: 0xed1afc8c4604958c2f38a3408fa63b32e737c428 · claimTokens

    The unverified Transit Swap contract has a claimTokens function that calls transferFrom on a token address. The token address, from, to and amount are all controlled by the caller. The attacker called it with victims' addresses as "from" and their own address as "to". This drained every token that users had approved to the swap contract, on both Ethereum and BSC.

    What would have stopped it: Never let callers choose the target address or the from/to/amount of a transferFrom call. Pull tokens only from msg.sender, and only for the swap being executed. Restrict the call target to whitelisted tokens and routers. Open-source the code and get it audited.

    rekt.news article ↗Run the exploit (Foundry PoC) ↗

  • Feb 27, 2021Ethereum$14.0MAudited, bug out of scope

    Furucombo: Furucombo lost about $14M when an attacker used its proxy's caller-specified delegatecall to an Aave V2 proxy handler to plant a malicious implementation and drain users' token approvals.

    Root cause and fix

    Vulnerable code: Furucombo proxy (delegatecalling the Aave V2 Lending Pool proxy as a handler) · initialize()

    The Furucombo proxy made delegatecalls to whitelisted handlers with caller-specified calldata. The Aave V2 Lending Pool proxy was a registered handler, and it exposes initialize(), which sets the implementation address in a storage slot. Because it ran by delegatecall, that write landed in the Furucombo proxy's own storage. The attacker first set the implementation slot to their malicious contract. They then called the proxy again with the Aave proxy as handler, which read that address from the Furucombo proxy's storage and delegatecalled the attacker's code. That code used users' approvals to transfer their tokens (stETH, USDC, aTokens and more) to the attacker.

    What would have stopped it: Do not let a delegatecall-based proxy run handlers that can write to its storage. Whitelist only specific functions or selectors on handlers, and check that the proxy's storage is unchanged after each handler call. Audit how every delegatecall target can affect the caller's storage, including proxy handlers such as Aave's.

    rekt.news article ↗

  • Jul 16, 2024Ethereum$9.7M

    LiFi Protocol: LiFi protocol lost about $9.73M when a newly added contract facet's swap function allowed call injection, draining users who had given infinite approvals.

    Root cause and fix

    Vulnerable code: LiFi Diamond (newly added contract facet) · swap

    A new contract facet was added to the LiFi router on July 11. Its swap function did not validate the call target or the call data. The attacker used this "call injection" to make the LiFi contract run arbitrary calls, such as token transferFrom, with the allowance users had granted it. This drained USDT, USDC and DAI from wallets with infinite approvals across several chains. The loot was swapped for 2,857 ETH. A near-identical bug cost LiFi $600K in March 2022.

    What would have stopped it: Only allow external calls to whitelisted targets and function selectors, and never let user-supplied calldata hit token contracts. Audit and test every new facet before adding it to the live router, including a regression test for the 2022 bug class.

    rekt.news article ↗Run the exploit (Foundry PoC) ↗

  • Feb 28, 2024Arbitrum$6.4MAudited

    Seneca Protocol: Seneca Protocol lost about $6.4M on Arbitrum and Ethereum when an attacker used crafted calldata in the Chamber contract to call transferFrom on tokens users had approved.

    Root cause and fix

    Vulnerable code: Chamber · performOperations()

    The Chamber contract let the caller supply calldata for an external call without restricting the target or the function. The attacker built calldata that made the contract call transferFrom on tokens users had approved to Seneca's contracts. This moved those tokens from user wallets to the attacker's address. The contracts also could not be paused, because the pause and unpause functions were internal.

    What would have stopped it: Never let callers pass arbitrary target addresses or calldata to a contract that holds user approvals. Use a whitelist of allowed targets and function selectors, and block calls to token contracts. Make the emergency pause externally callable and access-controlled.

    rekt.news article ↗Run the exploit (Foundry PoC) ↗

  • Jul 15, 2025Base$3.6MFlash loanAudited

    ArcadiaFi: ArcadiaFi on Base lost about $3.6M because the RebalancerSpot contract made an unchecked router.call(data) using attacker-controlled router and swapData.

    Root cause and fix

    Vulnerable code: RebalancerSpot · SwapLogic._swapViaRouter()

    SwapLogic._swapViaRouter() in RebalancerSpot called router.call(data) without validating the router address or the swapData. The attacker registered their own malicious contract as both the router and a whitelisted Arcadia Account. They called RebalancerSpot.rebalance(), which led through AccountV1.flashAction() and executeAction() to _swapViaRouter(). The Rebalancer's trusted context then made arbitrary calls against victim accounts. The attacker used Morpho flash loans to repay the victim's debt first, so the account looked healthy, then withdrew everything and repaid the loans.

    What would have stopped it: Whitelist the allowed routers and validate or restrict swapData. Never let a trusted contract forward arbitrary calldata to a caller-supplied target. Add tests where a registered Account acts as a malicious router.

    rekt.news article ↗

  • Jan 16, 2024Ethereum$3.3MAudited, bug out of scope

    Socket (Bungee bridge): Socket's Bungee bridge lost about $3.3M when a newly added route failed to validate swapExtraData, letting an attacker inject a transferFrom call against users' token approvals.

    Root cause and fix

    Vulnerable code: SocketGateway · performAction()

    A new route was added to the SocketGateway three days before the attack. Its contract did not validate the swapExtraData parameter. An attacker passed calldata containing a transferFrom call and sent 0 WETH, so the balance check still passed. The gateway then executed the call and moved tokens from addresses that had approved SocketGateway to the attacker's contract.

    What would have stopped it: Never execute caller-supplied calldata against user-approved tokens. Whitelist the target and function selector, and validate swapExtraData. Audit every new route before it goes live, and reject zero-amount inputs.

    rekt.news article ↗Run the exploit (Foundry PoC) ↗

  • Mar 8, 2024Ethereum$2.1MAudited, bug out of scope

    Unizen: Unizen's DEX aggregator lost about $2.1M on Ethereum when attackers abused an unverified external call added in a gas-optimization upgrade to drain user token approvals.

    Root cause and fix

    Vulnerable code: DEX Aggregation contract

    A gas-optimization upgrade to Unizen's DEX aggregation contract introduced an unverified external call. The call target and data were not validated, so attackers could make the contract call token contracts and pull funds from users who had approved it. Multiple attackers repeated this in dozens of transactions over a few hours. The article calls it a minor bug with great consequences and says the upgrade was not audited; it gives no function names.

    What would have stopped it: Do not let callers control the target or calldata of external calls in an aggregator. Restrict calls to a whitelist of known routers and block calls to token contracts, especially transferFrom. Audit and test every upgrade, including gas optimizations, before deploying.

    rekt.news article ↗Run the exploit (Foundry PoC) ↗

  • Feb 17, 2023Ethereum$2.0M

    Dexible: Dexible, a DEX aggregator, lost about $2M on Ethereum and Arbitrum because selfSwap let callers pick any router address and calldata, which the attacker used to call transferFrom on user-approved tokens.

    Root cause and fix

    Vulnerable code: Dexible v2 · selfSwap

    Dexible v2's selfSwap function lets users supply their own route, made of a router address and the data to send to it. The router address was not checked on-chain, for example against an allowlist of DEXs. The attacker passed a token contract as the "router" and sent transferFrom calldata. Dexible then pulled tokens from any account that had approved the Dexible contract. The stolen funds were sent to Tornado Cash.

    What would have stopped it: Check the router or target address against an on-chain allowlist of approved DEXs. Do not let user-supplied calldata call arbitrary contracts, especially token contracts, from a contract that holds user approvals. Get a formal audit before release.

    rekt.news article ↗Run the exploit (Foundry PoC) ↗

  • Jul 12, 2024Ethereum$1.8M

    DoughFina: DoughFina lost about $1.8M because ConnectorDeleverageParaswap.flashloanReq() accepted caller-supplied swap data and made arbitrary calls on behalf of a victim account.

    Root cause and fix

    Vulnerable code: ConnectorDeleverageParaswap · flashloanReq()

    flashloanReq() in ConnectorDeleverageParaswap decodes caller-supplied swapData and makes calls to attacker-chosen targets with attacker-chosen calldata. It does not validate the swap data, the targets or the position owner. The attacker first repaid the victim's USDC debt on Aave, then sent a small amount of USDC to the connector. They then called flashloanReq() with swapData that made the victim's account withdraw WETH collateral and call transferFrom to send about 596 WETH to the attacker. The PoC's USDC balance is only a funding trick, not part of the bug.

    What would have stopped it: Never execute caller-supplied targets or calldata. Whitelist the allowed swap targets and function selectors, and decode and validate swap parameters against the debt and collateral arguments. Also require that the caller is the owner of the position being acted on.

    Run the exploit (Foundry PoC) ↗

54 more examples in the full guide.

References

Send a new scam

Describe what happened, or paste a link to the post. Do not include seed phrases, keys or passwords.

Open the post ↗