Reproduced Exploit

Chiliz bridge: a 5 ether ERC20 deposit locks the 4 ether overpayment

Bridge.deposit requires msg.value >= fee and then sends msg.value - fee to the resource handler. The ERC20 handler's deposit never refunds that native value. A depositor who sends 5 ether against a 1 ether fee locks 4 ether in the handler. The fixed bridge returns the 4 ether to the caller and keep…

Undated•Ethereum•untagged•3 min read

Loss

4 ether of native value stuck in the ERC20 handler

Chain

Ethereum

Category

untagged

Date

Undated

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

The attack replays in your browser. Step through it by Solidity line or by opcode.

The attack is replayed in an in-browser EVM preloaded with the exact dumped fork state. The execution tree shows every call; step by Solidity line or by opcode across all depths — source, Stack, Memory, Storage, Balances (native / ERC-20 / NFT), Transient storage and Return value stay in sync. Click a tree node, opcode, or source line to jump. Query opens a search over the trace: previous and next writes, balance changes and calls, breakpoints, and a diff of everything that changed between two steps. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 50982-lack-of-refund-mechanism-for-overpayment-halborn-chiliz-brid. Standalone Foundry PoC and full write-up: 50982-lack-of-refund-mechanism-for-overpayment-halborn-chiliz-brid_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/bridge · vuln/logic

Reproduction: a self-contained Foundry PoC that compiles and runs offline with only forge-std - no fork and no RPC. PoC: test/50982-lack-of-refund-mechanism-for-overpayment-halborn-chiliz-brid_exp.sol.

Key info#

FieldValue
Loss4 ether of native value stuck in the ERC20 handler
ProtocolChiliz Bridge
Bug classNo refund of native overpayment on ERC20 deposit
SourceAuditVault finding
ReportHalborn, Chiliz Bridge Updates
Chain / block / dateEthereum model · block 0 · 1970-01
Compilersolc 0.8.27, cancun, via IR

TL;DR#

Bridge.deposit requires msg.value >= fee and then sends msg.value - fee to the resource handler. The ERC20 handler's deposit never refunds that native value. A depositor who sends 5 ether against a 1 ether fee locks 4 ether in the handler. The fixed bridge returns the 4 ether to the caller and keeps only the fee.

The vulnerable code#

SOLIDITY
require(msg.value >= FEE, "invalid value");
uint256 valueToSend = msg.value - FEE;
if (valueToSend > 0) {
    // @> VULN: excess native value is forwarded and never refunded
    payable(address(handler)).transfer(valueToSend);
}
handler.deposit(resourceID, destinationChainID, 1, msg.sender, data);

Root cause#

The fee is msg.value minus a remainder, and the remainder is pushed to the handler with transfer. For an ERC20 resource the handler does not spend or return that ETH. Nothing in deposit sends the excess back to msg.sender. The user who overpays cannot recover it.

Preconditions#

  • deposit is permissionless.
  • The resource id maps to an ERC20 handler.
  • Fee is 1 ether. The caller sends 5 ether. The note's own test uses value 500 against the same function.

Attack walkthrough#

  1. Call deposit with 5 ether.
  2. Pass the fee check because 5 >= 1.
  3. Compute the excess as 4 ether.
  4. Transfer the 4 ether to the ERC20 handler.
  5. Handler.deposit returns without a refund.
  6. Handler balance is 4 ether. Bridge balance is the 1 ether fee.

Diagrams#

flowchart TD A["User calls deposit with 5 ether"] --> B["Fee is 1 ether"] B --> C["VULN: transfer 4 ether to the ERC20 handler"] C --> D["Handler.deposit does not refund"] D --> E["4 ether stays stuck"]

Impact#

The depositor loses 4 ether. It sits on the ERC20 handler with no withdraw path in the quoted code. The control refunds the 4 ether and the handler balance stays 0; the only amount kept is the 1 ether fee.

Remediation#

Refund msg.value - fee to msg.sender (the fix the Chiliz team applied in the handler), or do not forward native value to an ERC20 handler.

How to reproduce#

BASH
cd 50982-lack-of-refund-mechanism-for-overpayment-halborn-chiliz-brid_exp
forge test -vv

run() is the harm path. The control test uses the corrected comparison or guard and does not produce the loss number.


Sources & further analysis#

Reproductions & code

Alerts & third-party analyses

  • Web3Sec X hacked database: search.
  • Rekt leaderboard: search.
  • Solodit incident search: search.

These dashboards index community alerts tweets, post-mortems, and independent write-ups. Reach them through the protocol name above to cross-check this reproduction against other analyses.