Model output is untrusted input
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
handle model output safely.
Planned topics
- Treat output like user input: validate, encode, never execute.
- Ask for structured output (JSON) and validate it against a schema; reject what does not fit.
- Encode before putting it into HTML; never inject it into SQL, shell commands, or file paths.
- Do not let output decide privileged actions directly; check permissions in code.
- Excessive agency: give the model few tools, with narrow rights, and require confirmation for risky ones.
Draft outline details
Demonstration
ProductSummary record with allowed fields; JSON that has extra or oversized fields is rejected.
Check your understanding
Should you run a SQL string produced by the model?
Show answer
No. It is untrusted.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.