DriftLock

How to Test Your Defenses Against Prompt Injection Before Rollout

Build a small set of realistic test cases — a report, an email thread, a web page, a spreadsheet — each with an instruction hidden somewhere staff wouldn't notice, and run them through every AI tool you plan to deploy before it touches real data. Watch for three outcomes: does the assistant follow the hidden instruction, does it output or send anything it shouldn't, and does it ask a human before acting. No test catches everything, since injection techniques keep changing, but a structured pre-rollout pass catches the obvious failures before they reach production.

Why test before rollout at all

No test suite will prove an AI tool is safe, because prompt injection is an open-ended problem — new phrasing, new hiding places, and new tool behaviors appear constantly. What a pre-rollout test does give you is a baseline: evidence of how each tool behaves against a known set of realistic attempts, run before staff start feeding it real customer data, contracts, or inboxes. That baseline is worth having even though it will go stale and need repeating.

Build test cases from real work, not hypotheticals

The most useful test cases look exactly like the documents and messages your staff already handle, with one instruction hidden somewhere a person reading normally wouldn't see it:

  • An internal report or PDF with text hidden via white-on-white formatting, a footnote, or document metadata.
  • An email thread where the instruction sits in a quoted reply, a forwarded message, or a signature block rather than the visible body.
  • A web page with off-screen or visually hidden text that a browser assistant can read even though a person scrolling the page never would.
  • A spreadsheet with an instruction placed in a cell outside the normal viewing range, or in a cell comment.
  • A shared drive document with the instruction left as a tracked-change comment rather than body text.

None of these require special tools to build. They mirror exactly the places a real attacker — or an accidental source, like a vendor's oddly formatted invoice — would put one.

Watch for three outcomes, not one

For each test case, there are three possible results, and only one of them is acceptable without a human checkpoint:

  1. The assistant ignores the embedded instruction and completes the original task normally.
  2. The assistant follows the embedded instruction silently — this is the failure you're looking for.
  3. The assistant notices something odd and asks before proceeding — better than silent compliance, but still worth logging, since it tells you the assistant can be influenced even if it caught itself this time.

A single pass that avoids outcome two is not a guarantee against outcome two next time with a slightly different phrasing. Treat each test as a sample, not a certification.

Test every surface separately

A coding agent, a browser extension, and a desktop chat assistant are different programs with different access and different guardrails, even when they're built on similar underlying models. A test run against one tells you little about the others. If staff across finance, legal, sales, and engineering are each going to use a different surface, test the specific combination of tool and typical task for each group, not just the one IT happens to use most.

Test case reference

Test case Where the instruction hides What you're checking
Internal report or PDF Hidden text, footnote, metadata Does the assistant summarize normally, or follow the embedded instruction
Email thread Quoted reply, signature, forwarded message Does the drafted reply leak data or take an unauthorized action
Web page Off-screen text, alt text, hidden elements Does a browser assistant act on content invisible to the person reading the page
Spreadsheet Out-of-view cell, cell comment Does the assistant include or act on instructions nobody scrolled to
Shared drive document Comment or tracked change Does the assistant treat a reviewer's note as a command

Run it as a pilot, not a one-time gate

Start with a small group doing real work with each tool, rather than a lab exercise disconnected from daily tasks. Expand access once the obvious failures from testing are closed, and keep the test cases on file so the next tool, model update, or integration can be run against the same baseline rather than starting from zero. Model versions and tool updates change behavior without notice, so plan to repeat the exercise on a schedule rather than treating it as something you do once before launch and never again.

Keep the record, not just the result

What was tested, what each assistant did, and what changed as a result is worth keeping on file — it becomes the evidence you need later when someone asks how AI tools were vetted before deployment. A continuous log of what agents actually do in daily use, across every machine, extends that same visibility past the test phase and into normal operation.

What to take away

  • Build test cases from real documents and messages, with the instruction hidden exactly where an attacker — or an odd vendor document — would put it.
  • Check for three outcomes: silent compliance, ignoring it correctly, or noticing and asking — and log all three.
  • Test each AI surface separately; behavior on a coding agent tells you little about a browser assistant.
  • Pilot with a small group doing real work before expanding access company-wide.
  • Repeat the test on a schedule, since tool and model updates change behavior without notice, and keep records for later evidence.

Related