Building with AILesson 64 of 80

Module 7 · Safety, security and the adversary

Model output as untrusted input to everything downstream

In this lesson

  • 9 min read
  • 7 reading sections
  • Knowledge check
  • Lesson 4 of 10 in this chapter

This chapter’s goalThreat-model an AI feature and defend it by architecture: name every channel by which untrusted text reaches the model and every channel by which its output reaches a privileged action or the outside world, restrict each with a control that does not depend on the model’s obedience, layer moderation and abstention with measured false-positive costs, and state plainly what a user must be told and what you cannot promise about a provider’s handling of their data.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 8Free · no account needed
Lesson steps

The oldest vulnerabilities, with a new author

Cross-site scripting, SQL injection, command injection and path traversal have been the top of every web-security list for twenty years. Each is the same mistake: text from an untrusted source is handed to an interpreter (a browser, a database, a shell, a filesystem) as if it were code the developer wrote. The defences are well known and applied by default in modern frameworks, because everyone learned to distrust user input.

A language model is a new source of text that is not user input and is not developer code. It is something in between, and it inherits the danger of both: it produces whatever its context steered it towards, including text an injection put there, and it produces it fluently, in the exact syntax the downstream interpreter expects. Treat everything the model writes as untrusted input to whatever consumes it next. That is the whole lesson; the rest is the list.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Python, from Zero, for AI exam.

Stuck on something?Ask Sayali, your AI tutor

How to cite: Addaly (2026) ‘Model output as untrusted input to everything downstream’, in Building with AI. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/building-with-ai/model-output-as-untrusted-input (Accessed: 29 November 2026).