A post-hoc analysis pipeline that goes beyond pass/fail metrics to measure how well an LLM red-team agent attacks a network. It replays an Incalmo action log to reconstruct an oracle attack graph and optimal path, aligns the agent's actual trajectory against that path, and labels every deviation with a failure category (irrelevant, redundant, dead-end, and others). It outputs annotated traces, summary metrics such as path efficiency and waste ratio, and visualizations that show where the agent drifted from optimal behavior.
18-731 Network Security, Carnegie Mellon University, Spring 2026
Karthik Chakkalakal, Christian Wong, Cora Marcet
This repository is a fork of Incalmo, an autonomous LLM-assisted red-teaming system from CMU CyLab (paper). We did not modify Incalmo itself, apart from a small update to the Haiku model name.
Our code lives in optimal_path_analysis/. See that folder's README for full details.
The pipeline runs on a standard Incalmo action_log.jsonl and has three modules:
- Oracle Solver replays every event in the log to rebuild the network as the agent experienced it (hosts, subnets, credentials, CVEs, infection chains), then runs BFS to find the shortest action sequence that exfiltrates all critical data.
- Alignment Engine compares the actual trace to the optimal path with a set-based parallel walk, tagging each step as PRODUCTIVE, DEVIATION or FAILED_EXECUTION. Productive steps taken out of order (e.g. batching phases across hosts) are flagged rather than counted as waste.
- Taxonomy Classifier resolves each non-productive step into IRRELEVANT, FAILED_EXECUTION, REDUNDANT (re-doing completed work, our "frontier decay" signal), DEAD_END or SUBOPTIMAL_ORDERING, using the oracle graph and a running memory of completed actions. When no attack graph can be built (as in the Haiku run), it falls back to coarser labels, using a single SUBOPTIMAL_EXPLORATION label for non-redundant deviations.
Outputs: analysis_report.json, aligned_trace.json, classified_trace.json, summary_report.json, plus a trajectory_timeline.png and an optional side-by-side attack_trajectory.mp4.
We ran the pipeline on two traces from the MHBench EquifaxLarge environment (~50 hosts, 48 goal databases):
| Run | Steps | Goals reached | Path efficiency | Wasted steps |
|---|---|---|---|---|
| Claude Sonnet 4 (sample log from Incalmo) | 156 | 48/48 | 0.942 | 9 (3 irrelevant, 3 redundant, 3 suboptimal ordering) |
| Claude Haiku 4.5 (our run) | 69 | 0/48 | undefined | 69 (33 failed execution, 22 redundant, 14 suboptimal exploration) |
Sonnet's 9 wasted steps all fell in one early block (steps 2–10): it picked the wrong web server, tried lateral moves along invalid edges, and re-scanned a subnet it had already mapped, then ran the remaining 146 steps without deviation. Haiku never exploited the Struts CVE and stalled at lateral movement, so no attack graph could be reconstructed; path efficiency is undefined because the solver found no goals, and the classifier fell back to graph-free labels.
Synthetic validation: we injected 10 known failures into the Sonnet trace, and the pipeline flagged all 10 as non-productive. Some were assigned a different failure category than the one we injected, so this validates detection, not exact categorization.
- Results come from only two runs, in one environment, with one trial per model, so they are suggestive rather than conclusive.
- DEAD_END did not fire in the Sonnet run because every host on EquifaxLarge can re-pivot to a credential-bearing host (the Haiku run had no attack graph, so it could not fire there); it should be more informative on more partitioned networks.
- The checks for FindInformationOnAHost and EscalatePrivilege are permissive: they accept any host with an inbound edge rather than only hosts actually compromised at that point in the trace.
cd optimal_path_analysis python main.py <path/to/action_log.jsonl>
See the folder README for options, outputs and setup.
- Karthik Chakkalakal: most of the pipeline code: the optimal path solver, trace alignment engine, main.py, the animation, and the current versions of the classifier, report and graph scripts; plus the Haiku 4.5 run and the synthetic injection outputs.
- Christian Wong contributed the initial taxonomy classifier and log parser.
- Cora Marcet wrote the first versions of the summary report generator (
generate_report.py, which builds the summary from the classified trace) and the trajectory graph script.
Incalmo is an autonomous AI-driven network penetration testing tool that automatically conducts intelligent red-teaming activities with the aim to enhance and assist operator abilities when performing complex network attack tasks.
Research Paper: On the Feasibility of Using LLMs to Execute Multistage Network Attacks
Website: Visit our website for more information!
- Prerequisites
- Installation
- Usage
- Tech Stack
- Project Structure
- Contributing
- License
- Acknowledgements
- Support
- Docker Desktop - Required for containerized environment
- Python 3.13+ - Required for local development
- uv - Fast Python package installer (recommended) or pip
- LLM API Keys - At least one of the following:
- OpenAI API Key - For GPT models
- Anthropic API Key - For Claude models
- Google API Key - For Gemini models
- DeepSeek API Key - For DeepSeek models
- Node.js (Optional) - Only needed for UI Interface
Create a configuration file by copying the example:
cp config/config_example.json config/config.json
Then edit config/config.json as needed.
Create an environment file by copying the example:
cp .env.example .env
Then add LLM API keys to .env.
Navigate to the docker directory and start the containers:
cd docker
docker compose upIn a new terminal window, attach to the running container and execute Incalmo:
cd docker docker compose exec attacker /bin/bash uv run main.py
If you want to use the web-based interface for Incalmo:
Follow Steps 1 through 3 in the Setup Instructions.
Install Node dependencies:
cd incalmo/frontend/incalmo-ui
npm installOnce dependencies are installed, run the react server:
npm start
This will lauch the frontend at http://localhost:3000
Note: A "strategy" is the logic behind an attack. See the strategies/ folder for examples of llm based attacks and state machine based attacks.
To use an your choice of an LLM-based attack:
-
Follow the setup and then:
-
Specify in
config/config.jsonwhat LLMs to use (list is available in the registry). Use theconfig_example.jsonas a template -
Run
main.pyas described in the setup -
Observe the status of the attack through the logs in the output directory. Your attack will be timestamped and used to name the logs folder
This is the most stable way to test attack.
Incalmo also supports creating non-LLM state-machine strategies. To use a custom (non-LLM/manual) strategy for attacks:
-
Follow the setup and then:
-
Specify in
config/config.jsonwhat manual strategy to use (list is available in strategies/state_machine). Use theconfig_example_state_machine.jsonas a template and fill in the strategy name as the class name. -
Run
main.pyas described in the setup -
Observe the status of the attack through the logs in the output directory. Your attack will be timestamped and used to name the logs folder
-
To create your own basic strategy, create a file in strategies/state_machine as follows:
class YourStrategyName(IncalmoStrategy):
async def step(self) -> bool:
# Your attack/strategy logic
It may be easier to look at examples of existing strategies to understand formatting and strategy abilities
To use the UI:
- Instead of running
main.py, launch the frontend and use the UI to start and stop attacks and observe logs. This is the cleanest/easiest way to observe the attacks in real time
Backend: Python 3.13, Flask, Celery, SQLite
LLM Integration: LangChain, OpenAI, Anthropic, Google Gemini, DeepSeek
Frontend: React, TypeScript, Node.js
Containerization: Docker, Docker Compose
Package Management: uv
Incalmo/
├── .env.example # Template for environment configuration
├── CITATION.cff # Research paper citation metadata
├── LICENSE # MIT License
├── main.py # CLI entry point - runs Incalmo strategy
├── README.md # Project Guide
├── config/ # Configuration management
├── docker/ # Docker containerization
│ ├── attacker/ # Attacker container configuration
│ └── equifax/ # Target environment (Equifax breach simulation)
│ ├── database/ # Database server container
│ └── webserver/ # Web server container
├── incalmo/ # Core application code
│ ├── incalmo_runner.py # Main strategy execution runner
│ ├── server.py # Flask server entry point
│ ├── api/ # Client API for C2 server communication
│ ├── c2server/ # Command & Control server
│ │ ├── agents/ # Agent implementations
│ │ ├── celery/ # Async task queue
│ │ ├── payloads/ # Exploit and deployment payloads
│ │ └── routes/ # Flask blueprints for API endpoints
│ ├── core/ # Core attack framework
│ │ ├── actions/ # Action classes
│ │ │ ├── EmptyServiceActions/ # Placeholder actions
│ │ │ ├── HighLevel/ # High-level actions
│ │ │ │ └── llm_agents/ # LLM-agent action implementations
│ │ │ └── LowLevel/ # Low-level commands
│ │ │ └── privledge_escalation/ # Privilege escalation exploits
│ │ ├── models/ # Core domain models
│ │ │ ├── events/ # Event system for state updates
│ │ │ └── network/ # Network infrastructure models
│ │ ├── services/ # Core logic services
│ │ └── strategies/ # Attack strategies
│ │ ├── llm/ # LLM-based strategies
│ │ ├── state_machine/ # Rule-based strategies
│ │ ├── testers/ # Strategy testing utilities
│ │ └── util/ # Strategy utilities
│ ├── frontend/ # Web interface
│ │ └── incalmo-ui/ # React-based UI
│ └── models/ # Shared data models (Pydantic)
└── output/ # Execution logs and results
Contributions are always welcome! Please raise issues or make PR's if you have ideas on how to improve this project
This project is licensed under the MIT License
To cite this project or paper, check out the Citation specifications
For support, email [email protected]