Hardhat plugin for CFG-based static analysis, YAML-driven audits, and deep vulnerability detection
SuperAudit is an enterprise-grade smart contract security analysis framework that redefines vulnerability detection for Solidity developers by combining advanced static analysis, artificial intelligence, and decentralized infrastructure into a single, intuitive platform. The project addresses the critical gap in Web3 security tooling by moving beyond traditional pattern-matching linters to implement sophisticated Control Flow Graph analysis that traces execution paths and identifies real-world exploits such as reentrancy attacks, authorization vulnerabilities, and state-ordering violations. At its foundation, SuperAudit features a comprehensive rules engine with 21 built-in analysis rules ranging from code style conventions to complex vulnerability patterns, all executable through a flexible configuration system supporting three analysis modes (basic, advanced, and full) to accommodate different use cases from quick CI/CD checks to comprehensive pre-deployment security reviews. The platform's most innovative aspect is its YAML-based playbook system, which democratizes security expertise by enabling security researchers and experienced auditors to codify their knowledge into shareable, version-controlled audit strategies that can be customized for specific project types like DeFi protocols, token contracts, or vault implementations. SuperAudit integrates cutting-edge AI capabilities through GPT-powered analysis that automatically explains vulnerabilities in developer-friendly language, suggests concrete code fixes, and provides risk scoring—transforming raw security findings into actionable intelligence without requiring specialized expertise. The project encompasses a complete ecosystem including a decentralized playbook registry built on IPFS and Lighthouse for permanent, encrypted storage; a blockchain-native payment system enabling security creators to monetize their expertise through cryptocurrency transactions; an interactive command-line interface featuring beautiful ASCII art, color-coded output, and guided menus; and multiple output formats including console, JSON, and SARIF for seamless integration with GitHub workflows and CI/CD pipelines. Built entirely in TypeScript for Hardhat 3.0, SuperAudit represents a fundamental evolution in smart contract security tooling—combining the rigor of traditional static analysis with the accessibility of AI explanation, the economics of blockchain payments, and the resilience of decentralized infrastructure to create the first truly modern security platform for Web3 developers.
The Architecture & Technology Stack SuperAudit is constructed as a modular Hardhat 3.0 plugin written entirely in TypeScript, leveraging a carefully orchestrated stack of specialized technologies to handle different aspects of security analysis. At the parsing foundation, we use @solidity-parser/parser to convert Solidity source code into Abstract Syntax Trees (ASTs), which serve as the raw material for our analysis engine. Since the parser doesn't export TypeScript types, we defined our own comprehensive type system to ensure type safety throughout the codebase—a decision that caught countless bugs early and made refactoring substantially safer.
The Analysis Engine: Three Tiers of Detection The core analysis engine is built in three distinct layers. The first layer consists of 21 AST-based rules that perform fast pattern matching on the parsed syntax tree—checking for naming conventions, visibility modifiers, and basic code quality issues. These rules execute in milliseconds and form the foundation of every analysis. The second layer implements Control Flow Graph (CFG) construction and analysis, where we build a directed graph representing all possible execution paths through a function, then traverse these paths to detect real vulnerabilities like reentrancy and CEI pattern violations. This is computationally more expensive (50ms per file) but catches actual exploits that naive pattern matching misses. The third layer is our playbook execution engine, which parses YAML-based audit strategies and executes custom rules defined using our Domain-Specific Language (DSL).
The DSL: Custom Pattern Matching Language We implemented a custom DSL parser for playbook rules that allows security experts to write pattern-matching logic in plain YAML without touching code. The DSL supports function calls like pattern.functionCall(name='approve'), state variable patterns like pattern.stateVariable(visibility='public'), and complex conditions. Particularly tricky was handling parameter validation—we learned the hard way that patterns require named parameters (e.g., pattern.selfdestruct(present=true) not pattern.selfdestruct()), which required robust error messaging to help users debug their playbooks.
AI Integration: Smart, Cost-Optimized Enhancement We integrated OpenAI's API for AI-powered explanations, but did this intelligently. Initially, we enhanced every finding, including trivial style warnings—which was wasteful. We implemented intelligent filtering to only enhance security-critical rules (reentrancy, authorization, CEI violations), reducing API calls by 80% and cutting costs dramatically. We also switched from GPT-4 to GPT-4o-mini because older GPT-4 models didn't support JSON mode with response_format parameter; GPT-4o-mini is cheaper, faster, and has better JSON support. We added fallback JSON parsing from markdown code blocks to handle edge cases where structured output fails.
CLI & User Experience: Terminal Transformation The interactive CLI was built using chalk for beautiful ANSI colors and readline for interactive prompts. We created a reusable InteractiveMenu class that handles menu navigation, input validation, and secure password prompts. The UX challenge was transforming boring terminal output into something developers actually enjoy using—we included two ASCII art banners, 9 color schemes, 28+ custom icons (✓, ✗, 🔍, 💳, etc.), and formatted tables. The interactive menu task (superaudit-menu.ts) orchestrates sub-menus for analysis, playbook management, and payment requests, with proper error handling and user guidance at every step.
Playbook Storage: Decentralized & Encrypted For playbook storage, we integrated Lighthouse, which provides IPFS-backed file storage with end-to-end encryption. The flow: users upload YAML playbooks, Lighthouse encrypts them with the user's private key, stores on IPFS, returns a content identifier (CID). We built a PlaybookRegistry singleton that manages playbook metadata, maintains indexes by tags and authors for fast searching, and tracks usage statistics. The registry distinguishes between three sources: builtin playbooks (shipped with the plugin), file-based playbooks (local YAML files), and remote playbooks (IPFS-stored via CID).
Blockchain Integration: Crypto Payments The payment system was built using ethers.js v6 for blockchain interaction. The PaymentManager class handles the complexity of Web3 wallets—prompting users for private keys (with masked input), creating and signing transactions, broadcasting to the network, and verifying payment on-chain. A particularly tricky detail: we had to handle both automatic payment (where we sign and send) and manual payment (where we return TX details for the user to send themselves). We also implemented encrypted user tracking—storing who paid for access in encrypted lists on Lighthouse, so creators can verify legitimate access without exposing user data.
Configuration System: Multiple Approaches Users can configure SuperAudit three ways: hardhat.config.ts (recommended), environment variables, or multiple config files. We built a ConfigResolver that merges these sources intelligently, with proper validation and helpful error messages. The three analysis modes (basic/advanced/full) allow developers to choose speed vs. comprehensiveness based on their context—CI/CD pipelines use basic mode (2ms), development uses advanced (50ms), and pre-deployment uses full with AI (500ms+).
Output Formatting: Three Formats, One Engine We implemented three distinct output formats using a pluggable Reporter architecture. The console reporter uses chalk for colors and custom formatting. The JSON reporter outputs structured data for tool integration. The SARIF reporter generates GitHub-compatible output so security findings appear as PR comments. All three consume the same underlying issue data structure, ensuring consistency.
Notably Hacky Solutions Worth Mentioning Task File Mapping: Hardhat's dynamic task loading required a custom taskFileMap to translate task names to file paths. This was a workaround for how the plugin dynamically loads tasks without explicitly registering each one.
Type Definitions for Untyped Parser: Since @solidity-parser/parser doesn't export TypeScript types, we hand-wrote comprehensive type definitions that match its actual output. This is fragile but necessary for type safety.
CFG Path Explosion Handling: Building complete control flow graphs can create exponential paths. We implemented path pruning and memoization to prevent analysis timeouts on complex functions—a practical necessity rather than elegant design.
AI Fallback Parsing: GPT-4o-mini sometimes returns invalid JSON despite response_format. We implemented fallback parsing that extracts JSON from markdown code blocks (``json ... ````), which actually works surprisingly well.
Playbook DSL with Limited Expressiveness: The DSL intentionally limits what's possible (no arbitrary code execution). This required careful language design to be useful without being Turing-complete—a security decision that occasionally frustrates power users.
Encrypted File Handling: Lighthouse encryption works with user private keys, but we had to implement careful key management—prompting users exactly when needed, never storing keys, and handling key mismatches gracefully when users lose private keys.
Why This Architecture Works The three-tier analysis approach (AST → CFG → playbooks) allows developers to choose their speed/accuracy tradeoff. The playbook system lets us ship just 3 builtin playbooks while enabling unlimited customization. The registry system keeps playbooks organized and searchable despite being decentralized. The payment integration creates economic incentives for security knowledge sharing. The beautiful CLI makes the tool actually enjoyable to use, which matters more than most developers realize.
The Result SuperAudit is production-ready with zero build errors, supporting complex Solidity analysis, AI explanations, custom playbooks, decentralized storage, blockchain payments, and an interactive CLI—all integrated seamlessly into the Hardhat development workflow. Every component was designed with developer experience in mind, from type safety to error messages to visual presentation.

