Skip to content

LI.FI Security - How the Diamond Was Exploited and What the Audits Found

LI.FI routes every swap and bridge transfer through one contract per chain, the LiFiDiamond, and users give that contract their token approvals. The companion article, How LI.FI Works - Inside the Bridge Aggregator’s Diamond Contract, explains how the diamond executes a transfer and why its allow-list of contract and selector pairs is the security boundary. This article looks at what happened when that boundary failed, and at what LI.FI’s auditors keep finding.

It follows the March 2022 and July 2024 exploits step by step, compares them with the current code, then groups the findings of LI.FI’s audit reports into the bug classes that recur from facet to facet. The annex turns both into a checklist for any contract that executes caller-supplied calls while holding user allowances.

This article has been made with the help of Claude Code and several custom skills

What you need to know first

  • ERC-20 approvals. A holder lets a spender move up to an allowance with transferFrom; an unlimited approval stays valid until it is revoked.
  • Proxies and delegatecall. A proxy runs another contract’s code in its own storage and with its own identity, so calls it makes carry its own address.
  • The LI.FI diamond. An EIP-2535 proxy that routes each function selector to a facet; facets run the swap phase through LibSwap.swap and check each step against the allow-list. See the architecture section of the companion article.
  • Swap steps. A SwapData step names a target, a spender to approve, an input asset and amount, and the calldata to send.
  • Audit severity. Reports rate findings Critical, High, Medium or Low; the ratings in this article are the reports’ own.

Two exploits from one root cause

Both LI.FI incidents spent allowances that users had given to the diamond. Neither broke a bridge. The timeline in the annex dates them, with the ownership and facet changes around them.

March 2022: unvalidated SwapData in the CBridge swap path

The first diamond, 0x5A9Fd7c39a6C488E715437D7b1f3C823d5596eD1, exposed swapAndStartBridgeTokensViaCBridge(LiFiData, SwapData[], CBridgeData). For each swap step it pulled the input from the caller, approved approveTo and ran callTo.call(callData), with no list of permitted targets. The DeFiHackLabs reconstruction, which does not bundle the facet’s source and rebuilds its logic from the trace, replays one attacker call at block 14,420,686 with 38 swap steps:

  • Step 0 was a real swap. 50 USDT (50,000,000 base units) went through the 0x Exchange Proxy and returned 49,863,998 base units of USDC, which satisfied the facet’s check on the bridged asset. That check only required the swaps to leave at least the 40 USDC declared in the bridge data.
  • Steps 1 to 37 were not swaps. Each pointed the call at a token contract (USDT, USDC, DAI, LINK, AAVE and others), declared the native sentinel address(0) as input with an amount of 0, and carried transferFrom(victim, attacker, amount) as calldata. The facet pulled and approved nothing for these steps and executed the call; since the diamond was the approved spender, each transferFrom succeeded.
  • The bridge step was real. The facet sent the 49.86 USDC through cBridge to Arbitrum, to the attacker’s address.

LI.FI put the whole incident at about $600K, taken from 29 wallets. The check on the bridged asset saw nothing wrong because the 37 drain steps did not touch it.

July 2024: a public helper that skipped SwapperV2

The second incident hit the current diamond, 0x1231DEB6…4EaE, through a facet added shortly before: GasZipFacet at 0xf28A352377663cA134bd27B582b1a9A4dad7e534. Its bridge entry points went through the swap phase and its allow-list. A helper meant to be used as a SwapData step did not. The verified source of the deployed facet reads:

function depositToGasZipERC20(
    LibSwap.SwapData calldata _swapData,
    uint256 _destinationChains,
    address _recipient
) public {
    // get the current native balance
    uint256 currentNativeBalance = address(this).balance;

    // execute the swapData that swaps the ERC20 token into native
    LibSwap.swap(0, _swapData);

    // calculate the swap output amount using the initial native balance
    uint256 swapOutputAmount = address(this).balance -
        currentNativeBalance;

    // call the gas zip router and deposit tokens
    gasZipRouter.deposit{ value: swapOutputAmount }(
        _destinationChains,
        _recipient
    );
}

The function is public, has no modifier, and passes caller data straight to LibSwap.swap.

