Prompt Injection Regression Tests Belong in CI

A prompt injection that was fixed in March can work again in June, and nobody touched the prompt. That is the case engineers make for prompt injection regression tests: every patched attack should become an automated check that runs whenever any part of an AI system changes.

Most companies file prompt injection under security. Specialists attack the system once or twice a year, patch the findings and move on. That cadence was inherited from older software, where a closed hole generally stayed closed until the next planned release. Agent systems break that assumption.

Why patches don’t stay fixed

Between two reviews, an agent can behave differently while the reviewed code stays untouched. Swapping the model, editing a prompt or adding a data connector can reopen a hole closed months before. A scheduled review is a snapshot. A regression suite can run each time anything changes.

Akash Agrawal, vice president of DevOps and DevSecOps at TestMu AI, points to the way agents are wired together. One model’s output becomes the next model’s input, and nothing in that handoff treats the data with suspicion. He warns that a hostile instruction planted in one model can spread to every model it talks to. A model can obey a poisoned instruction and still hand on output that looks perfectly normal.

He wants models held to the same zero-trust standard that security teams apply to people and services. Concretely, log each message passing between agents and validate it the way a public API endpoint validates requests. A test suite then has a definite target.

A model upgrade brought an attack back

Jose Lejin P J, a principal member of technical staff at Salesforce, has watched this happen. His team patched an injection that arrived through a retrieval connector, where a document the agent read carried instructions to ignore its guardrails and all earlier context.

Even the first fix took weeks, because the flaw kept failing in testing until the team tightened how system prompts and inputs were structured and handled. The patch then held until a model upgrade. The newer model simply followed instructions inside retrieved documents more readily than the old one, Lejin says, and the prompt itself never changed.

No code had changed, so a review or a prompt diff would have shown nothing. Replaying the old attack against the new model before release would have exposed it. The takeaway: handle a model version bump as a release in its own right. Pinning the version in configuration makes an upgrade a reviewed change instead of a quiet swap by the provider.

Every patched jailbreak becomes a fixture

Lejin’s team changed what a patch means. Every jailbreak they shut down now becomes a test case, pairing the original payload with the refusal the system should give. The cases sit in a red-team database and run when the prompt code, the model or a connector changes. A build that falls to an already-defeated attack doesn’t ship, and each incident also spawns a tougher variant.

Where the suite runs matters. Put it at the stage that already halts a release when a unit test fails, and it can’t degrade into a report people read later. The failed build also identifies the exact payload that got through.

Test more than user input

Agrawal divides the attack surface into two paths. In one, a user crafts input to override the agent’s instructions. In the other, outside data such as a document or another model’s output hides a command that triggers when the agent reads it. Lejin’s connector case was the second kind. A suite weighted toward user input can pass while the connector path stays open.

Memory is a further weak spot. Stored context and session state let a hidden instruction sit and wait after the request that delivered it is over. Agrawal recommends running payloads across a full session rather than one call, and testing the chain of agents as well as each agent alone. An agent that refuses an instruction can still pass it to the next one that doesn’t. Teams with agent memory should validate what gets written to it and keep a way to purge it after an incident.

Who owns the gate

Ownership gets contested once a regressed injection ships. Lejin recalls a standoff: security blamed a prompt regression, and the product team blamed a model that changed underneath them. His team settled it by splitting the work. Security owns the bar, meaning what counts as safe, and delivery owns the gate that enforces it on every build.

Source: stackoverflow.blog

Written by

Saksham Bhargava

Saksham Bhargava runs Alteroid and has been writing about consumer technology for over five years, covering iPhone, Android, Windows, AI tools and gaming. With an MCA and six years of hands-on web development experience, he tests the features he writes about on his own devices and focuses on clear, practical guides that solve real problems. Away from the screen, he enjoys travelling to places most tourists skip.