# Defensive exploit catalogue for agent harnesses

This is an awareness and regression catalogue, not a payload cookbook. Use
inert fixtures and local test doubles. Active testing still requires the
`authorized-web-security-audit` contract.

For every class, identify the threatened invariant, enforcing owner, safe
fixture, negative control, observable side effects, and cleanup. The regression
oracle must assert host behavior, not merely model refusal text.

## Agent and context attacks

### Prompt and tool injection

- **Vector:** user, repository, web, document, image metadata, tool description,
  schema, result, error, or worker output contains instructions that conflict
  with owner intent.
- **Defense:** explicit trust labels, data/instruction separation, structured
  bounded results, and capability enforcement outside the model.
- **Regression oracle:** injected text cannot enable a denied tool, read a
  protected resource, change policy, contact a new destination, or persist memory.

### Tool poisoning, shadowing, and rug pulls

- **Vector:** a server advertises a deceptive tool, impersonates another name,
  changes description/schema after approval, or uses one tool's text to steer a
  privileged tool.
- **Defense:** provenance allowlist, namespace isolation, schema/manifest hash,
  change re-approval, and per-tool capabilities.
- **Regression oracle:** a changed or colliding identity is quarantined before
  execution; previously approved authority is not inherited.

### Goal, memory, and context poisoning

- **Vector:** untrusted content becomes a durable goal, trusted fact, preference,
  policy, compaction summary, or cross-session memory.
- **Defense:** provenance-preserving memory types, human/host admission gates,
  tenant keys, bounded retention, integrity/version checks, and reversible history.
- **Regression oracle:** untrusted data remains query data and cannot alter a
  future session's authority or system instructions.

### Excessive agency and confused deputy

- **Vector:** a low-trust caller induces a privileged agent/server to exercise
  credentials or scopes the caller does not possess.
- **Defense:** principal-bound capabilities, per-client consent, audience/scope
  validation, no token passthrough, progressive elevation, and human approval at
  high-impact edges.
- **Regression oracle:** the same intent from an unapproved principal is denied
  without side effects or information leakage.

## Tool input and interpreter attacks

### Command and argument injection

- **Vector:** model text crosses into shell syntax, option parsing, environment
  expansion, nested interpreters, or executable selection.
- **Defense:** direct executable/argv adapters, option terminators, allowlisted
  grammar, clean environment, canonical cwd, and process sandbox.
- **Regression oracle:** metacharacters and option-shaped filenames remain data;
  only the intended executable and arguments are observed by a fake process.

### Path traversal, symlink, and archive escape

- **Vector:** relative traversal, mixed separators, device/UNC paths, alternate
  streams, case/Unicode aliases, symlink swaps, or archive entries escape a root.
- **Defense:** platform-aware canonicalization, handle-relative/symlink-safe open,
  post-open verification, exact extraction root, and denied sensitive paths.
- **Regression oracle:** aliases and a deterministic symlink swap cannot read or
  mutate outside the capability root.

### Unsafe parsing and deserialization

- **Vector:** duplicate keys, prototype pollution, accessors, unsafe integers,
  deep nesting, trailing values, decompression bombs, or executable formats.
- **Defense:** strict schemas, null-prototype/owned-property access, depth/byte
  bounds, non-executable formats, and fail-closed parse errors.
- **Regression oracle:** malicious shapes are rejected before state change while
  a structurally similar valid negative control succeeds.

### Query and template injection

- **Vector:** untrusted values become query language, regex, glob, selector,
  template, markup, or code rather than parameters.
- **Defense:** typed AST/builders, parameter binding, safe regex/glob limits,
  output encoding, and no dynamic evaluation.
- **Regression oracle:** metacharacters cannot alter query/operator structure or
  cross the intended record/resource set.

## Network and transport attacks

### SSRF, redirect escape, and DNS rebinding

- **Vector:** a permitted URL resolves or redirects to private, loopback,
  link-local, metadata, or another tenant's service; DNS changes after validation.
- **Defense:** standard URL/IP parsing, scheme/host/port/address allowlists,
  redirect-hop checks, DNS pinning/revalidation, egress proxy/policy, and stripped
  cross-origin credentials.
- **Regression oracle:** safe initial DNS followed by a forbidden result, and an
  external redirect to loopback, both fail before connection.

### MCP session hijack and event injection

- **Vector:** guessed/stolen session ids, unauthenticated HTTP, cross-node queues,
  resumed streams, or tool-list notifications cross principals or streams.
- **Defense:** authentication on every request, Origin validation, random ids
  bound to principal, per-stream event ids, generation fences, and scoped queues.
- **Regression oracle:** another authenticated user with the session id cannot
  call, resume, cancel, enumerate, or receive the owner's work.

### Token substitution and passthrough

- **Vector:** a server accepts a token issued to another resource or forwards the
  inbound bearer token to a downstream service.
- **Defense:** issuer/audience/expiry/scope validation and distinct downstream
  credentials bound to the server's own client role.
- **Regression oracle:** a valid wrong-audience token and a broader-than-required
  token are rejected without downstream contact.

## State, concurrency, and availability attacks

### Tenant crossover

- **Vector:** caches, workers, shells, memory, files, task ids, notifications, or
  credentials are keyed only by cwd, process, model, or guessable id.
- **Defense:** session tenant plus trusted principal on every key and transition;
  non-enumerating denials and tenant-specific cleanup.
- **Regression oracle:** two simultaneous sessions in one workspace cannot see,
  mutate, cancel, resume, or receive each other's state.

### Replay, stale result, and race exploitation

- **Vector:** duplicate delivery, ambiguous retry, out-of-order completion,
  check/use gaps, stale worker generation, or concurrent mutation repeats effects.
- **Defense:** intent-bound idempotency, versions/generation fencing, atomic
  transitions, durable terminal records, and postcondition reconciliation.
- **Regression oracle:** barriers force each ordering; the invariant is either
  fully committed once or absent, never partially or twice.

### Resource exhaustion and denial of wallet

- **Vector:** recursive delegation, tool loops, oversized results, decompression,
  regex backtracking, unbounded fan-out/retries, hung children, or cost amplification.
- **Defense:** independent token/cost/time/CPU/memory/output/depth/fan-out budgets,
  cancellation, circuit breakers, backpressure, and bounded summaries.
- **Regression oracle:** the smallest exceeded budget terminates owned work,
  emits one terminal status, and leaves no live descendants or unbounded artifact.

### Secret exfiltration through legitimate channels

- **Vector:** prompt injection places secrets in search queries, URLs, issue/email
  bodies, logs, errors, telemetry, filenames, or worker results.
- **Defense:** model-blind secret handles, sink-aware redaction/DLP, destination
  capabilities, explicit external-mutation approval, and minimum data projection.
- **Regression oracle:** canary secrets never appear in model context, artifacts,
  logs, argv, URLs, or outbound fake-service captures.

## Supply-chain and local-server attacks

### Malicious server, plugin, skill, or dependency

- **Vector:** installation executes lifecycle code, configuration embeds a
  startup command, bundled instructions expand authority, or an update changes
  behavior after trust was granted.
- **Defense:** exact pins and hashes, provenance/license review, no install scripts
  by default, displayed commands, sandboxing, signed/verified updates, and
  re-approval on manifest/capability changes.
- **Regression oracle:** an altered artifact or capability manifest is rejected
  before execution and cannot inherit stored credentials or approvals.

## Review outcome

Classify every tested item as confirmed, rejected with the negative-control
reason, incomplete with the missing probe, or residual architectural risk. Do
not call the harness secure merely because this catalogue has coverage.
