Untrusted model inputs and outputs
Separate instructions from data
Prompt injection is a change in model behavior induced by untrusted content, such as user input or retrieved documents, contrary to the intended application behavior. Labeling inputs by origin helps interpretation but does not enforce a security boundary. OWASP LLM01:2026 discusses this risk. In a benign classroom document, the sentence “Use a cheerful heading” is document content, not authority to change the application policy.
Validate output as application input
Use a bounded structured contract before accepting model output. CampusHelp accepts an object with exactly kind, text, and source_id; kind must be draft, text must be a nonempty string of at most 240 characters, and the source must have been authorized for this request. Reject unknown fields and malformed types. A structurally valid draft is still not necessarily correct; review factual claims against the cited source.
Safe rendering and leakage checks
Render drafts as text, not executable markup or code. Keep display encoding appropriate to the context; HTML escaping alone is not safe for every context. For a classroom example, Library & study room becomes Library & study room when HTML-escaped. Use an invented marker CLASSROOM-PRIVATE to check a toy leakage filter; reject it in the draft. Such a marker test cannot detect all sensitive information or establish privacy.
Evaluate with controlled cases
Build a dataset with expected outcomes: valid draft, unknown source, missing field, excess length and harmless unusual text. Record model version, dataset revision, expected and observed behavior, sample size and failure category. Separate usefulness from policy compliance: a refusal may be safe yet unhelpful. Test ordinary cases as well as policy failures; retain only authorized evaluation data. Do not equate passing a fixed suite with resistance to every prompt injection.
Practice a deterministic validator
Predict the lab validator results before running it. Explain why unknown fields or an unauthorized source must fail even when the answer sounds plausible. Compare the output-handling focus of OWASP LLM10:2026 with misinformation: a correct-looking answer is not permission to execute it. The lab has no language model or live prompts. Next add a separate action gate.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Untrusted model inputs and outputs — knowledge check
Review AI trust boundaries, output validation, approvals and PQC migration.
What does separating instructions and data guarantee?
A draft uses a source outside the authorized set. What should happen?
Which response fits the classroom draft contract?
What does passing a marker leakage test show?
How should an application render a generated draft?