Abstract
Read-Only Reentrancy (ROR) is a sophisticated cross-DApp vulnerability that has resulted in over $30 million in losses within the decentralized finance (DeFi) ecosystem. Traditional security tools often fail to detect ROR due to "boundary blindness" and siloed analysis of individual contracts. This paper presents SmartReco, a novel detection framework that combines fine-grained static analysis with multi-function fuzzing powered by on-chain data. SmartReco achieves a precision of 88.64% and has successfully identified 43 previously unknown ROR vulnerabilities in popular DApps, demonstrating its effectiveness in securing complex cross-contract interactions.
Introduction: The Read-Only Reentrancy Threat
While traditional reentrancy attacks are well-understood and often mitigated by reentrancy guards, Read-Only Reentrancy (ROR) exploits a more subtle architectural gap. In an ROR attack, an adversary manipulates the state of an "entry" DApp and then invokes a "victim" DApp while the state is inconsistent. Because the victim function only performs read operations—such as an oracle checking a price—developers frequently omit security guards, assuming these operations are inherently safe.
As shown in Figure 1, the attacker triggers a state change in the Vault (entry DApp) and, before the state is finalized, calls a function in the Pool (victim DApp) which relies on the inconsistent state via an Oracle. Existing detection tools struggle with ROR because they cannot accurately identify DApp boundaries, lack cross-DApp context, and face a massive search space when considering all possible function combinations.
The SmartReco Framework
To address these challenges, SmartReco implements a three-stage pipeline designed to bridge the gap between static code analysis and dynamic execution.
1. DApp Boundary Identification
SmartReco uses a heuristic-based algorithm to determine which contracts belong to a specific DApp. Instead of relying on potentially outdated third-party APIs, it traces the "builders" (creators) of contracts. This approach accurately groups contracts that interact as a single functional unit.
2. Cross-DApp Static Analysis
The framework performs fine-grained static analysis to locate potential entry points. It prioritizes functions based on an "Importance" metric, which considers how frequently a function reads or writes state based on historical data. To manage the search space, SmartReco applies pruning rules, such as ignoring functions already protected by access controls or existing reentrancy guards.
3. Multi-Function Fuzzing
Once potential entry-victim pairs are identified, SmartReco employs context-aware fuzzing. It uses real-world on-chain transaction data as seeds, replaying and mutating these transactions to attempt to trigger inconsistent state reads across DApps. This method is significantly more efficient than random input generation.
Evaluation and Results
SmartReco was evaluated against a labeled dataset of 45 ROR vulnerabilities and a large-scale dataset of 2,676 smart contracts from popular DApps.
- Precision and Recall: SmartReco achieved a precision of 88.64% and a recall of 86.67% on the labeled dataset.
- Comparison with State-of-the-Art: Tools like ityFuzz and Sailfish failed to detect any RORs in the benchmark, highlighting the necessity of SmartReco's cross-DApp approach.
- Real-World Impact: In wild testing, SmartReco discovered 43 new, unreported ROR vulnerabilities, putting approximately $520,000 USD at risk.
- Efficiency: By leveraging on-chain data, the framework reduced the number of required executions by nearly 75% compared to baseline "blind" fuzzing methods.
Conclusion
SmartReco demonstrates that the assumption of "read-only safety" is a significant vulnerability in the modern DeFi landscape. By identifying DApp boundaries and utilizing historical transaction data to guide analysis, SmartReco provides a robust solution for detecting complex cross-DApp reentrancy. Future work will focus on expanding language support beyond Solidity and refining gas-sensitivity analysis to further improve detection accuracy.
Summary updated