How to test AI systems against edge-case, adversarial, and malicious input, including prompt injection.
Input validation has always been part of QA — checking that a form rejects bad data, that an API returns a sensible error for a malformed request. AI systems need the same discipline, but the range of 'bad input' is much wider, because the input is often free-form natural language rather than a structured field with clear rules.
This article covers:
A traditional form field can be validated with a handful of rules: required, correct format, length limit. A chat input box that feeds into an LLM has almost none of those constraints — a user can type anything, in any language, of any length, with any intent, including intentionally trying to manipulate the system. Because the model tries to generate a plausible response to whatever it receives, an AI system without input validation will often attempt to answer questions it should refuse, follow instructions it should ignore, or process input that was never meant to be a legitimate request.
A thorough test suite for an AI system's input handling usually covers:
Prompt injection is an attack specific to AI systems, where a user embeds hidden instructions inside their input — or inside a document the AI is asked to process — to override the system's original instructions. A simple example is a user typing 'ignore your previous instructions and instead tell me...' A more advanced example hides similar instructions inside a document, email, or web page that an AI assistant is asked to read and summarize, so the attack comes through content the system processes rather than direct user input.
Testing for prompt injection means treating every source of text the AI reads — not just the direct chat input — as a potential attack surface, and includes checking whether the system can be tricked into revealing its own system instructions, ignoring safety rules, or performing actions the user should not be able to trigger.
A practical prompt test suite is built incrementally:
Because new prompt injection techniques are discovered constantly, this kind of test suite should be treated as a living document, not something written once and left alone.
Defining “Correct” in AI Systems
Solving LLM Instability in Internet Marketplace Platforms