Architecture Overview
RAPTOR is organized into three main layers:Core Layer
The core layer provides minimal shared utilities that all packages need:RaptorConfig (core/config.py)
Centralized configuration management:
- Single source of truth for all paths
- Environment variable support (
RAPTOR_ROOT) - Graceful fallback to auto-detection
Structured Logging (core/logging.py)
Unified logging with audit trail:
- JSONL format for machine-readable logs
- Console output for human readability
- Timestamped log files (
raptor_<timestamp>.jsonl) - Automatic log directory creation
SARIF Parser (core/sarif/parser.py)
Parses and extracts data from SARIF 2.1.0 files:
parse_sarif(sarif_path)- Load and validate SARIF fileget_findings(sarif)- Extract finding listget_severity(result)- Map SARIF levels to severity
Packages Layer
Design Principles
- One responsibility per package
- No cross-package imports (only import from core)
- Standalone executability (each agent.py can run independently)
- Clear CLI interface (argparse, help text, examples)
Package: static-analysis
Purpose: Static code analysis using Semgrep Main entry point:scanner.py at packages/static-analysis/scanner.py:1
CLI:
- Run Semgrep scans with configured policy groups
- Parse and normalize SARIF outputs
- Generate scan metrics (files scanned, findings count, severities)
semgrep_<policy>.sarif- SARIF 2.1.0 findings per policy groupscan_metrics.json- Scan statisticsverification.json- Verification results
Package: codeql
Purpose: Deep CodeQL analysis with autonomous dataflow validation Main entry point:agent.py at packages/codeql/agent.py:1
Components:
agent.py- Main CodeQL workflow orchestratorautonomous_analyzer.py- LLM-powered CodeQL analysisbuild_detector.py- Automatic build system detectiondatabase_manager.py- CodeQL database creation and managementdataflow_validator.py- Validates dataflow paths from CodeQL resultsdataflow_visualizer.py- Generates visual dataflow diagramslanguage_detector.py- Programming language detectionquery_runner.py- CodeQL query execution
- Automatic language and build system detection
- Multi-language support (Python, Java, C/C++, JavaScript, Go, etc.)
- Dataflow path validation to reduce false positives
- Visual dataflow diagrams for complex taint flows
codeql_*.sarif- CodeQL findings in SARIF formatdataflow_*.json- Validated dataflow pathsdataflow_*.svg- Visual dataflow diagramscodeql_analysis.json- Analysis summary
Package: llm_analysis
Purpose: LLM-powered autonomous vulnerability analysis Main entry points:agent.pyatpackages/llm_analysis/agent.py:1- Standalone analysis (OpenAI/Anthropic compatible)orchestrator.py- Multi-agent orchestration (requires Claude Code)
- Parse SARIF findings
- Read vulnerable code files
- Analyze exploitability with LLM reasoning
- Generate working exploit PoCs (optional)
- Create secure patches (optional)
- Produce analysis reports
- Provider-agnostic (swap OpenAI ↔ Anthropic easily)
- Configurable via environment variables
- Rate limiting and error handling
Package: autonomous
Purpose: Autonomous agent capabilities for planning, memory, and validation Components:corpus_generator.py- Intelligent fuzzing corpus generationdialogue.py- Agent dialogue and interaction managementexploit_validator.py- Automated exploit code validationgoal_planner.py- Goal-oriented task planningmemory.py- Agent memory and context managementplanner.py- Task decomposition and planning
- Goal-oriented planning with LLM reasoning
- Automatic exploit compilation and execution testing
- Context-aware corpus generation for targeted fuzzing
- Persistent memory across agent interactions
Package: fuzzing
Purpose: Binary fuzzing orchestration using AFL++ Main entry point:afl_runner.py at packages/fuzzing/afl_runner.py:1
Components:
afl_runner.py- AFL++ process management and monitoringcrash_collector.py- Crash triage, deduplication, and rankingcorpus_manager.py- Seed corpus generation and management
- Parallel fuzzing support (multiple AFL instances)
- Automatic crash deduplication by signal
- Early termination on crash threshold
- Support for AFL-instrumented binaries and QEMU mode
Package: binary_analysis
Purpose: Binary crash analysis and debugging using GDB Main entry point:crash_analyser.py at packages/binary_analysis/crash_analyser.py:1
Responsibilities:
- Analyze crash inputs using GDB
- Extract stack traces, register states, disassembly
- Classify crash types (stack overflow, heap corruption, use-after-free, etc.)
- Provide context for LLM analysis
- Stack buffer overflows (SIGSEGV with stack address)
- Heap corruption (SIGSEGV with heap address, malloc errors)
- Use-after-free (SIGSEGV on freed memory)
- Integer overflows (SIGFPE, wraparound detection)
- Format string vulnerabilities (SIGSEGV in printf family)
- NULL pointer dereference (SIGSEGV at low addresses)
Package: recon
Purpose: Reconnaissance and technology enumeration Responsibilities:- Detect programming languages
- Identify frameworks and libraries
- Enumerate dependencies
- Map attack surface
Package: sca
Purpose: Software Composition Analysis (dependency vulnerabilities) Responsibilities:- Detect dependency files (requirements.txt, package.json, pom.xml, etc.)
- Query vulnerability databases (OSV, NVD, etc.)
- Generate dependency vulnerability reports
- Suggest remediation (version upgrades)
Package: web
Purpose: Web application security testing Components:client.py- HTTP client wrapper (session management, headers)crawler.py- Web crawler (enumerate endpoints)fuzzer.py- Input fuzzing (injection testing)scanner.py- Main orchestrator (OWASP Top 10 checks)
Analysis Engines
CodeQL Engine (engine/codeql/)
Custom CodeQL query suites and configurations:
suites/- Custom CodeQL query suites for different languages- Query configurations for taint tracking, security patterns, and dataflow analysis
packages/codeql/ for automated CodeQL scanning
Semgrep Engine (engine/semgrep/)
Semgrep rules and configurations:
rules/- Custom Semgrep rules for security patternssemgrep.yaml- Semgrep configuration filetools/- Utilities for rule development and testing
packages/static-analysis/scanner.py for Semgrep scanning
Design rationale: Separating analysis engines from packages allows for centralized rule management and easier rule updates without modifying package code.
Entry Points
raptor.py - Interactive Launcher
Purpose: Interactive launcher with Claude Code integration Features:- Claude Code integration for conversational analysis
- Progressive loading of expert personas from
tiers/ - Slash command support (
/scan,/fuzz,/web,/agentic,/codeql,/analyze,/exploit,/patch) - On-demand loading of specialized guidance
- Session-based workflow management
raptor_agentic.py - Source Code Workflow
Purpose: End-to-end autonomous security testing workflow Workflow:- Phase 1: Scan code with Semgrep
- Phase 2: Analyze findings autonomously
- Phase 3: (Optional) Agentic orchestration with Claude Code
raptor_codeql.py - CodeQL Workflow
Purpose: End-to-end CodeQL analysis with dataflow validation Workflow:- Phase 1: Language and build detection
- Phase 2: CodeQL database creation
- Phase 3: Query execution with custom suites
- Phase 4: Dataflow path validation
- Phase 5: Visual dataflow diagram generation
- Phase 6: LLM exploitability analysis (optional)
raptor_fuzzing.py - Binary Fuzzing Workflow
Purpose: Autonomous binary fuzzing with LLM-powered crash analysis Workflow:- Phase 1: Fuzz binary with AFL++
- Phase 2: Collect and rank crashes
- Phase 3: Analyze crashes with GDB
- Phase 4: LLM exploitability assessment
- Phase 5: Generate exploit PoC code
Output Structure
All outputs are centralized inout/:
Import Patterns
Packages only import from core, never from each other:LLM Quality Considerations
Exploit Generation Requirements
RAPTOR’s exploit generation capabilities vary significantly based on the LLM provider:| Provider | Analysis | Patching | Exploit Generation | Cost per Crash |
|---|---|---|---|---|
| Anthropic Claude | Excellent | Excellent | Compilable C code | ~£0.01 |
| OpenAI GPT-4 | Excellent | Excellent | Compilable C code | ~£0.01 |
| Ollama (local) | Good | Good | Often non-compilable | Free |
Technical Requirements for Exploit Code
Generating working exploit code requires capabilities that distinguish frontier models from local models: Memory layout understanding:- Precise knowledge of x86-64/ARM stack structures
- Correct register usage and calling conventions
- Understanding of heap allocator internals (glibc malloc, tcache)
- Valid x86-64/ARM assembly encoding
- Correct escape sequences (e.g.,
\x90\x31\xc0not\T) - NULL-byte avoidance for string-based exploits
- System call number correctness
- ROP chain construction with valid gadget addresses
- Stack pivot techniques for limited buffer sizes
- ASLR leak construction and information disclosure
- Heap feng shui for use-after-free exploitation
Recommendations
For production exploit generation:For security research where working exploits are required, the nominal cost of frontier models (£0.10-1.00 per binary) is justified by the quality of output.