Because the facet was registered in the diamond, the fallback routed its selector like any other: anyone could call it through the diamond, and the call to USDT came from the diamond, the address users had approved.

In that version the swap function checked three things only: that the target had code, that the amount was not zero, and that the diamond held at least that amount of the input asset, reverting with InsufficientBalance otherwise. The attacker pointed the call at USDT with transferFrom(victim, attacker, balance) as calldata. To pass the bookkeeping checks, it declared as input a fake token contract that reports a balance of 1 and accepts approvals, with an amount of 1.

The reconstruction forks the chain at block 20,318,962 and replays the attack transaction 0xd82fe84e…3873, mined in block 20,318,963. In it, one victim with an unlimited USDT allowance to the diamond lost 2,276,295.880553 USDT. LI.FI’s incident report puts the whole incident at about $11.6M, taken from 153 wallets on Ethereum and Arbitrum.

What changed since

  March 2022 July 2024 At a1a449b (2026-11-23)
Diamond 0x5A9F…6eD1 0x1231…4EaE 0x1231…4EaE
Entry point swapAndStartBridgeTokensViaCBridge GasZipFacet.depositToGasZipERC20 none known
Missing check no allow-list at all allow-list existed but was bypassed none in the current source; older deployed facets may use the separate check
Drain call token.transferFrom(victim, attacker, x) as a swap step the same, through one SwapData needs a whitelisted (token, 0x23b872dd) pair, a selector collision on a facet using the old separate check, or a new bypass
Attacker trick zero-amount steps with native sentinel fake token reporting a balance of 1 none known

The helper no longer exists in GasZipFacet. It now lives in a separate GasZipPeriphery contract, which asks the diamond whether the contract-selector pair is whitelisted before calling. Being a separate contract, its calls do not carry the allowances users gave to the diamond (derived). Since before 2024, LibSwap.swap reverts on a zero amount, which would have rejected the 2022 drain steps as crafted (derived), but the 2024 attack shows that such bookkeeping checks are cheap to satisfy and are not a substitute for the allow-list.

Implementation: src/Periphery/GasZipPeriphery.sol, depositToGasZipERC20() with the isContractSelectorWhitelisted() check (lines 54-82).

The structural point has not changed: LibSwap.swap is still an unrestricted call primitive, and the allow-list is a property of its callers. The first check worth running on any new facet is therefore a search for every path to LibSwap.swap or a raw .call that does not pass a pair check (derived).

Recurring audit findings

The repository indexes 114 audit reports in audit/auditLog.json, from February 2024 to November 2026. Sujith Somraaj wrote 105 of them, Burra Security 6 and Cantina 3. Most are reviews of one version of one facet.

Two of the PDFs are corrupted upstream, which leaves 112 readable LI.FI reports. With Catapultar’s 7, that makes 119 reports, whose findings total 0 Critical, 6 High, 30 Medium and 122 Low as the reports rate them.

Source: audit/auditLog.json and the PDFs in audit/reports/. The three Cantina reports are a pre-competition review, a competition, and the review of the Sushiswap fork behind LiFiDEXAggregator, which is logged without an auditor handle. The Low count takes the 2025 Cantina competition at the 15 Lows of its summary, of which it details only 7.

The six Highs:

Report Finding Class
Permit2Proxy v1.0.0 (2024-11) Front-running callDiamondWithEIP2612Signature: the permit did not bind target and calldata Signature binding
ChainflipFacet v1.0.0 (2025-03) Improper receiver address encoding for Bitcoin Non-EVM receiver encoding
Patcher v1.0.0 (2025-07) Front-running could lead to loss of caller funds (acknowledged, documented only) Arbitrary-call periphery
AcrossV4SwapFacet v1.0.0 (2026-04) Incorrect LayerZero endpoint IDs for XDC and Plume Hard-coded chain ID tables
Catapultar (2026-04) CATValidator can validate outcomes with unrelated balance increases Balance-difference outcome check
Catapultar (2026-04) CatapultarFactory allows salt-prefix collisions Address squatting

