Reproduced Exploit

Origin: a malicious ERC20 currency bricks an accepted offer

makeOffer stores any address as the offer currency. paySeller then requires that currency's transfer to succeed. A token that reverts on transfer makes finalize revert, so an accepted offer can never be completed. The seller's balance stays 0.

Nov 2018•Ethereum•dos•3 min read

Loss

The seller cannot finalize. Offer status stays accepted and the seller receives 0

Chain

Ethereum

Category

dos

Date

Nov 2018

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. 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: 17097-remote-code-execution-through-arbitrary-erc20-implementation. Standalone Foundry PoC and full write-up: 17097-remote-code-execution-through-arbitrary-erc20-implementation_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/dos/frozen-funds · vuln/logic/missing-check

Key info#

FieldValue
LossThe seller cannot finalize. Offer status stays accepted and the seller receives 0
Vulnerable contractMarketplace.paySeller
Attacker EOA0x1111111111111111111111111111111111111111
Attack contractExploit
Attack txExploit.run()
Chain / block / dateEthereum model · block 0 · 2018-11
Compilersolc 0.8.27, cancun, via IR
Bug classUntrusted ERC20 used as the offer currency

TL;DR#

makeOffer stores any address as the offer currency. paySeller then requires that currency's transfer to succeed. A token that reverts on transfer makes finalize revert, so an accepted offer can never be completed. The seller's balance stays 0.

Background#

Trail of Bits' November 2018 Origin Protocol review. The report calls the issue remote code execution through an arbitrary ERC20. The concrete effect in paySeller is a grief: Bob offers a token that reverts on every transfer, Alice accepts, and finalization can never succeed. The short-term fix is a revoke path that does not call the currency. The long-term fix is a currency whitelist.

The vulnerable code#

SOLIDITY
require(IERC20(offer.currency).transfer(offer.buyer, offer.refund), "Refund failed"); // @> VULN
require(IERC20(offer.currency).transfer(listing.seller, value), "Transfer failed");

The first transfer reverts, so the seller payout on the next line never runs and the offer status is never set to finalized.

DIFF
- require(offer.currency.transfer(offer.buyer, offer.refund), "Refund failed");
- require(offer.currency.transfer(listing.seller, value), "Transfer failed");
+ // revoke the accepted offer without calling currency, or only allow a whitelisted currency

Root cause#

The currency is caller-chosen and the finalization path treats its return value as a hard requirement. There is no way for the seller or arbitrator to clear an accepted offer without that call.

Preconditions#

  • A listing exists.
  • The buyer passes a contract whose transferFrom returns true and whose transfer reverts.
  • The seller accepts the offer.

Attack walkthrough#

  1. Bob calls makeOffer with the malicious token for 1000 units. transferFrom returns true, so the offer is stored.
  2. Alice accepts. Status becomes accepted.
  3. finalize calls paySeller. The refund transfer reverts.
  4. Status is still accepted. The seller's balance of the token is 0.

Diagrams#

flowchart TD A["Buyer passes a custom ERC20 as the offer currency"] --> B["makeOffer stores that address on the offer"] B --> C["Seller accepts the offer"] C --> D["VULN: paySeller requires currency.transfer"] D --> E["The token reverts"] E --> F["Offer stays accepted and the seller receives 0"] B --> G["Control uses an honest token"] G --> H["Control finalize sets status finalized and pays the seller"]

Impact#

Alice cannot complete the sale and cannot revoke it without another call into the same token. The accepted offer is stuck. An honest currency in the control finalizes and pays the seller 1000 units.

Remediation#

Let the seller or the arbitrator revoke an accepted offer without calling the currency, and restrict makeOffer to a whitelist of token addresses.

How to reproduce#

BASH
cd 17097-remote-code-execution-through-arbitrary-erc20-implementation_exp
forge test -vv

test_exploit_malicious_currency_bricks_finalize asserts finalize fails, status stays 2, and the seller balance is 0. test_control_honest_token_finalizes asserts an honest token reaches status 3 and pays the seller. Captured output is output.txt.

Sources#


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.