Methodology
Advanced
AML.T0051

AI Application Pentest Methodology

Treat AI features like distributed systems with probabilistic decision points. The test target is not only the model: it is the prompt chain, retrieval layer, permission model, gateway, observability stack, and the business process that trusts the output.

Use the planner first

Start with the planner below to create a scoped test plan, then refine it against the client's architecture and rules of engagement.
AI engagement planner

Build a scoped AI test plan in seconds

Select the system shape and generate a practitioner checklist mapped to OWASP LLM, MITRE ATLAS, evidence, and report deliverables.

Checks
12
Evidence
Required
Output
Markdown
01 Scoping

Document model/provider, user roles, data classes, tool permissions, allowed tests, and explicit no-go actions before testing begins.

Rules of engagement addendum, architecture sketch, permission inventory.

OWASP LLM01OWASP LLM07
02 Prompt injection

Test direct and indirect instruction conflicts across user input, retrieved content, files, tickets, web pages, and third-party connectors.

Prompt, source content, model response, guardrail behavior, impact notes.

OWASP LLM01MITRE ATLAS AML.T0051
03 Abuse-case execution

Run at least one end-to-end authorized abuse path that starts with adversarial input and reaches an unsafe answer, data exposure, permission decision, or attempted tool action.

Abuse-case objective, fixture data, model context, response, downstream effect, and business-impact statement.

OWASP LLM01OWASP LLM05OWASP LLM06
04 Regression pack

Convert accepted findings into repeatable evals with expected safe behavior, owner, severity, and rerun instructions.

Prompt/eval file, fixture IDs, scoring rule, model version, prompt version, pass/fail output.

OWASP LLM09OWASP LLM10
05 Output handling

Verify that generated output cannot trigger unsafe rendering, hidden links, credential disclosure, or automated downstream actions.

Rendered output capture, sanitizer behavior, blocked content examples.

OWASP LLM02OWASP LLM05
06 Monitoring

Confirm prompts, retrieval hits, tool calls, approvals, and high-risk denials are logged with enough context for incident response.

Log samples, alert rules, retention policy, privacy notes.

OWASP LLM10
07 Retrieval boundaries

Test cross-tenant retrieval, document-level ACLs, stale index entries, poisoned chunks, and citation integrity.

Corpus sample, retrieval trace, denied-document test, citation diff.

OWASP LLM02OWASP LLM06OWASP LLM08
08 RAG abuse paths

Seed harmless poisoned documents, cross-tenant canaries, stale index records, and citation-laundering fixtures to prove retrieval trust-boundary failures.

Document ID, chunk ID, retrieval score, source ACL, answer text, citation comparison, and canary result.

OWASP LLM01OWASP LLM02OWASP LLM08
09 Knowledge ingestion

Review upload, crawl, sync, and connector paths for malicious instructions, hidden text, metadata injection, and unsafe file parsing.

Ingestion path map, sample poisoned document, sanitizer output.

OWASP LLM03MITRE ATLAS AML.T0046
10 Read scope

Confirm read tools cannot access secrets, unrelated tenants, local credential stores, or out-of-scope repositories.

Allowlist, denied read tests, data-boundary notes.

OWASP LLM06
11 Confidentiality

Prefer local or approved enterprise endpoints, redact secrets before prompts, and record exactly where client data is processed.

Data-flow record, redaction examples, approved endpoint list.

OWASP LLM06OWASP LLM10
12 Hybrid routing

Verify sensitive prompts route only to approved local/private endpoints and fallback behavior does not leak data to public providers.

Routing policy, fallback test, denied external call.

OWASP LLM06OWASP LLM07

What you'll be able to do

  • Write an AI rules-of-engagement addendum with test classes, tool-use boundaries, and stop conditions
  • Map the AI attack surface across prompts, retrieval, tools, memory, gateways, approvals, logs, and output consumers
  • Convert OWASP LLM, MITRE ATLAS, business flows, and tool permissions into testable hypotheses
  • Execute tests in low-risk order against controlled fixtures
  • Preserve full evidence and define fix-validation criteria for every finding

Assessment Phases

1. Scope and data rules

Document AI features, model/provider, data classes, allowed test types, prohibited actions, and evidence handling.

2. Architecture mapping

Map users, prompts, retrieval, memory, tools, model gateways, output sinks, logging, and approval gates.

3. Abuse case design

Convert OWASP LLM, MITRE ATLAS, business flows, and tool permissions into testable hypotheses.

4. Controlled execution

Run tests in low-risk order: prompt conflicts, retrieval boundaries, tool abuse, tenant isolation, output handling, and monitoring.

5. Evidence and retest

Preserve prompts, traces, screenshots, logs, control behavior, business impact, and fix validation criteria.

AI application pentest methodology - the five assessment phases, with retest feeding back into abuse-case design

The five assessment phases - scope and data rules, architecture mapping, abuse-case design, controlled execution, and evidence/retest - joined left to right, with a dashed retest-after-fix edge returning from evidence back to abuse-case design.

Scroll sideways to see the whole diagram

Minimum Test Matrix

AreaWhat to testProof to collect
Prompt layerDirect, indirect, multi-turn, role conflict, and hidden instruction handling.Prompt, context, response, refusal or bypass trace.
RetrievalChunk poisoning, ACL filters, stale index entries, source ranking, and citation integrity.Retrieved chunks, scores, source IDs, user role.
Tools and agentsTool allowlists, argument validation, approval gates, memory persistence, sandbox escape paths.Tool manifest, approval logs, blocked calls, sandbox policy.
Model gatewayTenant isolation, abuse throttling, provider fallback, prompt/version pinning, sensitive-output controls.Gateway config, request IDs, rate-limit results, version record.
OperationsLogging, alerting, incident response, privacy retention, data minimization, and human handoff.Log samples, alert rule, retention setting, escalation workflow.