Beyond the Highs, the same classes recur from facet to facet:

  • The receiver actually paid is not bridgeData.receiver. validateBridgeData only checks that the receiver is non-zero; the bridge pays a protocol-specific field. Findings in AcrossV3, DeBridgeDln, Relay and Mayan are all variants; in the Mayan case the receiver was decoded from the wrong field of opaque protocol data.
  • Non-EVM receivers. Wrong width or padding of a bytes32 receiver (Chainflip, GasZip, AcrossV4), the NON_EVM_ADDRESS marker accepted for an EVM destination so that the declared receiver differs from the real one (PolymerCCTP, Eco), EVM-style receivers accepted for Solana, and missing or spoofable BridgeToNonEVMChain events.
  • Refund and cancel rights taken from msg.sender. When a facet is reached through Permit2Proxy, a relayer or an integrator contract, msg.sender is that contract. Refunds then land in a shared contract and cancel rights belong to an address that cannot use them (LayerSwap, PolymerCCTP, Symbiosis, Eco, DeBridge, Garden). The 2026 fixes added an explicit, signed refundRecipient.
  • Opaque calldata against runtime amounts. The facet forwards backend-built protocol data while the amount changes after the source swap: stale minimum outputs (Mayan), linear rescaling on positive slippage that makes deposits unfillable (AcrossV4Swap), value-bearing fields hidden in protocol data and not validated.
  • Last swap output versus sendingAssetId, and whole-balance accounting. If the last swap’s output may differ from the bridged asset, a caller can bridge any stray token the diamond holds: the swap phase measures the balance increase of the last step’s output, and the facet then bridges that amount of sendingAssetId, taken from whatever balance of it the diamond already had. These findings are usually acknowledged with “the diamond holds no funds”, a premise that fails as soon as any path leaves funds behind.
  • Native value. msg.value reused across loop iterations, bridge fees paid out of the diamond’s own native balance, overpaid fees not refunded.
  • Per-chain constants. Hard-coded chain ID to provider ID tables (the LayerZero High), two TRON chain IDs defeating a same-chain check, and EIP-7702 delegated accounts that LibAsset.isContract treats as EOAs because it requires more than 23 bytes of code.

One item is still open as a lead rather than a finding.

At this commit, 20 facets send excess native value back to msg.sender, and their swap variants also send it the swap leftovers. AcrossFacetV4, StargateFacetV2, DeBridgeDln, Chainflip, Garden, Squid, ThorSwap and Unit are among them. When the call comes through Permit2Proxy, that sender is the proxy. The proxy’s receive() function is commented “required to be able to receive native token refunds from the diamond”, but no forwarding of such refunds to the user was found in its source; only the proxy owner can recover them, through withdrawToken. The audits raised this pattern, but whether a leftover can arise on those paths through the proxy has not been verified.

Implementation: each facet’s refundExcessNative(payable(msg.sender)) modifier and the leftover receiver it passes to _depositAndSwap().

Conclusion

Both exploits spent allowances that users had given to the diamond, and both did it by making the diamond call transferFrom on a token. Neither broke a bridge.

  • 2022. A swap path had no allow-list at all, so 37 crafted steps called token contracts directly. LI.FI put the loss at about $600K from 29 wallets.
  • 2024. The allow-list existed, but a public helper in a newly added facet passed caller data straight to LibSwap.swap. LI.FI put the loss at about $11.6M from 153 wallets.
  • Today. The helper moved to a separate periphery contract that checks the pair before calling. LibSwap.swap is still an unrestricted call primitive, so every new path to it needs the pair check.
  • Audits. The recurring classes are the receiver the bridge actually pays, non-EVM receiver encoding, refunds to msg.sender behind proxies, and amounts inside opaque protocol calldata. One lead on refunds through Permit2Proxy is still unverified.

Mindmap of LI.FI security covering the 2022 and 2024 approval drains, what changed in the code since, the six High audit findings, the recurring bug classes and the implementation checklist

Annex

Key Terms

