Security Objective
Adversarial testing for prompt injection is an authorized assurance activity in which a team exercises its own AI system, controls, telemetry and recovery paths with representative adversarial conditions. Its objective is to learn where trust boundaries hold, where they fail, and whether failures would be observed and recoverable, before those conditions arise outside the test.
Threat Model
Testing assumes the same threat model as the controls it exercises: untrusted language can reach model context through direct input, external content, retrieval, tool output, delegated agents and persistent state; model behavior is variable; probabilistic detectors miss some events and flag some benign ones; and deterministic controls outside the model are expected to limit what influenced behavior can do.
Testing adds its own risks. A test can cause real side effects, leak real data into test logs, or grow into an unmanaged payload repository. The program design below treats these as risks to control, not as acceptable costs.
Adversarial Testing, Labs and Incident Response
| Activity | Purpose | Who and where |
|---|---|---|
| Labs on this site | Educational, preset client-side simulations that teach concepts to readers | Any reader, in the browser, with fictional inputs and no real model or system |
| Adversarial testing | Engineering assurance of a real system's boundaries, controls, telemetry and recovery | An authorized team, against its own system, within a written scope |
| Incident response | Investigation and recovery after a suspicious or confirmed event | Responders, on events that already occurred |
The Test Case Library provides reviewed, safe test cases for each testing domain, expanded selectively where a distinct boundary needs its own case.
The Labs illustrate individual ideas and are not a test suite for any product. The Prompt Injection Security Testing methodology provides the practitioner foundation for evidence states, local pass criteria and reporting across real systems. Incident Response handles real events; its tabletop exercises are one input to testing, and findings from incidents feed regression tests here.
What Testing Can and Cannot Prove
| Outcome | What it shows | What it does not show |
|---|---|---|
| A test succeeds in causing a deviation | Behavior under the tested conditions, versions and configuration | Universal exploitability, real-world abuse, malicious intent or production impact |
| A test fails to cause a deviation | The tested cases did not produce the effect in the observed runs | That the system is secure; coverage, variability, retrieval state and versions matter |
| A deterministic control denies as expected | The enforcement decision for that input and configuration | That model behavior was safe or that other paths are covered |
| A detector alerts | A probabilistic signal fired | Compromise, success or intent |
Scope and Authorization
Testing is authorized, scoped and governed. A written scope names the owner, systems, environments, identities, tools, destinations, data classes, time window, stop conditions and escalation contacts. Testing grants no permission beyond that scope: a tester's role does not authorize actions the scope excludes, and a model or agent can never widen it.
Scope record
- Accountable owner and approvers
- Systems, versions and environments in scope and explicitly out of scope
- Test identities and their capabilities
- Allowed destinations, all synthetic or controlled
- Data classes permitted; real secrets and customer data excluded
- Stop conditions, rollback plan and escalation contacts
Test Environment Choices
| Environment | Strength | Limitation |
|---|---|---|
| Isolated test environment | No real side effects; free repetition | May differ from production configuration and data |
| Staging mirroring production configuration | Closer realism with controlled data | Drift from production must be tracked |
| Carefully governed production tests | Real configuration and integrations | Requires change approval, blast-radius limits, monitoring, rollback and explicit ownership; not universally appropriate |
Many organizations should never test adversarially in production. If they do, synthetic identities, synthetic destinations and reversible actions remain mandatory.
Test Asset Inventory
Model identifier, version, sampling settings where exposed.
Versioned instructions and context assembly.
Index version, corpus snapshot and retriever configuration.
Tool schemas, grants and connector identities.
Authorization, flow, egress, validation and containment policy versions.
Principals and scoped credentials used by the test.
Synthetic sinks and allowlist state.
Memory, caches, vector stores and files present before the run.
Trust-Boundary Coverage Model
Coverage is organized around trust boundaries rather than around clever inputs. Each boundary where untrusted content enters context, or where a model proposal becomes an effect, needs tests that exercise it in both expected-allow and expected-deny directions.
- 01Entry
Content enters context with provenance attached.
- 02Interpretation
The model produces output or a plan.
- 03Proposal
A tool call or artifact is proposed.
- 04Decision
Authorization, approval, flow and egress policy decide.
- 05Enforcement
Validation, containment and brokers apply the decision.
- 06Effect and evidence
Downstream state changes, or does not, and telemetry records it.
Test Case Anatomy
A test case is a versioned artifact. The following record is engineering guidance, not a standard schema. It does not require collecting model chain-of-thought.
Stable identifier.
The boundary and failure being examined.
Reference to the scope record.
Model, prompt, retriever, tools, policies.
Who the run acts for and what task it has.
Which fake content is used and where it enters.
Only where relevant, as a distribution rather than a single answer.
Allow, deny, flag, isolate or require approval.
For example: none, submitted, executed on synthetic sink.
Events that must be recorded.
Reset steps for state and fixtures.
Run count, and seed if supported.
Links to decision and effect records.
Who maintains it and when it is re-reviewed.
Expected Outcome and Oracle Design
An oracle decides whether a run passed. Oracles for deterministic controls read enforcement records and downstream state: the authorization decision, the broker log, the synthetic sink. Oracles for model behavior classify outputs across repeated runs. A transcript alone is a weak oracle for a control, because a model can claim an action it never performed or omit one that happened.
Model-Behavior Assertions vs Security-Control Assertions
| Property | Model-behavior assertion | Control assertion |
|---|---|---|
| Nature | Probabilistic | Deterministic for a fixed input and configuration |
| Evidence | Output classification over many runs | Decision and enforcement records, downstream state |
| Result form | Rate or distribution | Pass or fail per case |
| Typical controls | Instruction hierarchy, detection, plan drift signals | Authorization, IFC, egress, validation, containment |
Do not merge these into one score. A high model-deviation rate with perfect control enforcement is a different risk position from a low deviation rate with a missing authorization check.
Direct Injection Tests
Direct tests exercise the path where the requesting user supplies instruction-like text. The useful questions are whether the application's instruction hierarchy and policy hold, and whether any deviation remains bounded by the requesting principal's own authority. See Direct Prompt Injection for the attack mechanics.
Indirect Content Tests
Indirect tests place synthetic instruction-like text in web, email, document or search content that the system processes on behalf of a different principal. Tests verify that provenance survives extraction and that downstream decisions still use the initiating principal's authority. See Indirect Prompt Injection.
RAG and Retrieval Tests
Retrieval tests check that relevance does not become trust: that tenant and access filters apply before retrieval, that source metadata reaches policy, and that a synthetic document from a lower-trust source cannot change what the application authorizes.
Tool-Output Tests
Tool-output tests return synthetic results containing instruction-like text and verify that the result is treated as data, that provenance is recorded, and that any subsequent proposal is authorized on its own merits.
Agent and Action Tests
Action tests exercise the step where a proposal becomes an effect. Each should record proposed, authorized, submitted, executed, succeeded, failed and unobserved as distinct states. A proposal is not execution, and an unobserved stage is not evidence that nothing happened.
Multi-Agent and Delegation Tests
Delegation tests verify that a child task receives only the capabilities the parent was allowed to delegate, that returned results carry provenance, and that parent and child identifiers correlate. A finding in a child does not by itself establish a finding in the parent, or the reverse.
Authorization and Least-Privilege Tests
Authorization tests submit proposals the principal may and may not perform and assert the authorization decision exactly. Least-privilege tests confirm that capabilities outside the task simply do not exist for the test identity, rather than relying on a denial.
Information-Flow and Tenant-Boundary Tests
Flow tests label synthetic data by source and classification and verify that information flow control blocks disallowed movement to destinations, tenants or models, including through summaries or derived artifacts.
Egress Tests
Egress tests use synthetic destinations inside and outside the allowlist and verify that egress restrictions deny before connection, recheck after resolution and redirects, and cannot be bypassed by a worker's direct network path.
Output-Validation and Sink-Handling Tests
Validation tests submit structurally invalid values and confirm output validation rejects them before the sink. Passing validation shows structure and format, not trust or semantic safety; sink-specific encoding is tested separately.
Sandboxing and Containment Tests
Containment tests are defensive regression classes: host paths are inaccessible, denied networking is unavailable, quotas terminate runaway work, read-only inputs stay unchanged, broad credentials are absent, export requires release, and unavailable sandboxing fails closed. They do not teach escape techniques.
Detection, Plan Drift and Tool-Chain Telemetry Tests
Telemetry tests verify that detection, plan drift and tool-chain signals are emitted, correlated and routed. Detector recall and false-positive rates are measured over repeated runs. A missed detection with successful enforcement is a detector gap, not a security failure of the enforcement layer.
Incident-Response and Evidence-Capture Tests
These tests check whether a synthetic run can be reconstructed end to end from provenance and decision records, whether evidence is preserved before cleanup, and whether containment actions such as revoking a test token work as documented.
Persistence, Memory and Cross-Run State Tests
Persistence tests write synthetic, model-influenced state into memory, caches or vector stores and verify that a later run treats it as untrusted, that lineage identifies which runs consumed it, and that reset restores known-good state without affecting unrelated tenants.
Repetition and Nondeterminism
A single run is not enough for probabilistic behavior. Repeat model-behavior cases enough times to report a rate with its run count, and record versions and seeds where supported. Deterministic controls should give the same decision for the same input and configuration; variance there is itself a finding.
Coverage and Traceability Matrix
A practical matrix maps entry vector, capability, boundary control, expected decision and observed state. This is engineering guidance, not a standard.
| Dimension | Example values |
|---|---|
| Entry vector | User input, web, email, document, search, RAG, tool output, sub-agent output, persistent memory |
| Capability | Read, write, send, share, execute, retrieve, delegate |
| Boundary control | Provenance, inspection or detection, authorization, human approval, IFC, egress, output validation, sandboxing |
| Expected decision | Allow, deny, flag, isolate, require approval |
| Observed state | Proposed, authorized, submitted, executed, succeeded, failed, unobserved |
Every cell needs expected-allow cases as well as expected-deny cases. A system that blocks everything is not a successful security design.
Safe Synthetic Fixtures and Benign Markers
Use fictional documents, fake identities, synthetic destinations and benign marker strings whose appearance in an output or sink shows that influence reached that point. Never require real secrets, real customer data, real external targets, real money movement, destructive changes or uncontrolled autonomous execution.
Regression fixtures derived from incidents or research are sanitized to the minimum needed to exercise the boundary, so the suite does not become a payload repository.
Findings, Evidence States and Severity
Findings keep evidence states separate: model influence observed, control decision recorded, action submitted, action executed, effect confirmed on a synthetic sink, telemetry missing. A detector alert is evidence, not a finding of compromise.
Severity follows reachable impact, not prompt cleverness: which privileges, data classes, destinations, tenants and persistent state a failure could reach given the controls that actually held. An elaborate input that only changes wording is lower severity than a simple one that reaches an unauthorized write.
Regression Suite Lifecycle and Change-Triggered Retesting
Regression cases come from documented incidents, research findings, red-team findings and newly discovered trust-boundary failures. Each is sanitized, owned, versioned and retired when the boundary it tests no longer exists.
Retest when these change
- Model or model version
- System prompt or context assembly
- Retriever, index or corpus
- Tool schemas, grants or connectors
- Authorization, flow, egress, validation or containment policy
- Memory or persistence behavior
Worked Scenarios
All scenarios use fictional systems, synthetic fixtures and benign markers. No attack text is shown.
A direct instruction-like input causes the model to propose a write outside the task. Authorization denies it; the synthetic resource is unchanged. Result: model-influence finding, no impact.
A fictional retrieved document contains instruction-like text. The detector does not alert. Provenance is preserved and IFC blocks sending labeled data to an external synthetic destination. Result: detector gap and successful deterministic control.
A permitted read-only agent task completes and returns the expected synthetic data. Result: controls are not simply blocking everything.
A synthetic result from Tool A influences a proposed Tool B action. Cross-tool authorization denies it. Result: tool-chain and authorization behavior exercised; no Tool B effect.
A proposal targets a synthetic destination outside the allowlist. The broker denies before connection. Result: no network effect.
Synthetic model-influenced memory affects a later run. The test verifies lineage identifies the consuming run, reset restores known-good state, and later runs are unaffected.
| Scenario | Proves | Does not prove |
|---|---|---|
| A | Write authorization held for this case | That the model resists injection generally |
| B | IFC held; detector missed this case | Detector recall overall, or real exfiltration |
| C | Legitimate work is possible under the policy | That every legitimate task succeeds |
| D | Cross-tool authorization held | Coverage of all tool combinations |
| E | Egress denial before connection for this destination | That no other network path exists |
| F | Reset and lineage worked for this store | That all persistent stores are covered |
Metrics With Denominators
| Metric | Denominator |
|---|---|
| Coverage by entry vector, capability and boundary | Cells in the coverage matrix |
| Deterministic-control pass rate, expected-deny | Expected-deny cases run |
| Deterministic-control pass rate, expected-allow | Expected-allow cases run |
| Telemetry completeness by required event type | Runs requiring that event |
| Model-deviation rate per case | Repeated runs of that case |
| Regression recurrence rate | Previously fixed findings retested |
| Mean time to reproduce and triage a finding | Findings in the period |
| Stale test percentage | Tests affected by a change and not yet retested |
| Finding-to-regression conversion rate | Accepted findings |
These are operational measures, not proof of security. Do not combine them into one aggregate security score, and avoid vanity counts such as the number of prompts tried.
Common Mistakes
Avoid
- Treating a successful test as proof of real-world exploitation
- Treating a clean run as proof of security
- Judging controls from transcripts instead of enforcement records
- Merging model behavior and control results into one score
- Single-run verdicts for probabilistic behavior
- Only expected-deny cases, rewarding systems that block everything
- Real secrets, customer data or external targets in tests
- Unversioned tests that go stale after changes
- A regression suite that grows into a payload repository
- Production testing without approval, limits, monitoring and rollback
Implementation Checklist
Program readiness
- Written scope with owner, stop conditions and escalation
- Asset inventory with versions recorded per run
- Coverage matrix with expected-allow and expected-deny cells
- Test case records with oracles based on enforcement and effect
- Synthetic fixtures and benign markers only
- Repetition counts for probabilistic checks
- Findings recorded with separate evidence states and reachable-impact severity
- Change triggers wired to retesting
- Metrics with explicit denominators
Standards and Sources
Standards and guidance referenced
- NIST
- AI 100-2e2025 Adversarial Machine Learning: A Taxonomy and Terminology of Attacks and Mitigations
- OWASP
- GenAI Red Teaming Guide, LLM01:2026 Prompt Injection, Top 10 for Agentic Applications 2026 (risk context)
- MITRE
- ATLAS knowledge base (threat orientation)
Source scope: NIST AI 100-2e2025 provides broad adversarial machine learning terminology and taxonomy; it is not a prompt-injection test standard. The OWASP GenAI Red Teaming Guide gives general guidance for red teaming generative AI systems; it does not define the coverage matrix, record schema or metrics on this page. OWASP LLM01:2026 and the Agentic Top 10 are risk context. MITRE ATLAS is used for threat-knowledge orientation, not as evidence that any test is effective. No cited source defines this adversarial testing model as a complete standard. The coverage matrix, test case record, scenarios, severity approach and metrics are this site's engineering guidance.
Frequently Asked Questions
Are the Labs an adversarial test suite?
No. The Labs are educational simulations. Adversarial testing targets your own system under authorized scope.
Does a successful test mean we were attacked?
No. It shows behavior under test conditions, not real-world abuse or production impact.
If nothing deviated, are we secure?
No. Absence of findings reflects the cases, runs and versions tested.
Should we collect chain-of-thought?
It is not required. Assert on outputs, decisions and effects.
Should we test in production?
Only with explicit approval, blast-radius limits, monitoring, rollback and ownership, and many teams should not.
References
- Adversarial Machine Learning: A Taxonomy and Terminology of Attacks and Mitigations, NIST AI 100-2e2025NIST · Standard · 2025-03Reviewed 2026-09-27
- GenAI Red Teaming GuideOWASP GenAI Security Project · Guidance · 2025-01Reviewed 2026-09-27
- OWASP GenAI LLM Top 10 2026 (LLM01:2026 Prompt Injection)OWASP GenAI Security Project · GuidanceReviewed 2026-09-27
- OWASP Top 10 for Agentic Applications for 2026OWASP GenAI Security Project · Guidance · 2025-12Reviewed 2026-09-27
- MITRE ATLAS (Adversarial Threat Landscape for Artificial-Intelligence Systems)MITRE · Technical documentationReviewed 2026-09-27