Reproduced Exploit

Hanji LOB: receiveTokens credits fee-on-transfer tokens for more than it received

receiveTokens calls transferFrom and then adds the requested amount to the trader balance. A token that keeps 10% on the way into the book delivers 9000 of a 10000 deposit. The book still owes the attacker 10000. Withdraw pays 10000. The extra 1000 comes out of the victim's deposit. The victim was…

Jan 2025•Other•defi•2 min read

Chain

Other

Category

defi

Date

Jan 2025

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

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. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 56840-incorrect-handling-of-fee-on-transfer-tokens-mixbytes-none-x. Standalone Foundry PoC and full write-up: 56840-incorrect-handling-of-fee-on-transfer-tokens-mixbytes-none-x_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/defi/fee-manipulation · vuln/logic/state-update

Reproduction: cheatcode-free local synthetic. LOB.receiveTokens credits the nominal amount. Full trace: output.txt. PoC: test/56840-incorrect-handling-of-fee-on-transfer-tokens-mixbytes-none-x_exp.sol.

AuditVault taxonomy: lang/solidity · sector/dex · severity/high · MixBytes XPress / Hanji OnchainCLOB

Key info#

ProtocolXPress / Hanji OnchainCLOB
FindingMixBytes, AuditVault 56840, high
Vulnerable codeLOB.receiveTokens
HarmAttacker withdraws 1000 FEE that the pool never received from them. Victim credit 5000 vs 3500 tokens left
Chainlocal synthetic

TL;DR#

receiveTokens calls transferFrom and then adds the requested amount to the trader balance. A token that keeps 10% on the way into the book delivers 9000 of a 10000 deposit. The book still owes the attacker 10000. Withdraw pays 10000. The extra 1000 comes out of the victim's deposit. The victim was credited 5000, delivered 4500, and the pool has 3500 left, a 1500 shortfall. The fixed function measures the balance delta and reverts with fee-on-transfer when it is not equal to amount.

The vulnerable code#

SOLIDITY
function receiveTokens(uint256 amount) external {
    token.transferFrom(msg.sender, address(this), amount);
    // @> VULN: credits `amount` with no check that the balance rose by `amount`
    balances[msg.sender] += amount;
}

Diagrams#

flowchart TD A["Victim deposits 5000 nominal"] --> B["Book receives 4500 and credits 5000"] B --> C["Attacker deposits 10000 nominal"] C --> D["Book receives 9000 and credits 10000"] D --> E["Attacker withdraws the 10000 credit"] E --> F["1000 extra FEE is kept"] F --> G["Victim is short 1500 against 3500 left"]

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.