Introduction
The promise of decentralized finance (DeFi) is often compromised by the presence of privileged roles within smart contracts. While administrative functions like owner or admin are frequently intended for legitimate maintenance, they often serve as "backdoors" that introduce significant financial centralization risks. These risks allow developers to arbitrarily mint tokens, freeze user accounts, or drain funds—tactics famously employed in "rug pull" scams like the Squid Game token incident.
Current security tools, such as Pied-piper and Tokeer, primarily rely on predefined code patterns to detect these vulnerabilities. However, these syntax-based approaches are easily bypassed by novel logic or slightly altered code structures. To address this, we present JANUS, an automated analyzer that shifts the focus from "what the code looks like" to "what the code actually does to the assets."
System Architecture and Methodology
JANUS employs a "difference-oriented" philosophy to identify behavioral discrepancies between privileged accounts and ordinary users. The system's workflow is built upon three core pillars:
1. Iterative Difference Analysis
JANUS performs dual symbolic execution on contract functions. It simulates execution paths for both a privileged account and an ordinary user, then compares the resulting states. If a privileged account can reach a state—specifically a modification of a financial variable—that is inaccessible to a standard user, JANUS flags the behavior as a potential risk.
2. State Space Optimization via Variable Summaries
To mitigate the "state explosion" problem common in symbolic execution, JANUS utilizes Variable Summaries. Instead of tracking every possible numerical value, it abstracts variable states into qualitative categories such as "increased," "decreased," or "unchanged." This abstraction, combined with a difference-oriented state traversal, allows the tool to prune redundant paths while maintaining focus on variables that exhibit behavioral differences.
3. Financial Variable Recognition using GNNs
Not all state differences indicate a security risk; for instance, an owner updating a descriptive string is harmless. To distinguish between benign changes and financial exploits, JANUS employs a Graph Neural Network (GNN). By constructing a "Heterogeneous Variable Property Graph," the GNN learns the context of variable usage (e.g., how balanceOf relates to transfer logic) to identify variables representing digital assets with over 98% accuracy.
Experimental Evaluation
The researchers evaluated JANUS using a comparison dataset of 540 contracts (including known risky contracts and their "repaired" counterparts) and a real-world dataset of 33,151 contracts from Ethereum and Binance Smart Chain (BSC).
Comparative Performance
In head-to-head tests against existing tools, JANUS demonstrated superior accuracy and reliability.
As shown in the results, JANUS achieved zero False Negatives (FN) across all five major risk categories: Arbitrarily Transfer, Arbitrarily Mint, Destroy Account, Disable Transferring, and Freeze Account. Notably, in the "Freeze Account" category, where Pied-piper produced 56 False Positives, JANUS maintained a clean record.
Real-world Impact
When applied to the large-scale real-world dataset, JANUS flagged 8,391 contracts as risky. A manual audit of 1,000 samples confirmed a precision of 91.0% and a recall of 91.37%. Furthermore, JANUS identified two novel risk categories previously missed by pattern-based tools:
- Parameter Manipulation: Owners arbitrarily increasing transaction fees to 100% during transfers.
- Whitelist Backdoors: Owners bypassing global transfer locks for specific accounts to facilitate rug pulls.
Conclusion and Future Directions
JANUS represents a significant advancement in smart contract security by prioritizing semantic impact over syntactic patterns. By focusing on how privileged roles affect financial variables, it uncovers sophisticated exploits that evade traditional detection. Future work will focus on expanding the definition of "financial" variables to include metadata and governance risks, optimizing analysis speed through parallelization, and exploring the integration of Large Language Models (LLMs) to better interpret developer intent.
Summary updated