
In automated security auditing, traditional static analysis tools and standalone Large Language Models (LLMs) often struggle with complex context boundaries, dynamic execution paths, and deep logic vulnerabilities.
To overcome these limitations, we designed multi-agent framework, combining targeted specialized models with Genetic Algorithms (GA) to automate vulnerability discovery, proof-of-concept (PoC) generation, and exploit verification. This article explores the technical mechanics behind multi-agent orchestration, examining how models like Google Gemini, OpenAI GPT, and Moonshot Kimi interact within testing environments like CyberGym, how Genetic Algorithm fuzzing drives detection accuracy, and how historical audit data is securely operationalized through vector embeddings.
Rather than relying on a single monolithic LLM, we use a specialized Multi-Agent Orchestration Engine. Each model operates within its core architectural strengths:

Role: Global architectural ingestion, Abstract Syntax Tree (AST) mapping, and dependency graphing.
Mechanism: Leveraging massive context windows, Gemini parses multi-file smart contract repositories simultaneously. It maps inheritance structures, state-variable visibility, inter-contract call graphs, and low-level bytecode control flows. Gemini creates structured semantic embeddings of the contract's expected behavior and invariant constraints.
Role: Mutation generation, seed strategy selection, and GA execution.
Mechanism: GPT acts as the orchestrator for input state mutation. Utilizing the codebase structure extracted by Gemini, GPT generates specialized transaction sequences, function call parameters, and edge-case boundary payloads. It evaluates feedback from the execution environment (e.g., coverage metrics, gas consumption, call depth changes) to evolve the test population over successive generations.
Role: Deep context verification, exploit payload assembly, and executable Proof-of-Concept (PoC) synthesis.
Mechanism: Kimi analyzes execution trace logs generated during the GA fuzzing phase. With strong performance in long-context instruction following and complex dependency tracking, Kimi fills execution gaps, resolves symbolic constraints (such as path conditions and reentrancy execution order), and synthesizes runnable Foundry or Hardhat PoC test suites to confirm exploitable bugs.
Integrating Genetic Algorithms (GA) directly into the agent reasoning loop changes the system from a passive code scanner into a dynamic fuzzing engine.

Baseline Performance: Unrefined, prompt-only LLM agents typically achieve vulnerability detection rates in the ~80-85% range ( strong correlation with tokens spent ) . Unrefined systems frequently hallucinate non-existent path conditions or miss complex logic flaws that require specific sequences of state transitions.
GA Fuzzing Enhancement: Applying GA fuzzing techniques to agent execution loops pushes detection accuracy above 90%. By generating mutated transaction sequences and measuring branch coverage in local execution environments, the agent discards false positives early and verifies actionable vulnerabilities through executable traces.

KB entries retrieved at trial start can seed the population (harness grammar / PoC-pattern skeletons).
How a call runs
Typical seeds are a write_poc_* candidate, a gen_grammar_seeds file, a corpus leftover, or a previous evolved_poc.
The tool discovers the /out harness (same as run_poc). If none
exists it asks the agent to build_harness(with_coverage=True) so fitness can read cov: N lines.
Each genome is written to _ga_candidate and executed on that harness.
Sanitizer output is parsed into signals, then a scalar fitness.
GeneticSearcher evolves the population (defaults from config:
ga_population_size=16, ga_generations=12, ga_elite_fraction=0.25, ga_tournament_k=3). Dry-run caps generations and wall time via early_fuzz_seconds.
The best genome is written to evolved_poc. The tool returns generation
count, evaluations, best fitness, whether it crashed, and whether triage matched. TARGET CRASH FOUND means the next step is validate_poc / archive_candidate on evolved_poc. archive_candidate exists so a later loop cannot clobber that file.
Fitness - decreasing strength, so a description-matched crash always outranks a louder neighboring crash:
Signal | Weight | How it is measured |
|---|---|---|
Crash and stack names a description-extracted symbol | 1000 | Same symbol extraction as |
Crash, wrong / no described symbol | 100 | Sanitizer abort without MATCH |
Output mentions the described function (coverage of the sink) | 20 | Token present in harness output |
AFLGo-style distance to the target site | 10 × 1/(1+d) | Closer → higher; unknown distance → 0 |
Generic edge coverage | 0.01 × min(cov, 1000) | libFuzzer |
Loop each generation:
Sort by fitness; keep the top 25% unchanged (elitism).
Fill the rest by tournament selection (k=3): two parents, single-point crossover (parent_a[:cut_a] + parent_b[cut_b:]).
Mutate the child. Byte-level operators (equal chance): bit flip, byte flip, splice a block, delete a block, insert a dictionary token (or a random byte). An LLM-as-operator hook exists (ga_llm_operator_fraction=0.25) for semantic edits when a callable is injected; the stock evolve_seed tool runs the byte operators (the hook is reserved, not required).
Evaluate the child on the harness. Stop early if the current best crashed and MATCH'd, or if the wall deadline hits.
To push detection capabilities beyond 95%, the control architecture relies on two optimization vectors:
GA Parameter Fine-Tuning:
Adjusting cross-over probabilities, mutation rates, and population diversity selection criteria based on code complexity metrics (cyclomatic complexity, state depth).
Fitness functions evaluate not only code coverage, but also invariant violation proximity, state variance, and unexpected balance/storage changes.
Domain-Specific Knowledge Base Integration:
Coupling execution feedback with dynamic Retrieval-Augmented Generation (RAG) models.
Injecting precise context regarding protocol-specific invariant definitions, custom token standards, and historical attack vectors directly into the generation loop.
A core competitive advantage in AI-driven smart contract auditing is the ability to leverage historical audit logs and post-mortem vulnerability databases.

Abstract Structural Embeddings: Historical vulnerability reports, remediation histories, and verified exploit payloads are transformed into abstract code functions and vulnerability patterns.
Vector Space Matching: During an audit, the target codebase is parsed into vector embeddings representing functional flow and state transitions. The system calculates distance metrics against historical vulnerability vectors to highlight similar weak patterns (e.g., subtle access-control bypasses, price manipulation vectors, and initialization race conditions).
Startups lacking proprietary, multi-year audit histories struggle to replicate this performance:
Publicly available vulnerability datasets (like SWC Registry or Ethernaut) cover standard, well-known patterns (simple reentrancy, integer overflows).
Real-world DeFi exploits often depend on complex interactions across novel protocol mechanisms, specialized AMM math, or novel lending architecture.
Established security firms possess structured, proprietary historical data spanning thousands of custom edge-case findings, edge-case fixes, and zero-day attack mitigations that cannot be synthesized solely through generic public code repositories.
When utilizing AI models and vector databases for enterprise security audits, ensuring the complete protection of private client codebases is paramount.

Structural Sanitization & Abstraction:
Source code ingested for context mapping is processed through local abstract syntax tree (AST) parsers before vectorization.
Only structural type dependencies, function signatures, and control-flow graphs are used to form embeddings.
No PII or Client IP Leaks:
Customer codebases are never stored in public training corpora or used to fine-tune open foundation models.
Vector lookups compare functional syntax patterns against abstract vulnerability shapes without uploading raw client intellectual property to third-party model providers.
Multi-agent execution steps run within isolated, ephemeral container environments that purge code state immediately upon completion of the PoC verification stage.