How deonmenezes/mantishack works
1. Top-level shape
This is a monorepo for an autonomous offensive-security framework, not a single app. The runtime is predominantly Python, with command wrappers in bin/, mantishack.py, mantishack_agentic.py, and many executable shims in libexec/. The repo also contains large data sets, rule packs, and test corpora that are part of the architecture, not just fixtures.
2. Two control planes
The README’s key architectural split is between the Python execution layer and the Claude Code decision layer.
- The Python layer (core/, packages/, engine/) runs scans, analysis, validation, reporting, and artifact management.
- The Claude layer (.claude/, tiers/, CLAUDE.md) supplies the human/agent workflow: slash commands, skills, specialist agents, and persona-driven reasoning.
3. Command surface and workflow entrypoints
The primary user-facing entrypoints are the /mantis-* commands defined under .claude/commands/, with supporting skills and agents under .claude/skills/ and .claude/agents/. These commands route into the Python packages through libexec/* wrappers, so the architecture is “command-driven orchestration over shared analysis engines,” not a single monolithic CLI.
4. Core orchestration layer
core/orchestration/, core/run/, core/project/, and core/reporting/ form the backbone for turning a target into structured findings.
- core/run/ tracks provenance, identity, metadata, and safe output handling.
- core/project/ manages named workspaces, merges/diffs, exports, and finding correlation.
- core/reporting/ renders findings and witness data into console/report formats.
5. Static analysis pipeline
Static code analysis is centered around Semgrep and CodeQL, but the repo wraps them in substantial orchestration.
- packages/semgrep/ and packages/codeql/ provide scanners, model adapters, and evidence validators.
- engine/semgrep/rules/ and engine/codeql/suites/ hold the actual rule/query packs.
- core/sarif/ parses SARIF output into the internal finding model.
The data flow is: source tree → scanner(s) → SARIF/JSON findings → validation/correlation → reports.
6. Dataflow and exploitability validation
core/dataflow/ and packages/hypothesis_validation/ are the main “is this real?” layer. They consume findings from scanners, augment them with path/constraint evidence, and decide whether a result is reachable, meaningful, and worth escalation. This layer also bridges to LLM extraction and barrier synthesis, so it is the boundary between raw tool output and attackable hypotheses.
7. Agentic analysis and LLM dispatch
core/llm/, packages/llm_analysis/, packages/code_understanding/, packages/autonomous/, and packages/strategy_eval/ coordinate model usage and prompt-driven analysis. The repo supports multiple providers and model roles, with dispatch, routing, scorecards, tool-use loops, and response validation. This is where “analysis” gets converted into structured judgments, but the architecture keeps the model layer separated from the execution and scanning layers.
8. Binary, crash, fuzzing, and exploit paths
The repo has a parallel binary-analysis branch: packages/fuzzing/, packages/binary_analysis/, core/binary/, core/sandbox/, core/smt_solver/, and core/witness/.
- Fuzzing generates corpora, harnesses, telemetry, and crash artifacts.
- Sandbox modules constrain or observe untrusted execution.
- Crash analysis and SMT components turn crashes into feasibility checks and candidate exploit constraints.
- Witness storage captures evidence that links crashes, traces, and exploitability claims.
9. Software composition analysis and supply-chain risk
packages/sca/ is a major subsystem on its own. It scans dependency manifests, lockfiles, container/image metadata, registries, and reachability evidence to produce supply-chain risk judgments. It includes parsers for many ecosystems, resolvers, registries, reachability analysis, version handling, SBOM import/export, suppression logic, and calibration data. This is the repo’s dependency-risk and update-impact pipeline, separate from source-code vulnerability hunting.
10. Historical / forensic / CVE-diff tooling
packages/cve_diff/ and core/cve/ compare known CVE fixes against code and release artifacts. core/coverage/, core/inventory/, core/ast/, core/verified_outcome/, and core/oss-forensics-related tooling support evidence-backed reconstruction of changes, call graphs, and historical states. The architecture supports “before/after” and “what changed?” workflows, not just point-in-time scanning.
11. Security boundary and containment layers
A lot of the repo is dedicated to keeping the framework safe while it analyzes hostile code. core/security/ contains prompt envelope defenses, redaction, environment sanitization, response schema checks, and trust rules. core/sandbox/ adds OS-level isolation, profiling, tracing, seccomp/Landlock/Seatbelt-style controls, and observation modes. These layers sit between external code/binaries and the analysis pipeline.
12. Artifacts, caches, and persistent state
The main data interchange formats are SARIF, JSON, YAML, and project-specific store formats. Persistent and semi-persistent state lives in project workspaces, witness stores, annotation stores, coverage stores, fingerprint caches, and SCA calibration data. The repo also ships large internal corpora under core/dataflow/corpus/, packages/cve_diff/data/, packages/sca/data/, and test/data/, which are used both for regression tests and for validating the analysis methods.
13. External service and tooling dependencies that shape the architecture
The repo integrates with Claude Code, Semgrep, CodeQL, GitHub/GH Archive/Wayback, OCI registries, OSV/NVD, and GitHub Actions. These are not incidental: they define acquisition paths, offline caches, CI workflows, and how findings and vulnerability evidence are sourced. The repo is designed to keep much of this offline once packs/data are cached.
14. Repository boundary as a product platform
Overall, this is a platform with multiple specialized pipelines sharing a common execution substrate. The shared substrate is the Python/core model layer and the command/runtime wrappers; the specialized pipelines are source-code analysis, binary exploitation, supply-chain analysis, forensic reconstruction, and LLM-assisted validation. An architecture diagram should therefore show a central orchestration/runtime backbone feeding several loosely coupled analysis domains, all mediated by security/sandbox controls and converging into a common findings/reporting/project store.
Main entry points: llm_analysis LLM analysis · hypothesis_validation Dataflow validation · run Runtime core · orchestration Orchestration
Components 21
Control plane
Claude Code commands, skills, agents, and personas that drive the agentic workflow.
- Slash commands · Primary user-facing command surface for mantis workflows.
.claude/commands - Skills & agents · Specialist skills and agent prompts for analysis, validation, and reporting.
.claude/skills - Personas · Tiered personas and guidance that shape Claude-driven decisions.
tiers
Python core
Shared execution substrate for orchestration, project state, runtime safety, and reporting.
- CLI entry · Top-level Python launchers and wrappers for the framework.
mantishack.py - Wrappers · Executable shims that route commands into Python packages and tools.
libexec - Runtime core · Core execution backbone for run identity, provenance, safe IO, and orchestration.
core/run - Orchestration · Coordinates analysis passes, reachability enrichment, and understand/validate handoffs.
core/orchestration - Project store · Manages workspaces, merges, diffs, exports, correlations, and project reports.
core/project - Reporting · Console and report rendering for findings and witness evidence.
core/reporting - Security boundary · Prompt, environment, redaction, and trust controls around model and tool use.
core/security - Sandbox · Isolation, observation, and platform-specific execution controls.
core/sandbox
Analysis domains
Specialized pipelines for source, binary, supply-chain, and exploit workflows.
- Scanner layer · Shared scanner orchestration and result normalization for Semgrep, CodeQL, and Coccinelle.
packages/static-analysis - Source analysis · Source-intel discovery, measurement, rendering, and rule-based reasoning for code smells and hazards.
packages/source_intel - Dataflow validation · Findings, barriers, path evidence, and hypothesis validation across scanner outputs.
packages/hypothesis_validation - LLM analysis · Model routing, prompts, scorecards, validation, and agentic reasoning loops.
packages/llm_analysis - Binary paths · Fuzzing, crash analysis, binary understanding, and exploitability support.
packages/fuzzing - Exploit feasibility · SMT- and graph-based feasibility checks, mitigations, and exploit constraints.
packages/exploit_feasibility - SCA pipeline · Supply-chain scanning, reachability, registries, SBOMs, and calibration-driven risk scoring.
packages/sca - CVE diff · Compares fixes, releases, and advisories to reconstruct vulnerability change history.
packages/cve_diff
Policy & data
Rule packs, corpora, calibration data, and persistent evidence stores.
- Evidence stores · Annotations, witnesses, coverage, fingerprints, and cached corpus-like evidence.
core/witness - Rules & corpora · Rule packs, query packs, calibration data, and repository corpora used for validation and regression.
engine/semgrep/rules
Connections 23
- Slash commands → Wrappers: invoke · Slash commands dispatch through executable shims into the runtime.
- Skills & agents → LLM analysis: guide · Specialist agents and skills steer LLM-backed analysis and review loops.
- Personas → LLM analysis: shape · Personas define reasoning style, escalation posture, and review behavior.
- CLI entry → Runtime core: boot · Top-level launchers initialize the shared runtime substrate.
- Wrappers → Orchestration: route · Wrappers route command-specific flows into orchestration passes.
- Orchestration → Project store: persist · Workflow passes write workspaces, diffs, correlations, and exports.
- Orchestration → Dataflow validation: handoff · Findings move from orchestration into evidence-backed validation.
- Runtime core → Security boundary: enforce · Runtime operations are filtered through trust, redaction, and schema defenses.
- Runtime core → Sandbox: contain · Untrusted execution and observation run inside containment layers.
- Scanner layer → Rules & corpora: consume · Scanner behavior is driven by rule packs and cached corpora.
- Scanner layer → Dataflow validation: emit · Scanner outputs are normalized into findings for validation.
- Source analysis → Scanner layer: build on · Source-intel analysis uses scanner results and rule-based context.
- Source analysis → LLM analysis: consult · Some source-intel workflows use model-assisted interpretation and bridging.
- Dataflow validation → Exploit feasibility: refine · Validated findings can be transformed into feasibility and constraint problems.
- LLM analysis → Security boundary: guarded by · Model dispatch and prompt handling are protected by response and envelope controls.
- Binary paths → Sandbox: run in · Fuzzing and crash workflows execute under containment and observation.
- Binary paths → Exploit feasibility: check · Crashes and traces feed exploitability and constraint checks.
- SCA pipeline → Rules & corpora: calibrate · SCA depends on offline data, calibration sets, and ecosystem maps.
- SCA pipeline → LLM analysis: triage · Selected SCA judgments use LLM-assisted review and explanation.
- CVE diff → Rules & corpora: compare · Historical diff workflows rely on corpora, advisories, and fix samples.
- Reporting → Project store: summarize · Reports are assembled from project state and correlated findings.
- Evidence stores → Reporting: source · Witnesses, annotations, and coverage records back rendered reports.
- Evidence stores → Dataflow validation: support · Validation consumes persistent evidence and witness data.