# Esim: EVM Bytecode Similarity Detection Based on Stable-Semantic Graph

Crypto.world

> Smart contracts on Ethereum and other EVM chains are heavily copied and forked, but more than 99% of Ethereum contracts are not open source, so similarity must be judged from compiled bytecode alone.

**arXiv**: 2511.12971

**Published**: 2025-11-17

**Authors**: Zhuo Chen, Gaoqiang Ji, Yiling He, Lei Wu, Yajin Zhou

## AI summary

## Overview

**Research area:** Blockchain security, specifically binary code similarity detection for Ethereum Virtual Machine (EVM) bytecode, with an emphasis on DeFi smart contracts.

**Technical level:** Advanced. The paper assumes familiarity with EVM opcodes, control flow graphs, taint analysis, and graph neural networks.

**Scope:** The paper proposes a new bytecode representation called the Stable-Semantic Graph (SSG) and a prototype system, Esim, that uses it to detect similar smart contracts at scale across six EVM-compatible chains.

## What This Paper Is About

Smart contracts on Ethereum and other EVM chains are heavily copied and forked, but more than 99% of Ethereum contracts are not open source, so similarity must be judged from compiled bytecode alone. Existing binary-similarity techniques (instruction-stream and CFG-based) work poorly on EVM bytecode because it is low-level with no symbolic information, because the Solidity compiler splits and reuses small basic blocks in ways that blur function boundaries, and because 113 Solc versions (0.1.3 to 0.8.24) produce very different bytecode from identical source. The paper's goal is a representation that stays stable across these obstacles and a system that uses it to find similar and vulnerable contracts accurately and efficiently.

## Key Contributions

1. **A new bytecode representation.** The Stable-Semantic Graph captures control-flow and data-flow relationships only among "stable instructions" — storage, log, call, and return instructions — which the authors argue carry high semantic relevance and resist the compiler's basic-block reuse strategy.
2. **A working prototype, Esim.** The system has two modules: an SSG Builder (stable control flow graph construction plus stable data flow graph integration via backward taint analysis) and an SSG Embedding Generator that embeds the heterogeneous graph into vectors using a Siamese graph-embedding network.
3. **Extensive evaluation against prior work.** The authors build three datasets, compare against FuzzHash, Genius, Eclone, and Etherscan, and report 100% F1 on control flow and 95.16% F1 on data flow for SSG construction, and 96.3% AUC for similarity detection — at least 12.6% higher than previous research.
4. **A large-scale real-world study.** 2,675,573 distinct contracts collected from six EVM-compatible chains (Ethereum, Optimism, Binance Smart Chain, Polygon POS, Arbitrum One, Avalanche-C-Chain) between January 1st, 2023 and June 13th, 2024, used for a vulnerability-code-search case study in which Esim found 382 similar vulnerable contracts with no false positives versus 255 for Etherscan with a false positive rate above 93.3%.

## Main Findings

- **SSG construction accuracy:** Using Dataset I (Uniswap V2 and USDT source code plus bytecode), Esim reaches a 100% F1-score for control flow identification and a 95.16% F1-score for data flow identification.
- **Similarity detection performance:** Esim attains 96.3% AUC, described as state-of-the-art and at least 12.6% higher than prior research on the same task.
- **Robustness to hyperparameters:** The evaluation reports that hyperparameters shift AUC effectiveness by only 2.8%.
- **Efficiency:** Extracting SSGs from a single contract takes 26 seconds on average, and similarity detection across six EVM-compatible chains takes less than 5 seconds.
- **Vulnerability search beats Etherscan:** For vulnerability code attacked between May 2023 and May 2024, Esim identified 382 similar vulnerable contracts with no false positives; Etherscan identified 255, with a false positive rate exceeding 93.3%.
- **Two motivating insights:** EVM instructions have graded semantic relevance (storage instructions alone can change global blockchain state, while stack instructions only touch the stack), and instructions with high semantic relevance are more stable against basic-block reuse because Solc reduces reuse of blocks containing them to preserve program correctness.
- **Evidence across compiler versions:** The paper shows the CFG of one `approve` function differing substantially between Solc 0.5.16 and Solc 0.8.5, while the relationships between stable instructions remain clear and concise.
- **Dataset composition:** Dataset II contains 21,018 SSGs built with Solc 0.5.17, 0.6.12, 0.7.6, and 0.8.20 (plus 0.8.20 via-ir), under optimization settings none, opt=200, opt=200000, and via-ir, split 70% training / 20% validation / 10% test. Per-version totals are 1,875 / 2,743 / 3,495 / 11,108 / 1,797. (The paper states in one place that the top 10,000 TVL Ethereum projects were selected and in another that the top 1,000 Ethereum DeFi projects were used, of which 907 are open source.)

## Methodology in Plain English

