Miso
solana smart contract auditor and deployer
The problem Miso solves
MISO (Miso Smart Inspector & Optimizer) is an end-to-end security auditing and remediation platform built specifically for Solana & Anchor Rust smart contracts. It bridges the gap between static rule-based analysis, Retrieval-Augmented Generation (RAG) powered by real Solana audit datasets, and interactive AI-driven code patchingβall integrated directly into the developer's terminal workflow and synced with an interactive web dashboard.
π― The Problem It Solves
1. High Vulnerability Rates in Solana Smart Contracts
Solana smart contracts written in Rust/Anchor are prone to critical security vulnerabilities such as:
- Missing Signer / Owner Checks: Allowing unauthorized account access or fund draining.
- Unconstrained Cross-Program Invocations (CPIs): Allowing arbitrary program execution.
- PDA Bump Unvalidation: Enabling spoofed Program Derived Addresses.
- Unsafe Account Closing & Rent Exemption Flaws: Exposing accounts to re-initialization attacks.
- Unchecked Arithmetic: Causing integer overflows/underflows.
2. Manual & Costly Security Audits
Traditional smart contract security audits are manual, expensive (ranging from tens to hundreds of thousands of dollars), and slow down rapid development iterations.
3. LLM Hallucinations in Code Remediation
While generic LLMs can suggest code, they frequently generate syntactically invalid Rust/Anchor code, fail to account for Anchor framework constraints (e.g. lifetime parameters, account validation macros), or break existing logic when patching.
4. Fragmented Developer Workflows
Existing tools either run only static analysis in CI/CD or operate as separate web interfaces. Developers lack a terminal-native tool that scans code locally, presents VS Code-style inline diffs, auto-applies verified patches with rollbacks, and security-gates deployments.
π₯ Key Features
- π‘οΈ Hybrid Audit Engine: Combines 7 Solana-specific deterministic static security rules with semantic LLM inspection to calculate a weighted Confidence Score (
75% AI Score + 25% Static Score). - π§ RAG-Powered AI Auto-Patcher: Leverages ChromaDB vector embeddings trained on real Solana security audit datasets (
solana_security_audit_dataset.jsonl) to retrieve relevant vulnerability contexts and generate precise Rust security patches. - π₯οΈ VS Code-Style Terminal Diffs: Interactive CLI prompt presenting side-by-side/inline unified diffs, auto-backup creation (
.bak), interactive patch approval ([A]pply,[S]kip,[V]iew,[M]anual), and re-scanning. - πͺ Security-Gated Deployment (
miso deploy): Prevents deploying contracts to Solana devnet/mainnet if the security score drops below a configurable threshold (default:90/100). - π Automated Audit Logs (
MISO.md): Generates an append-only audit trail markdown file tracking scans, confidence scores, and historical vulnerability trends. - π MISO Hub & Web Platform: Sleek React/Vite web application featuring 3D visualizers, live audit reporting, documentation, and Neon PostgreSQL database synchronization.
β‘ System Architecture
+-----------------------+
| Solana Rust Contracts |
+-----------+-----------+
|
v
+-------------------------+
| MISO Hybrid Scan Engine|
| - 7 Static Rules Parser|
| - LLM Semantic Scanner |
+------------+------------+
|
v
+-----------------------+
| Weighted Audit Score |
| & Findings |
+-----------+-----------+
|
v
+-------------------------+
| RAG Query & Retrieval |
| (ChromaDB + Gemini) |
+------------+------------+
|
v
+-------------------------+
| MISO AI Patch Generator|
+------------+------------+
|
v
+-------------------------+
| Terminal Interactive Diff|
Challenges we ran into
1. LLM Syntax Hallucinations in Anchor Rust Patches
- Challenge: Standard LLMs often fail to generate syntactically correct Anchor Rust codeβfrequently omitting lifetime parameters (e.g.
Context<Withdraw<'_>>), breaking Anchor macro expansions, or introducing ownership/borrow checker errors. - Solution: We implemented a RAG pipeline using ChromaDB populated with real-world Solana security audit cases. We engineered specialized prompt templates (
miso_patch_prompt.txt) that instruct the LLM to output precise line-by-line diffs with strict Anchor syntax rules, and integrated AST-level validations before surfacing patches to developers.
2. Cross-Language Bridge (Node.js CLI to Python RAG Pipeline)
- Challenge: Node.js is great for fast terminal CLIs and interactive menus, but Python is the standard ecosystem for vector stores (ChromaDB, LangChain). Running a heavy persistent Python daemon for a fast CLI tool was impractical.
- Solution: Built an asynchronous, lightweight JSON-over-stdio IPC subprocess bridge (
ragBridge.js$\leftrightarrow$retrieval.py). The CLI executes python RAG retrieval on demand only duringmiso patch, keeping all other CLI operations ultra-fast and independent.
3. Deterministic vs. Non-Deterministic Scoring Alignment
- Challenge: Relying solely on static regex/AST parsing leads to high false positives, while relying purely on LLM scoring causes score variance between runs.
- Solution: Designed a hybrid scoring formula combining deterministic static AST rule evaluations (25% weight) with deep LLM semantic code analysis (75% weight), bounded by a margin metric. This creates consistent, repeatable confidence scores ranging from 0β100.
4. Safe In-Place File Patching & Rollbacks
- Challenge: Automatically modifying developer Rust source code in-place carries high risk of accidental code loss or unwanted changes.
- Solution: Developed a fail-safe patch applicator (
patchApplicator.js) that automatically creates timestamped backups (.bak) before any mutation, verifies file target ranges, allows instant rollbacks, and provides interactive diff preview screens.
5. Multi-Tiered API Provider Management
- Challenge: Rate limits and key management across Google Gemini and Groq LLMs.
- Solution: Created a centralized provider client (
llmClient.js&config.js) supporting hot-swappable providers, environment variable fallbacks, and CLI key management (miso provider-gsk_...).
π‘οΈ Solana Security Rules Covered
| Rule ID | Severity | Description |
|---|---|---|
MISSING_SIGNER_CHECK | π΄ Critical | Accounts modified without verifying is_signer flag |
MISSING_OWNERSHIP_CHECK | π΄ Critical | Account owner constraint missing (untrusted account data) |
PDA_BUMP_UNVALIDATED | π High | Using unverified PDA bump seeds instead of canonical bump |
UNCONSTRAINED_CPI | π High | Invoking target program via CPI without verifying program ID |
UNSAFE_ACCOUNT_CLOSE | π High | Closing accounts without zeroing data or clearing lamports |
UNCHECKED_ARITHMETIC | π‘ Medium | Raw arithmetic operations prone to overflow/underflow |
MISSING_RENT_EXEMPTION | π‘ Medium | Account initialization missing explicit rent-exemption checks |
π¦ Project Structure
miso-cli/
βββ miso-cli/ β Terminal-native CLI Application
β βββ bin/miso.js β Executable entry point
β βββ src/
β β βββ cli/ β Commands (scan, patch, deploy, save, history)
β β βββ engine/ β AST parser & 7 static Solana security rules
β β βββ rag/ β RAG bridge connecting Node.js to Python
β β βββ llm/ β Prompt engineering & API client (Gemini/Groq)
β β βββ utils/ β Interactive terminal diff & patch applicator
β βββ rag/ β Python ChromaDB vector store & ingestion pipeline
βββ miso - front/ β Web Frontend & API Hub
β βββ src/ β React 19 + Vite + TailwindCSS + Three.js
β βββ server.js β Express backend with PostgreSQL integration
β βββ public/ β Static assets
βββ MISO.md β Automated audit log generated by scans
βββ README.md β Root documentation
π Getting Started
Prerequisites
- Node.js: v18 or higher
- Python: v3.10+ (for RAG vector search during
miso patch) - API Key: Google Gemini API key or Groq API key
1. Installation
# Clone the repository
git clone https://github.com/ruyamB/NBH-MISO.git
cd NBH-MISO
# Install CLI dependencies
cd miso-cli
npm install
# Install Frontend dependencies
cd "../miso - front"
npm install
2. Configuration & RAG Setup
cd miso-cli
# Set your API key
miso provider-AIzaSy... # Google Gemini key
# or: miso provider-gsk_... # Groq key
# B
Tracks Applied (4)
Best Use of Gemini API
Google Cloud
Best Use of Solana
Solana
Open Innovation
Best Beginner's team
Technologies used
