TL;DR
This paper introduces two novel methods for automatically detecting token systems on the Ethereum blockchain by analyzing their bytecode. By combining behavioral analysis with signature matching, they achieve near-perfect detection, offering valuable tools for regulators and researchers to understand the rapidly growing token ecosystem.
What Problem Does This Paper Address?
The Ethereum blockchain has become a fertile ground for creating "tokens" – essentially digital assets that can be traded and managed by smart contracts. The sheer volume and value of these tokens (billions of dollars) have raised concerns for regulators regarding security laws, consumer protection, and financial stability. To address these concerns, there's a pressing need for reliable methods to automatically identify, classify, and monitor these token systems. Existing methods often rely on simple signature matching, which can be easily circumvented, or are too complex for widespread application. This paper aims to bridge this gap by developing and comparing two distinct, yet complementary, approaches to detect token systems directly from their underlying code.
Methods
The authors propose and compare two primary methods for detecting token systems:
- Behavior-based Detection: This approach uses symbolic execution and taint analysis to identify smart contracts that exhibit the characteristic behavior of a token system. Specifically, it looks for contracts that:
- Store user balances as integers in permanent storage.
- Provide a function to transfer tokens between users.
-
Crucially, maintain the total amount of tokens in circulation during transfers. This method is designed to be robust against minor deviations from standard interfaces.
-
Signature-based Detection: This method acts as a benchmark and relies on identifying smart contracts that implement the widely adopted ERC-20 token standard. It works by analyzing the contract's bytecode to detect the presence of specific function selectors (unique identifiers for functions) defined by the ERC-20 standard. A contract is classified as a token system if it implements at least five of the six required ERC-20 functions.
Datasets
- Ethereum Main Chain Data: The authors extracted all unique runtime bytecode instances from the Ethereum main chain from its inception until May 30, 2018. This resulted in over 111,000 unique bytecode instances.
- Curated Ground Truth Dataset (GTD): To validate their methods, the authors created a ground truth dataset by downloading the top 612 ERC-20 tokens from Etherscan. After filtering out tokens created after May 2018, they obtained a dataset of 595 ground truth token systems, from which they extracted 578 bytecode instances.
Key Insights and Ideas
- Behavioral patterns are a powerful, albeit imperfect, indicator: The behavior-based method, while not achieving perfect recall, can identify "hidden" or non-standard token systems that intentionally deviate from established interfaces. This suggests that looking beyond just signatures is crucial for comprehensive detection.
- ERC-20 is dominant but not universal: The signature-based method, leveraging the ERC-20 standard, achieves very high recall, highlighting its widespread adoption. However, the existence of token systems missed by this method underscores the need for alternative detection strategies.
- Code reuse is prevalent, but innovation is concentrated: The analysis of bytecode reuse reveals that a significant portion of token systems are based on a few common templates, suggesting that much of the innovation in the ICO space might be concentrated around these templates rather than entirely novel implementations.
- Symbolic execution, while powerful, has practical limitations: The paper highlights challenges like path explosion and the NP-hardness of symbolic execution, which can lead to missed detections or incomplete analysis, especially for more complex contracts.
Key Results
- Combined approach yields 100% recall: When both the signature-based and behavior-based methods are used in conjunction, they achieve a perfect 100% recall rate on the curated ground truth dataset.
- Signature-based method: High recall, potential for false positives: The signature-based method alone achieved a recall of 99.13% on the GTD. However, it can produce false positives with "factory contracts" that deploy other token systems.
- Behavior-based method: Good recall, identifies non-standard tokens: The behavior-based method achieved a recall of 88.75% on the GTD. It successfully identified five contracts missed by the signature-based method, which did not fully adhere to the ERC-20 standard.
- Significant number of token systems missed by individual methods: The paper found that the signature-based method missed 11.25% of tokens (65 contracts), while the behavior-based method missed 0.87% (5 contracts) on the GTD.
- Behavioral analysis is more robust to obfuscation: The behavior-based method is less susceptible to simple obfuscation techniques like renaming functions compared to signature-based methods.
Limitations and Future Work
- Limitations of Symbolic Execution: The behavior-based method inherits limitations from symbolic execution, including path explosion, unbounded loops, and the NP-hardness of the SMT problem. This can lead to missed detections or incomplete analysis, especially for complex contracts.
- Locality of Analysis: Both methods analyze contracts locally, meaning they are blind to behaviors or signatures located outside the smart contract under analysis. This can lead to missed detections if contracts delegate their logic to other contracts.
- False Positives for Signature-based Method: Factory contracts and dead code can lead to false positives in the signature-based method.
- Future Work:
- Quantifying the false positive risk of the signature-based method.
- Improving the behavior-based method to handle more sophisticated obfuscation.
- Using concolic execution to overcome the locality limitation.
- Developing a domain-specific language for specifying behavioral patterns to generalize the approach to detect other types of smart contracts (e.g., non-fungible tokens, decentralized exchanges).
- Analyzing transaction data to map the Ethereum ecosystem and understand the relationships between detected services.
Summary updated