The researchers first identify a small set of EVM instructions they consider "stable" — those that write to storage, emit logs, make external calls, or return/terminate — on the reasoning that these matter most to what a contract actually does and that the compiler is less free to shuffle them around. They then build, for each external function, a graph whose nodes are those stable instructions rather than ordinary basic blocks.

To do this, they locate external function entry points via function selectors, reconstruct function-level CFGs using the Elipmoc framework (an existing decompilation approach), and clone/inline reused basic blocks so each function gets its own copy. Stable instructions in the same block are linked in order; stable instructions in different blocks are linked by walking backward to the nearest preceding block that contains one.

Next they add data flow. They identify the variables each stable instruction consumes or produces (storage slots, log topics, call addresses/values/selectors, return indices), then run backward taint analysis to trace where those values came from — constants, environment, calldata, or earlier computed values — modeling how values propagate through memory. The result is a directed heterogeneous graph with two node types (control flow, data flow) and three edge types (control-to-control, data-to-data, control-to-data).

For comparison, the graph is embedded into a vector. Finite-field attributes such as opcodes are one-hot encoded; non-finite data such as hard-coded strings are converted to binary and cropped or padded to 256 bits. A Siamese architecture runs two identical graph-embedding networks over a pair of SSGs and is trained with a contrastive loss that pulls similar pairs together and pushes dissimilar pairs apart, using +1/-1 ground-truth labels derived from whether two functions came from the same source. After training, the parameters are frozen and the embedding function is used to score similarity. The SSG extractor is built on the open-source Gigahorse tool, and the neural model is implemented in PyTorch.

## Why This Matters

**Impact on research:** The paper argues that instruction-stream and CFG-based representations inherited from C++ and Java work poorly on EVM bytecode, and offers a compiler-aware alternative. Its two insights — graded semantic relevance and stability of high-relevance instructions under block reuse — are reusable ideas for other EVM static-analysis tasks such as decompilation, clone detection, and vulnerability propagation tracking.

**Real-world applications:**

- **Fork auditing in DeFi:** Detecting projects that copied a known protocol, as with the Compound v2 forks that led to the Hundred Finance, Onyx Protocol, and Radiant attacks, which the paper cites as motivation.
- **Vulnerability propagation search:** Given a newly disclosed vulnerable contract, finding other deployed contracts that share its code, which the paper demonstrates at the scale of 2,675,573 contracts.
- **Plagiarism and license checking:** Identifying copied bytecode when source is unavailable, which is the common case since more than 99% of Ethereum contracts are not open source.
- **Blockchain-wide measurement studies:** Tracking code reuse trends across six chains with sub-5-second similarity queries.

**Industry relevance:** Etherscan is the tool practitioners most commonly use for this purpose, and the paper reports that Esim both finds more similar vulnerable contracts (382 vs. 255) and avoids the false positives that make Etherscan's results noisy (above 93.3% false positive rate). The 2024 DeFi market the authors cite carries over $88.8 billion in Total Value Locked, which frames code-reuse risk as a financial concern rather than only an academic one.

## Future Directions

- **Extending beyond Solidity:** The representation is built around Solc's compilation behavior and basic-block reuse strategy; whether it holds for Vyper, Yul-only contracts, or hand-written assembly is not addressed.
- **Closing the SSG construction gap:** Control flow reaches 100% F1 but data flow reaches 95.16%, leaving room for better taint modeling, particularly for location-sensitive "definition variables" whose values depend on on-chain environment.
- **Improving downstream precision further:** The paper reports zero false positives in its vulnerability search case study, but a broader benchmark of vulnerability-class detection (beyond similarity to known vulnerable code) is not reported.
- **Handling newer compiler versions and defenses:** With 113 Solc versions in 8 years, and Dataset II covering only 0.5.17 through 0.8.20, keeping the "stable instruction" assumption valid as compilers and optimizers evolve is an open question.

## Target Audience

Blockchain security researchers and graduate students working on binary similarity, clone detection, or smart contract analysis; security engineers at audit firms and exchanges who need to trace forked or vulnerable bytecode; and tool builders interested in applying heterogeneous graph neural networks to program representations. Readers without background in EVM internals or graph embedding will find the design sections dense.

## Authors’ abstract

Decentralized finance (DeFi) is experiencing rapid expansion. However, prevalent code reuse and limited open-source contributions have introduced significant challenges to the blockchain ecosystem, including plagiarism and the propagation of vulnerable code. Consequently, an effective and accurate similarity detection method for EVM bytecode is urgently needed to identify similar contracts. Traditional binary similarity detection methods are typically based on instruction…

[The full abstract on arXiv](https://arxiv.org/abs/2511.12971)

[Read the original paper](https://arxiv.org/abs/2511.12971)

---

Canonical: https://crypto.world/paper/esim-evm-bytecode-similarity-detection-based-on-stable-semantic-graph-2511.12971
