Smart contracts are the backbone of decentralized finance, managing billions of dollars in digital assets. However, as the infamous DAO and BeautyChain hacks proved, a single programming error can lead to catastrophic financial loss. While many tools exist to find low-level bugs like integer overflows, they often miss the "silent killers": logic errors where the code runs perfectly but violates the fundamental rules of its intended standard.
In their paper, "Detecting Standard Violation Errors in Smart Contracts," Ao Li and Fan Long from the University of Toronto introduce SOLAR, a symbolic execution tool designed to catch these elusive standard violations.
The Problem: Logic vs. Runtime Errors
Most existing security tools for Ethereum focus on "runtime errors"—things like integer overflows or reentrancy. While important, these tools have a major blind spot: they cannot determine if a contract is doing something "legal" but logically incorrect.
For example, an ERC-20 token contract might successfully execute a transfer without crashing, but fail to correctly update the totalSupply variable. To a standard bug-hunter, this looks fine. To a user or exchange, it is a critical failure of the contract's logic. The authors identify a "gap" in current research: a lack of tools that can verify if a contract actually conforms to the community-driven technical standards (like ERC-20 for fungible tokens) that they claim to follow.
Methodology: The SOLAR Symbolic Execution Engine
SOLAR utilizes symbolic execution on Ethereum Virtual Machine (EVM) bytecode. Instead of running the contract with specific numbers, it uses symbolic variables to explore all possible execution paths. The core algorithm for this exploration is detailed below.
The core innovations that make SOLAR effective include:
- User-Specified Invariants: Users can write high-level constraints (in a Python-like syntax) derived from standards. For example: "The sum of all account balances must always equal the total supply."
- Customized Addressing Mechanism: EVM storage often uses complex SHA3 cryptographic hashes to determine data locations. These hashes are "kryptonite" for SMT solvers. SOLAR replaces these with a lightweight addressing scheme that prevents "path explosion" while maintaining functional equivalence.
- Volatile Memory Optimization: The EVM stack uses 256-bit values, but its memory is 8-bit. Naively processing these leads to massive, redundant symbolic expressions. SOLAR uses a symbolic cache to track 256-bit values stored in memory, skipping expensive bit-level operations when possible.
Evaluation and Key Results
The authors evaluated SOLAR using a benchmark of 1,089 real-world smart contracts scraped from Etherscan, including 779 ERC-20 contracts and 310 ERC-721 (NFT) contracts.
SOLAR's performance was impressive, especially when compared to industry-standard tools like Mythril:
- Detection Power: It found 255 standard violation errors across 197 vulnerable contracts.
- Zero-Day Discovery: 237 of these errors were "zero-day" (previously unreported).
- Precision: SOLAR reported only 3 false positives in its main evaluation. In a head-to-head manual comparison of 100 contracts, SOLAR found 36 errors with zero false positives, while Mythril reported 127 errors, of which only one was a "true" positive.
- Market Impact: The total market cap of the vulnerable contracts found by SOLAR exceeded $900 million at the time of writing.
Key Insights
The results reveal a disturbing reality: many "top" contracts that manipulate publicly traded assets do not fully conform to their standards. This includes "backdoors" that allow owners to manipulate balances and "attackable" corner cases. The paper argues that logic errors are often more dangerous because they don't trigger typical "red flags" in standard analysis tools. By leveraging the fact that most contracts follow a few common standards, SOLAR provides a tool that is both general-purpose and highly specific.
Limitations and Future Work
While powerful, SOLAR has a few acknowledged limitations. To keep the analysis tractable, SOLAR bounds the size of dynamic objects (like arrays or maps) to three elements, which could theoretically miss bugs appearing only with larger data structures. Additionally, it uses a "no write after external call" rule to detect reentrancy, which may miss complex scenarios. Currently, a human must derive the invariants from technical standards; future work could involve automatically extracting these specifications directly from standard documentation.
Summary updated