Client Deliverables

AI RoE addendum

Allowed models, providers, test classes, tool-use boundaries, evidence restrictions, and emergency stop conditions.

AI attack-surface map

Trust boundaries for prompts, retrieval, tools, memory, gateways, human approval, logs, and output consumers.

Regression pack

A small set of reproducible prompts, fixtures, and expected outcomes that validate fixes after model or prompt changes.

Quality bar

A strong AI finding includes the exact user role, source content or fixture, model/prompt version, retrieved context, tool-call trace if applicable, observed business impact, and the control that should have stopped it.

Setup and Prerequisites

  • Scoped plan: create a scoped test plan in the planner above, then refine it against the client's architecture and rules of engagement.
  • Fixture pack: the fixture pack at /labs/offensive-ai (docker-compose.yml, app/, fixtures/, scripts/) for controlled execution.
  • Runtime: Docker + Docker Compose, or Python 3.11+ to run the app directly with python -m app.server.
  • Working directory: run every command from inside the pack directory; the lab client is python scripts/lab.py.
lab-start.sh
docker compose up -d
python scripts/wait_for_health.py

Expected output

The container starts and the health check prints a healthy body whose marker is OAI-TOYAPP-HEALTHY.

Steps

  1. Document AI features, model/provider, data classes, allowed test types, prohibited actions, and evidence handling in an AI RoE addendum.

    roe-addendum.md
    # AI RoE addendum — fill every heading before testing.
    # Allowed models, providers, test classes, tool-use boundaries,
    # evidence restrictions, and emergency stop conditions.
    ## Allowed models
    ## Allowed providers
    ## Allowed test classes
    ## Prohibited actions
    ## Tool-use boundaries
    ## Evidence restrictions
    ## Emergency stop conditions

    Expected output

    Allowed models, providers, test classes, tool-use boundaries, evidence restrictions, and emergency stop conditions are all named before testing starts.
  2. Map users, prompts, retrieval, memory, tools, model gateways, output sinks, logging, and approval gates onto the trust boundaries.

    attack-surface-map.md
    # AI attack-surface map — trust boundaries for each area.
    ## Prompts
    ## Retrieval
    ## Tools
    ## Memory
    ## Gateways
    ## Human approval
    ## Logs
    ## Output consumers

    Expected output

    Trust boundaries exist for prompts, retrieval, tools, memory, gateways, human approval, logs, and output consumers.
  3. Convert OWASP LLM, MITRE ATLAS, business flows, and tool permissions into testable hypotheses.

    abuse-case.md
    # Abuse case — one testable hypothesis per file.
    surface: prompt-layer | retrieval | tools-agents | model-gateway | operations
    control: the control this case should trip
    expected: the observable result that proves impact
    evidence: prompt, context, response, refusal or bypass trace

    Expected output

    Each hypothesis names its surface, the control it should trip, the expected observable result, and the evidence to collect.
  4. Run tests in low-risk order — prompt conflicts, retrieval boundaries, tool abuse, tenant isolation, output handling, and monitoring — starting with a fixture health check.

    controlled-execution.sh
    python scripts/lab.py health

    Expected output

    The fixture answers healthy with marker OAI-TOYAPP-HEALTHY; higher-risk phases only start after the low-risk ones pass.
  5. Preserve prompts, traces, screenshots, logs, control behavior, business impact, and fix validation criteria in a regression pack.

    regression-pack.json
    {
      "prompts": ["reproducible prompt, pinned to a prompt version"],
      "fixtures": ["fixture name and hash"],
      "expected_outcomes": ["expected observable result per prompt"]
    }

    Expected output

    A small set of reproducible prompts, fixtures, and expected outcomes that validate fixes after model or prompt changes.

Verify It Worked

Check Expected Where to look
AI RoE addendum names the boundaries Allowed models, providers, test classes, tool-use boundaries, evidence restrictions, and emergency stop conditions The engagement file
Attack-surface map covers every boundary Prompts, retrieval, tools, memory, gateways, human approval, logs, and output consumers each listed The attack-surface map document
Regression pack reproduces the findings Reproducible prompts, fixtures, and expected outcomes that validate fixes after model or prompt changes The regression pack directory
Each finding meets the quality bar Exact user role, source content or fixture, model/prompt version, retrieved context, tool-call trace, business impact, and the control that should have stopped it The finding record

Evidence and Findings

Finding Proof Control
Missing AI RoE boundaries No documented test classes, tool-use limits, or stop conditions for the engagement. AI RoE addendum before testing.
Unmapped AI attack surface Prompts, retrieval, tools, memory, gateways, approvals, logs, or output consumers lack trust boundaries. AI attack-surface map.
Finding without reproduction Missing user role, source fixture, model/prompt version, retrieved context, or tool-call trace. Quality-bar evidence bundle plus a regression pack.

Common Mistakes

Testing without a written AI RoE addendum

Document AI features, model/provider, data classes, allowed test types, prohibited actions, and evidence handling first: allowed models, providers, test classes, tool-use boundaries, evidence restrictions, and emergency stop conditions.

Skipping the architecture map

Map users, prompts, retrieval, memory, tools, model gateways, output sinks, logging, and approval gates before designing abuse cases.

Running high-risk tests first

Run tests in low-risk order: prompt conflicts, retrieval boundaries, tool abuse, tenant isolation, output handling, and monitoring.

Reporting without retest criteria

Preserve prompts, traces, screenshots, logs, control behavior, business impact, and fix validation criteria — a strong AI finding includes the exact user role, source content or fixture, model/prompt version, retrieved context, tool-call trace if applicable, observed business impact, and the control that should have stopped it.