LearnAI
Module 10 · AI Application Security (Pro) · Lesson 1/5
← Back to catalog
Task

Input and output are untrusted

How to handle input and output? Return JSON {"rules": [list of 2+ rules], "why": "brief"}.

Unlock access to submit solutions for instant AI review.Start for free
AI Application Security Base
💡 A bit of theory

Key mindset shift: Both user input AND model output are untrusted data. The user may try to break your prompt; The model may return incorrect, harmful, or substituted content. Rules: Do not paste model output directly into HTML, SQL or commands without escaping (risk of XSS and injections); validate the structure and content of the response before use; limit what the model can generally return (format, length); treat her text as input from an outsider, and not as code from yourself. Rule: trust the model’s output exactly as much as you would trust the text from a random user - that is, do not trust, but check.

How it's graded · passing score 70

  • 1Valid JSON without text around it30%
  • 2There is an array rules and why35%
  • 32+ rules: do not insert raw output, validate, limit format, consider untrusted35%
Your promptClaude ⌄