Term Definition
Approval drain An attack that makes an approved spender call transferFrom on a victim’s token, moving the victim’s allowance to the attacker.
Allowance The amount an ERC-20 holder lets a spender move with transferFrom; an unlimited allowance stays usable after the transaction it was given for.
delegatecall A call that runs another contract’s code in the caller’s storage and balance, keeping the caller’s identity towards third parties.
Facet A logic contract registered in the diamond; LI.FI has one per bridge integration plus admin facets.
SwapData One step of the swap phase: a target, a spender, input and output assets, an amount, raw calldata and a deposit flag.
Contract-selector allow-list The LibAllowList map of permitted (contract, selector) pairs that every swap step must match before the diamond calls it.
NON_EVM_ADDRESS The marker 0x11f1…11F1 put in bridgeData.receiver when the real receiver is on a non-EVM chain and travels in facet data.
Receiver A LI.FI contract on the destination chain that a bridge pays when the route has a destination call; it hands the funds to the Executor.
Permit2 witness Extra typed data bound to a Permit2 signature; Permit2Proxy uses it to bind the diamond address and calldata hash.

Security Implementation Checklist

An approval-holding aggregator diamond is a pattern several teams build. The rows below derive from LI.FI’s code, exploits and audit findings and apply to any contract that executes caller-supplied calls while holding user allowances.

Arbitrary calls and the allow-list

Both exploits came from an external call that the allow-list did not cover. These rows close every path to such a call.

Check Security requirement Failure mode if violated
☐ Every code path that performs a caller-chosen external call checks a (contract, selector) pair allow-list first, including helpers meant to be used as steps. A single unchecked path turns the contract into a transferFrom proxy for every user’s allowance (2024 GasZip).
☐ The allow-list is keyed by pairs, not by contracts and selectors separately. A whitelisted selector colliding with transferFrom on a whitelisted token reopens the drain through the allow-list.
☐ No token contract is whitelisted with transfer, transferFrom, approve or permit selectors. The contract can be told to move or approve any user’s tokens.
☐ A spender that differs from the call target is separately whitelisted as approve-only. The contract max-approves an attacker-chosen address.
☐ The contract cannot whitelist itself or call itself through a step. A step re-enters privileged entry points with the contract’s own identity.
☐ Contracts that make unrestricted calls by design (executors, patchers) never receive a standing user approval. Anyone can spend the allowance through the unrestricted call (Patcher High).

Receivers and destinations

Funds can leave the source chain correctly and still reach the wrong address. These rows check that the address paid, on either chain, is the one the user signed for.

Check Security requirement Failure mode if violated
☐ The address the bridge will pay equals the receiver the user signed for, or a validated non-EVM field when the marker is used. Funds go to an address different from the one in the event and the quote.
☐ The non-EVM marker is accepted only for non-EVM destinations, and each destination has a defined receiver encoding (width, padding, wallet or token account). Funds are sent to an unusable or attacker-controlled address on the destination.
☐ Destination-call receivers accept calls only from their bridge and reset any approval they give after use. A third party triggers swaps with bridged funds, or a stale approval remains.
☐ The destination-call flag matches the presence of a payload. A payload is executed or dropped against the user’s intent.

Refunds, signatures and amounts

Value can also leak without an arbitrary call, through refunds, reused signatures or stale amounts. These rows cover those paths.

Check Security requirement Failure mode if violated
☐ Refunds, leftovers and cancel rights go to a user-signed recipient, not to msg.sender, whenever the entry can be reached through a proxy or relayer. Refunds accumulate in a shared proxy where the next caller can take them.
☐ A permit or signed entry binds the target, calldata hash, amount, chain, deadline and nonce. A front-runner reuses the signature with its own calldata (Permit2Proxy High).
☐ Amounts inside opaque protocol calldata are recomputed or checked after a source swap changes the input amount. Stale minimum outputs or unfillable deposits after slippage.
☐ The last swap’s output asset equals the asset that is bridged, and balances are measured as deltas within the call. A caller bridges or sweeps stray funds the contract happens to hold.
☐ Native fees are paid from msg.value, and excess value is refunded. Fees are drawn from other users’ native balance held by the contract.
☐ Hard-coded chain ID to provider ID tables are checked against each provider’s official list. Funds are routed to a wrong or non-existent destination (LayerZero eid High).

Governance

Whoever can change the facets can change everything else. These rows limit who can do it and how fast.

Check Security requirement Failure mode if violated
☐ Code changes go through a multisig and a timelock, and the pause path cannot remove the upgrade or pause facets. A single key replaces logic, or a pause becomes irreversible.
☐ Any delay bypass is limited to actions that cannot add code. The bypass becomes an instant upgrade path.
☐ A storage change in an inlined library is checked against every deployed facet that embeds the old version. Older facets read stale or cleared storage.

