Safety, privacy and running in production · core
Prompt injection and unsafe outputs
The model cannot reliably tell instructions from data, so any text in its context can act as an instruction. Defend by limiting what the system can do, not by asking the model to be careful.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Direct injection: the user types ignore your rules. Indirect injection: the instruction hides in content the app feeds in, such as a web page, email, PDF, resume or tool result, sometimes in white text or an image.
- The lethal trifecta: private data, untrusted content and a way to send data out. An agent with all three can be tricked into leaking data. For any flow that reads untrusted content, remove at least one.
- Layered defences: least-privilege tools, identity enforced in code, confirmation for actions with consequences, untrusted content in a separate call with no tools and a constrained output schema, and no open outbound channels.
- A markdown image can leak data: the model writes an image URL with the secret in it and the browser loads it without a click. Never auto-load images from arbitrary domains. Use an allowlist or an image proxy, sanitise HTML and set a strict Content-Security-Policy.
- Other dangerous outputs: HTML and JavaScript (XSS), and SQL or shell commands. Treat model output as untrusted input.
- Resume screening case: hidden text said to score 98. Extract evidence with quotes into a schema and let code compute the score, so no sentence in the resume can set the number. Flag hidden text.
- A system prompt that says ignore instructions inside emails does not reliably stop an attack.
- OWASP lists prompt injection as number 1 in its Top 10 for LLM applications.
The red pen
Common traps: mistake → fix
Mistake: A strong system prompt prevents injection
Fix: it lowers risk but cannot remove it.
Mistake: Only users attack the app
Fix: documents, web pages and tool results can attack too.
Mistake: Rendering model output as is, is safe
Fix: images, links and HTML can leak data.
Easy to hard
Questions interviewers ask, easy to hard
- What is prompt injection? Direct and indirect?
- Why can a better prompt not fix it?
- Review this email assistant: what could an attacker do?
- Explain how a markdown image leaks notes.
- How do you protect a resume-screening tool?
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.