National Cyber Warfare Foundation (NCWF)login

agent-opfor for adversary emulation against AI agents and MCP servers


0 user ratings
2026-10-27 01:32:08
milo
Red Team (CNA)
"agent-opfor

agent-opfor runs automated red-team campaigns against LLM applications, AI agents, and MCP servers, mapping results to OWASP suites for authorized security teams.








ToolKeyValueSoftwareSystems/agent-opfor — open-source adversary emulation framework for AI agents, LLM apps, and MCP servers
CategoryAI red-teaming / automated security testing (TypeScript)
Primary UseAuthorized security assessment of your own AI agents via OWASP-mapped suites (owasp-llm-top10, owasp-agentic-ai, owasp-mcp-top10) using CLI, browser extension, MCP server, or SDK
Safe UseFor authorized assessments of systems you own or have written permission to test — internal pre-release red-teaming, CI/CD security gates, and defensive research on your own deployed agents
Telemetry NoteDefenders observe it as a burst of multi-turn adversarial prompts against the target endpoint; every attack prompt, request, response, and judge verdict is logged locally under .opfor/reports/, making runs fully auditable by the blue team

agent-opfor — OPFOR, short for Opposition Force, the military unit that plays the enemy in training — is an open-source adversary emulation framework from KeyValueSoftwareSystems that red-teams AI agents, LLM applications, and MCP servers. Written in TypeScript and sitting at 578 stars, it is the product of a consultancy that reportedly shipped 130 products for 90 startups and hit the same AI-testing wall on every engagement. The premise is straightforward: to defend AI agents better, you have to attack them first, in a controlled and authorized setting.


What distinguishes opfor from the crowd of prompt-probe libraries is breadth of surface. Rather than testing only the model endpoint, it targets the full agentic stack: prompts, tool calls, MCP endpoints, memory, and multi-turn reasoning state. It generates targeted attacks mapped to the owasp-llm-top10 (2025), owasp-agentic-ai, owasp-mcp-top10 (2025), and owasp-api suites — plus an eu-ai-act-bias suite covering age, gender, race, and disability bias — fires them at the target, and has an LLM judge classify each response with pass/fail and reasoning.


The execution pipeline is documented clearly. A run first fetches target info, connecting to the agent and detecting available tools, MCP endpoints, and capabilities. It then plans attacks per category, emulates them as real multi-turn adversarial conversations, evaluates responses with the LLM judge, and generates reports in both HTML for browsing and JSON for CI/CD. Each run lands in its own subfolder under .opfor/reports/run-report---/, and the README stresses that nothing is a black box: every attack prompt, request, response, and verdict is logged, making results reproducible, auditable, and forkable.


Installation is the standard npm path: npm install -g @keyvaluesystems/agent-opfor-cli, followed by exporting a provider key such as OPENAI_API_KEY or ANTHROPIC_API_KEY. From there, opfor run triggers a one-shot wizard-plus-scan, or opfor setup saves a reusable config to .opfor/configs/ that you can commit to CI and invoke with opfor run --config .opfor/configs/. Note that the CLI consumes an API key for the attacker and judge models — those are opfor's own calls, separate from your target's inference spend.


Five entry points share the same evaluators, attack templates, and judge logic: the CLI for engineers and CI/CD, a Chrome browser extension for non-developers, an MCP server mode for AI coding agents in Cursor or Claude Desktop, IDE slash-command skills like /opfor-run, and an SDK (@keyvaluesystems/agent-opfor-sdk) exposing run and hunt programmatically. The browser extension is the interesting democratization move: product managers, designers, and QA can open any chat interface, click the icon, pick a suite, and watch the extension auto-detect the interface, send attack prompts as if typed, and download an HTML report. In an authorized context this means the people closest to product behavior can participate in security testing.


The owasp-mcp-top10 coverage deserves attention from anyone deploying Model Context Protocol infrastructure. The README lists secret exposure, scope escalation, tool description injection, and SSRF among the evaluator focus areas — exactly the failure modes that emerge when agents dynamically bind to third-party tool servers. The owasp-agentic-ai suite targets excessive agency, tool misuse, agent goal hijack, and memory poisoning, which are multi-turn problems that single-prompt jailbreak checkers structurally miss.


Trace-aware testing is the most architecturally significant feature. Through a telemetry config block, opfor integrates with Langfuse and Netra so the LLM judge sees every tool call, retrieval, and intermediate reasoning step — not just the final response. The README's examples of what this catches are persuasive: PII leaking into a tool call that never reaches the user, MCP scope escalations that don't change the response text, agents retrieving unauthorized data while rendering a clean reply. Input/output-only testing is blind to all three.


The autonomous mode, opfor hunt, skips the config file entirely: give it an --endpoint and an --objective, and a multi-agent system — commander, operators, scout — runs an adaptive campaign of recon, strategy, multi-turn probing, and reporting. Notably, the hunt agents run on Claude only (via API key, claude setup-token, or local claude login), while the target can be anything. A --ui flag renders the attack tree live. For authorized internal use this is a genuine force multiplier; it is also the feature that most demands a clear scope agreement before invocation.


Cost accounting is unusually honest for this category. Every run reports instrumented token usage and spend, broken down by model, with prices sourced from a snapshot of LiteLM's public price map shipped in the package so re-renders are deterministic. The README spells out its own caveats: caching is only credited when the provider reports it (over-estimating rather than under-reporting), unknown models are marked unpriced and the total labeled a lower bound, and a few helper calls — trace curation, session summarisation, one JSON helper — are not yet metered. The per-model split often shows the judge as the dominant cost, and pointing it at a cheaper model is flagged as the easiest saving.


Operationally, defenders should understand what opfor looks like from the target side: a high-volume burst of structured, multi-turn adversarial prompts against a chat or MCP endpoint, with repeated conversation prefixes that exploit provider prompt caching. Because all artifacts are logged locally under .opfor/reports/, red and blue teams can reconcile runs exactly — a property that makes it suitable as a regression gate in CI/CD rather than just a point-in-time assessment tool.


Caveats: the license badge reads Apache 2.0 while the metadata reports NOASSERTION, so verify before commercial redistribution. And the browser extension's ability to fire attacks at any open chat interface is precisely the capability that must stay inside an authorization boundary — it should never be pointed at systems you do not own. Used as intended, against your own agents in labs, staging, and pre-release pipelines, agent-opfor is one of the more complete OWASP-mapped AI security testing frameworks currently open-sourced.



Official project repository for KeyValueSoftwareSystems/agent-opfor.

Download Tool

Educational analysis for authorized security professionals. Use only in controlled, authorized environments.






Source: OffensiveSec
Source Link: https://www.offsecblog.com/2026/10/agent-opfor-for-adversary-emulation.html


Comments
new comment
Nobody has commented yet. Will you be the first?
 
Forum
Red Team (CNA)



Copyright 2012 through 2026 - National Cyber Warfare Foundation - All rights reserved worldwide.