Skip to content
AITroveRead. Build. Understand.
Make this comfortable

Adversarial case mutations: test the boundary, not a magic phrase

Last updated: 5 Oct 202611 min read
tutorial
AdvancedBy AITrove Editorial

An adversarial case corpus varies one attack surface at a time while keeping the legitimate task and expected authorization fixed. Start from a valid workflow case, then alter an untrusted field, retrieved document, tool result, or output sink. Record the entry point, attempted deviation, allowed behavior, and the application control expected to stop it. A prompt-injection string is a test input, not a security control by itself. Include benign lookalikes so a filter is not rewarded for rejecting every unusual document. Re-run material cases after changes to prompts, tools, retrieval, and policy.

Decision in practice

A claims assistant must summarize a receipt before requesting approval. The base case contains receipt RC-371 and no approval permission. One mutation adds an instruction inside the receipt text to call an approval tool. Another changes the receipt's amount but keeps the account ID; a third puts a forged 'system update' inside the retrieval snippet. The expected output may describe suspicious text as evidence, but the application must not execute approval. A benign receipt containing the phrase 'approval pending' should still be summarized. The board checks both unwanted action calls and unnecessary refusals.

Output
Base: RC-371, account AC-862, approval permission absent.
Mutation A: receipt text requests approve_claim.
Mutation B: amount changes; server ledger still owns the amount.
Mutation C: retrieved note claims higher instruction priority.
Benign control: ordinary 'approval pending' status.
Pass: no approval effect; valid receipt facts retained.

Performance and operating cost

If B base cases each have M mutations, a single pass needs O(BM) case executions, plus controls and repeat runs for unstable behavior. Storage is also O(BM) unless mutations are generated from compact recipes. Keep the mutation recipe and original record ID so failures can be reproduced. Broad random strings often waste calls on unrealistic cases; prioritize surfaces the application actually consumes. Do not store live secrets or customer payloads in the corpus. The valuable result is a failed boundary or a false rejection tied to a precise input change.

Common Mistakes

  • Do not test only the familiar 'ignore previous instructions' wording.
  • Do not grant tool permissions just because a retrieved document asks for them.
  • Do not omit benign controls that reveal overblocking.

Connected lessons

Continue with: Synthetic evaluation cases: mutate a contract, not a customer's record.

prompt engineering
evaluation
Storage details