CoinWatch: A Clone-Based Approach For Detecting Vulnerabilities in Cryptocurrencies

Qingze Hum, Wei Jin Tan, Shi Ying Tey, Latasha Lenus, Ivan Homoliak, Yun Lin, Jun Sun

Abstract

The cryptocurrency ecosystem relies heavily on open-source collaboration, often through "forking" established codebases like Bitcoin. However, this practice introduces a significant security risk: inherited vulnerabilities. This paper introduces CoinWatch, a tool designed to automatically detect these propagated bugs across thousands of projects using code evolution analysis and clone detection. By identifying the specific "vulnerability window" in parent projects, CoinWatch uncovered hundreds of unpatched flaws in the wild, demonstrating a critical "patching lag" in the decentralized finance space.

Introduction: The "Inherited" Bug Problem

In the rapidly evolving world of cryptocurrencies, developers frequently launch new projects by copying the source code of successful predecessors like Bitcoin or Zcash. While this accelerates development, it creates a dangerous security vacuum. When a vulnerability is discovered and patched in a "parent" project, there is no automated mechanism to propagate that fix to its thousands of "child" forks. Many smaller projects lack the resources to monitor upstream security updates, leaving them vulnerable to known exploits long after a patch is available. A notable example is the "PigeonCoin" attack, where a failure to port a Bitcoin fix resulted in a $15,000 loss.

The CoinWatch Pipeline

To address this systemic risk, the authors developed CoinWatch (CW), a systematic pipeline for detecting propagated vulnerabilities. The process consists of four primary stages:

  1. CVE Parsing & Linking: CW identifies known flaws by scraping the CVE (Common Vulnerabilities and Exposures) database for parent projects.
  2. Code Evolution Analysis: Using an enhanced SZZ algorithm, the tool analyzes Git histories to find the exact commits that introduced and fixed a bug, defining a "vulnerability window."
  3. Initial Filtering: Projects are filtered based on their fork dates; those forked outside the vulnerability window are excluded.
  4. Clone Detection: For projects within the window, CW utilizes Simian to perform "Type I" clone detection, searching for exact matches of the buggy code snippet.
The CoinWatch system pipeline, illustrating the four main stages from CVE parsing to final clone detection.

Experimental Setup and Datasets

The study involved a large-scale analysis of the cryptocurrency landscape:

  • Repositories: 1,094 C++-based cryptocurrencies were scraped from CoinGecko.
  • Benchmarks: The analysis focused on four high-severity CVEs (e.g., CVE-2018-17144, a double-spending bug) targeting Bitcoin and Zcash as primary parents.
  • Language Distribution: While C++ is the dominant language for Bitcoin-based projects, the researchers also mapped the prevalence of Javascript and Go across 2,079 projects.

Analysis and Insights: The Forking Liability

The research revealed the staggering extent of code reuse in the ecosystem. Approximately 786 cryptocurrencies were found to be directly or indirectly forked from Bitcoin. Some of these clones share over 90% of their codebase with the parent, making them nearly identical targets for attackers.

Distribution of clone ratios across monitored cryptocurrencies, highlighting the prevalence of code reuse.

A key insight is the "Persistence of Bugs." Even a year after high-profile disclosures, many clones remain unpatched. While major projects like Dash or Bitcoin Cash tend to patch quickly, smaller projects often remain vulnerable for months or even years.

Results and Impact

CoinWatch demonstrated high efficacy in real-world scenarios:

  • Accuracy: The tool achieved a True Positive Rate (TPR) of 89.7%.
  • Detection: Out of 1,094 projects, CW identified 786 true vulnerabilities across 384 unique projects.
  • Market Risk: At the time of the study, 31 projects vulnerable to a specific double-spending bug represented a combined market capitalization of over $35 million.
  • Validation: The findings led to the creation of 4 new CVE extensions with MITRE, following successful developer notifications.

Conclusion and Future Work

While CoinWatch is highly effective for "Type I" (exact) clones, it faces limitations with more complex modifications. If developers rename functions (Type II) or alter logic (Type III), the current text-matching approach may fail. Future iterations of the tool aim to automate the manual annotation process and extend detection capabilities to syntactic and semantic similarities to provide broader security coverage for the cryptocurrency ecosystem.

Summary updated

BibTeX
@inproceedings{hum2020coinwatch,
  author = {Qingze Hum and Wei Jin Tan and Shi Ying Tey and Latasha Lenus and Ivan Homoliak and Yun Lin and Jun Sun},
  title = {{CoinWatch: A Clone-Based Approach For Detecting Vulnerabilities in Cryptocurrencies}},
  booktitle = {Blockchain},
  year = {2020},
  url = {https://openreview.net/forum?id=P7YTqRGbVqd},
}
Figure