Automated Vulnerability Detection in Smart Contracts

16 concepts16 papers1 proposal

Smart contracts have fundamentally shifted how we manage digital assets by encoding agreements directly into immutable code. However, this immutability is a double-edged sword. In traditional software, a critical bug can be patched post-deployment. In a decentralized ecosystem, a vulnerability deployed to the blockchain is permanent, often exposing millions of dollars to immediate exploitation.

As highlighted by Bin Hu et al., these security flaws undermine the foundational trust required for automated agreements. The risks span from high-value over-the-counter financial markets, as explored by Xuan Zhang, to automated industrial settings and next-generation communication networks, as noted by Minho Jo et al. and Ali Hussain Khan et al.. To protect these ecosystems, researchers have developed automated techniques to detect vulnerabilities before they can be exploited.

Instrumenting the Contract State

To find a bug, an automated tool must first understand the contract's structure and execution flow. At the source-code level, this requires parsing high-level languages like Solidity into a machine-readable format.

Chao Peng et al. addressed this by creating SIF, a framework that generates a C++-based intermediate representation of a contract's Abstract Syntax Tree (AST). By mapping code to an AST, developers can insert custom instrumentation—extra pieces of code that monitor variables or state changes—directly into the contract. This source-level visibility allows static analysis tools to reason about the contract's logic before it is compiled.

Solidity Source Code ──> Abstract Syntax Tree (AST) ──> Custom Instrumentation

However, source code is not always available, and static analysis can miss complex runtime behaviors that only occur during live execution on the Ethereum Virtual Machine (EVM).

Dynamic Fuzzing and Test Oracles

When static analysis falls short, researchers turn to dynamic fuzzing: executing the contract repeatedly with a massive volume of randomly generated transactions to see if it breaks.

The challenge with fuzzing smart contracts is knowing when a vulnerability has actually been triggered. Unlike traditional software, where a bug might cause a clean program crash, a vulnerable smart contract often executes successfully from the EVM's perspective, even while its funds are being drained. Fuzzers therefore rely on test oracles—predefined security rules that monitor execution behavior for anomalies.

Bo Jiang et al. pioneered this approach with ContractFuzzer. By instrumenting the EVM itself, ContractFuzzer monitors execution traces against specific vulnerability signatures, such as reentrancy loops or unhandled exceptions.

To make this process more proactive, Haijun Wang et al. developed ContraMaster, which pairs semantic test oracles with dynamic exploit generation. Instead of just flagging a potential bug, ContraMaster actively searches for a sequence of inputs that constructs a working exploit, proving definitively that a vulnerability exists and is actionable.

Learning Vulnerability Signatures from Bytecode

While fuzzing is highly accurate, exploring every possible transaction combination is computationally expensive. To accelerate detection, recent work leverages deep learning to scan compiled bytecode directly, bypassing the need for source code or lengthy execution loops.

The core challenge here is that raw bytecode lacks human-readable semantics like variable names or clear control-flow graphs. To bridge this gap, researchers use metric learning paired with triplet loss functions to teach neural networks how to distinguish between safe and unsafe contracts.

Anchor (Target Contract) ──────┐
                               ▼
Positive (Known Safe)   ───> [ Triplet Loss ] <─── Negative (Known Vulnerable)
                               ▲
                               └─ Pulls Safe closer, pushes Vulnerable away

As implemented by Feng Mi et al. and Meiying Wang et al., a Bidirectional Long Short-Term Memory (BiLSTM) network processes bytecode sequences. During training, the triplet loss function takes three inputs: an anchor contract, a positive example (a safe contract), and a negative example (a vulnerable contract). The network learns to project these contracts into a high-dimensional vector space where the distance between the anchor and the safe contract is minimized, while the distance to the vulnerable contract is maximized.

To handle the inherent noise and missing context in compiled bytecode, Guokai Sun et al. introduced MTVHunter, which uses a multi-teacher knowledge translation framework. One "teacher" network focuses on denoising the raw instructions, while another recovers missing semantic information, allowing the underlying model to accurately classify vulnerabilities based on subtle structural patterns.

The Role of Large Language Models

With the rise of generative AI, researchers have also evaluated whether Large Language Models (LLMs) can replace these specialized architectures. Chong Chen et al. benchmarked ChatGPT's capability in this domain, revealing a distinct trade-off: while LLMs achieve high recall (they are excellent at spotting a wide variety of potential issues), they suffer from low precision, generating numerous false positives that require manual filtering.

The Frontier: Logic Errors and Economic Security

Despite the sophistication of fuzzers and deep learning models, a significant gap remains between automated detection and real-world exploits. Stefanos Chaliasos et al. evaluated existing security tools against historical Decentralized Finance (DeFi) attacks and found that they only prevented roughly 8% of incidents.

The reason for this gap lies in the nature of the vulnerabilities. Existing tools excel at finding well-defined technical bugs (like reentrancy or integer overflows), but they struggle with protocol-level logic errors.

As Sam M. Werner et al. point out, DeFi security must be divided into two categories:

  1. Technical Security: Ensuring the code executes exactly as intended without low-level crashes or exploits.
  2. Economic Security: Ensuring that the system's economic incentives cannot be manipulated (e.g., via flash loans or oracle manipulation), even if the underlying code executes flawlessly.

To tackle this frontier, tools must move beyond syntax and bytecode patterns toward understanding financial intent. Frameworks like FASVERIF, introduced by Wansen Wang et al., attempt to automatically infer and verify financial security properties. By modeling the expected economic behavior of a contract, these advanced verification systems aim to ensure that automated protocols are secure not just against code exploits, but against economic manipulation as well.

Key Foundational Work

ContractFuzzer: fuzzing smart contracts for vulnerability detection (2018) — contributed 2 concept elements to this direction.
SIF: A Framework for Solidity Contract Instrumentation and Analysis (2019) — contributed 1 concept elements to this direction.
History & citationVersion 1 · 2026-10-04

Current · Permanent link

View frozen version 1

Cite this direction

Latest version (a living page):

@misc{lacuna_smart_contract_security_vulnerabilities_a8c7e589,
  title = {smart contract security vulnerabilities},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/smart-contract-security-vulnerabilities/rdr_a8c7e589faa9470d975c17d9340c28ad},
  note = {Latest version of a living research direction; cite a version for a fixed text. Accessed 2026-11-20},
}

This exact version (version 1, frozen text):

@misc{lacuna_smart_contract_security_vulnerabilities_a8c7e589_v1,
  title = {smart contract security vulnerabilities},
  author = {{Lacuna}},
  howpublished = {Lacuna research direction},
  year = {2026},
  url = {https://lacuna.tiptreesystems.com/direction/smart-contract-security-vulnerabilities/rdr_a8c7e589faa9470d975c17d9340c28ad/v/1},
  note = {Version 1, frozen 2026-10-04. Accessed 2026-11-20},
}
About

These directions overlap with this one through shared papers.

See something wrong? Report a mistake