Frequently Asked Questions

Q: The 2024 attacker had to get past LibSwap.swap’s bookkeeping. How, and why did the allow-list not stop it?

In the 2024 version, LibSwap.swap required a non-zero amount, approved the spender for the input asset, and reverted with InsufficientBalance if the diamond held less than that amount of the input asset. That balance check is why the fake token had to report a balance. The attacker declared as input a fake token that reported a balance of 1 and accepted approvals, with an amount of 1, while the call went to USDT with transferFrom(victim, attacker, balance) as calldata.

The allow-list did not run because depositToGasZipERC20 called LibSwap.swap directly instead of going through SwapperV2._executeSwaps, where the check lives. The fix moved that helper into a periphery contract with its own pair check.

Q: Why did the 2022 check on the bridged asset not notice the drain?

Because it only checked that the swaps left at least the declared 40 USDC of the bridged asset. Step 0 was a real swap that produced 49.86 USDC, and the 37 drain steps never touched USDC, so the check passed.

Q: Would the 2022 drain steps still pass LibSwap.swap today?

Not as they were crafted: since before 2024, LibSwap.swap reverts on a zero amount, and the 2022 steps declared an amount of 0 (derived). The 2024 attack shows how little that helps: a fake token reporting a balance of 1 satisfied the bookkeeping checks. Only the pair check on the allow-list stops such a call.

Q: Why do audits keep finding receiver bugs?

validateBridgeData only checks that bridgeData.receiver is non-zero. The bridge pays a protocol-specific field, so each facet must check that this field equals the receiver the user signed for, and each new facet can get it wrong. Findings in AcrossV3, DeBridgeDln, Relay and Mayan are variants of this.

Q: Why does “the diamond holds no funds” not settle the whole-balance findings?

The premise fails as soon as any path leaves funds behind: leftovers, refunds that land in the diamond or a shared proxy, or tokens sent by mistake. A facet that bridges an amount of sendingAssetId taken from the diamond’s balance then lets a caller bridge those stray funds.

Q: Where does the GasZip helper live now, and why is that safer?

In a separate GasZipPeriphery contract, which asks the diamond whether the contract and selector pair is whitelisted before calling. Being a separate contract, its calls do not carry the allowances users gave to the diamond (derived).

Gaps

These points are not settled by the sources read for this article.

Gap Why it matters What to read or verify
Both exploit descriptions come from DeFiHackLabs-style reconstructions; the 2022 facet source is not bundled with the reconstruction and its logic was rebuilt from the trace, and that write-up labels the 50 USDT input as “50M”. Amount and code details of the 2022 incident are secondary. The trace in DeFiHackLabs and LI.FI’s own 2022 post-mortem on Medium (blog.li.fi/20th-march-the-exploit-e9e1c5c03eb9, linked from the DeFiHackLabs index), which refused automated access; only LI.FI’s summary post on X was read.
Whether users were compensated is not settled. LI.FI’s July 2024 report says only that it was evaluating options to compensate affected users, and its March 2022 post on X says users did not have to do anything. The Loss sharing row says “none found” for the contracts only. A later LI.FI announcement on compensation, and the full 2022 post-mortem.
Audit reports before February 2024 (if any) are not in the repository’s audit folder. The history before the 2024 incident is thin. LI.FI’s security page and documentation.
The incident totals now follow LI.FI (about $600K from 29 wallets in 2022, about $11.6M from 153 wallets in 2024). The local 2022 reconstruction gives about $5.7M and the DeFiHackLabs index $570K; the 2024 reconstruction gives about $10M. Neither total was summed from the chain here. Third-party figures for the same incident differ by a factor of ten. The drain transactions of each incident summed on chain, starting from the 2022 attack transaction.
The 20 facets that refund to msg.sender were not traced through Permit2Proxy, and no test was run to see whether a leftover or native refund can arise there. The Risks table lists it as a lead, not a vulnerability. callDiamondWith* in Permit2Proxy.sol followed into each facet, tested in an isolated Foundry fork.

References

Analyzed source

Audit reports

Exploits

You might also enjoy