---
title: "Arbitrary external calls"
url: https://dontgetrekt.today/dev/arbitrary-call
section: "What does it trust?"
owasp: SC06:2026
---

# 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.

## 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 code

```solidity
function swap(address target, bytes calldata data) external {
    (bool ok,) = target.call(data);   // caller picks target and calldata
    require(ok, "call failed");
}
```

## Fixed code

```solidity
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)

- 2021-08-10 Poly Network ($611.0M): 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. [rekt.news](https://rekt.news/polynetwork-rekt) [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2021-08/PolyNetwork_exp.sol)
- 2022-10-02 Transit Swap ($21.2M): Transit Swap lost about $21M (over 70% later returned) because its swap contract let callers control a transferFrom call and drain users' approved tokens. [rekt.news](https://rekt.news/transit-swap-rekt) [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2022-10/TransitSwap_exp.sol)
- 2021-02-27 Furucombo ($14.0M): 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. [rekt.news](https://rekt.news/furucombo-rekt)
- 2024-07-16 LiFi Protocol ($9.7M): 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. [rekt.news](https://rekt.news/lifi-jumper-rekt) [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2024-07/Lifiprotocol_exp.sol)
- 2024-02-28 Seneca Protocol ($6.4M): 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. [rekt.news](https://rekt.news/seneca-protocol-rekt) [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2024-02/Seneca_exp.sol)
- 2025-07-15 ArcadiaFi ($3.6M): ArcadiaFi on Base lost about $3.6M because the RebalancerSpot contract made an unchecked router.call(data) using attacker-controlled router and swapData. [rekt.news](https://rekt.news/arcadiafi-rekt)
- 2024-01-16 Socket (Bungee bridge) ($3.3M): 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. [rekt.news](https://rekt.news/socket-rekt) [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2024-01/SocketGateway_exp.sol)
- 2024-03-08 Unizen ($2.1M): 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. [rekt.news](https://rekt.news/unizen-rekt) [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2024-03/UnizenIO_exp.sol)
- 2023-02-17 Dexible ($2.0M): 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. [rekt.news](https://rekt.news/dexible-rekt) [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2023-02/Dexible_exp.sol)
- 2024-07-12 DoughFina ($1.8M): DoughFina lost about $1.8M because ConnectorDeleverageParaswap.flashloanReq() accepted caller-supplied swap data and made arbitrary calls on behalf of a victim account. [PoC](https://github.com/SunWeb3Sec/DeFiHackLabs/blob/main/src/test/2024-07/DoughFina_exp.sol)

## References

- [OWASP SC06:2026](https://scs.owasp.org/sctop10/SC06-UncheckedExternalCalls/)
- [SWC-124: Write to arbitrary storage location](https://swcregistry.io/docs/SWC-124/)
- [Revoke.cash: why approvals are a risk](https://revoke.cash/learn/approvals/what-are-token-approvals)
