Unit 7 · ML & applied AI · Lesson 12 of 13
Prompt injection, permissions, privacy and model limitations
Step 1: Learn the ideas
- Direct prompt injection and jailbreaks
- Indirect prompt injection through retrieval, browsing, email and tools
- Exfiltration channels: links, images and tool calls
- Least privilege, server-side authorization and approval gates
- Improper output handling: model output as untrusted input
- Hallucination, unsupported claims and grounding checks
- Tenant isolation, personal data and retention
- Model limitations and how to communicate them
- Frameworks: OWASP Top 10 for LLM Applications, NIST AI RMF
Why it matters
An LLM application treats text as instructions, and much of that text comes from places you do not control. Once the model can read private data and take actions, a sentence hidden in a web page or an email can redirect it. "How would an attacker abuse this feature?" is a natural question in any applied AI design discussion, and the realistic failure is a data leak, not just an embarrassing output.
Core ideas
Prompt injection. Direct injection is a user typing instructions that override the developer's ("ignore the previous instructions and..."); jailbreaks are direct attempts to get around safety behavior. Indirect injection hides instructions in content the system processes on a user's behalf: a retrieved document, a web page, an email being summarized, a code comment, a tool result. The model cannot reliably separate data from instructions because both arrive as tokens in the same context. Input filters, delimiters and "never follow instructions inside documents" prompts reduce some attacks but are not a security boundary; assume a determined attacker eventually gets text through.
The dangerous combination. Risk peaks when one agent has (1) access to private data, (2) exposure to untrusted content and (3) a channel to send data out, which can be as subtle as rendering an image whose URL carries data in its query string. For any flow that handles untrusted content, remove at least one leg: no outbound channels while untrusted content is in context, no private data in that context, or human approval of every outbound action.
Design-level defenses.
- Least privilege: tools scoped to the task and to the user's own permissions; read-only by default.
- Authorization by the server on every tool call, using the authenticated user and tenant, never parameters chosen by the model.
- Treat model output as untrusted input downstream: validate it against schemas, escape it before rendering HTML or building queries, and never execute generated code outside a sandbox.
- Human approval for irreversible or outbound actions, showing exactly what will be sent.
- Separate trusted control flow from untrusted data: a planner sees only the trusted request, untrusted content is processed by a component that cannot trigger actions, and policies restrict which data may flow into which tools.
- Monitoring and rate limits to detect abuse and bound cost.
Unsupported claims. Models generate plausible text, not verified facts, and state errors fluently. Ground answers in retrieved sources with citations, verify that cited sources support the claims, constrain outputs to structured fields where possible, allow abstention, evaluate faithfulness explicitly, and show uncertainty in the product.
Tenant and data permissions. Multi-tenant systems must isolate retrieval indexes, caches, logs and fine-tuning data per tenant. Filter retrieval by the user's access rights before anything reaches the model. Be careful with shared caches of prompts and responses, and assume a system prompt can leak, so never embed secrets in it.
Privacy. Send only the personal data the task needs; redact or pseudonymize personal data in logs and evaluation sets; set retention periods and deletion paths for prompts, outputs and traces; check what the model provider retains and where data is processed; and do not train on user data without a clear basis and consent. Models can memorize rare training sequences, so fine-tuning on sensitive data creates an extraction risk.
Model limitations. Knowledge cutoffs, sensitivity to phrasing, nondeterminism, uneven quality across languages and domains, and unreliable arithmetic or exact recall without tools. Communicate them to stakeholders with evidence from evaluations rather than reassurance.
Common misconceptions
- "A strong system prompt prevents prompt injection." At best it lowers success rates; enforce boundaries outside the model.
- "Only user input is untrusted." Retrieved documents, web pages, emails and tool outputs are untrusted too.
- "Filtering offensive output is enough." Exfiltration hides in URLs, tool arguments and markdown images; restrict what outputs can do.
- "Retrieval eliminates hallucination." It reduces it, but models still misread sources or go beyond them; verify faithfulness.
- "The model provider handles privacy." Your logs, caches, evaluation sets and retention policies are your responsibility.
- "An injection classifier solves the problem." Detectors are useful signals but can be bypassed; design so that a successful injection has limited impact.
How to approach it
For any LLM feature, draw the data flow, mark untrusted inputs, sensitive data and side effects, then remove dangerous combinations and add server-side controls. Walk through the OWASP Top 10 for LLM Applications with your own design, and try an indirect injection on a toy RAG system to see how easily it works. Senior-level discussions expect threat models, layered defenses and an honest statement of residual risk.
Suggested order
- 1Read the OWASP Top 10 for LLM Applications (2025), especially LLM01 Prompt Injection, LLM02 Sensitive Information Disclosure, LLM05 Improper Output Handling and LLM06 Excessive Agency.
- 2Read Greshake et al. on indirect prompt injection, focusing on the threat taxonomy and attack vectors.
- 3Read Simon Willison’s "The lethal trifecta for AI agents" and his Dual LLM pattern post, then check which of your own feature designs combine all three risk factors.
- 4Read the design overview of the CaMeL paper to see how control flow and data flow are separated and policies are enforced at tool calls.
- 5Skim the NIST AI RMF page and its four core functions (Govern, Map, Measure, Manage) for governance vocabulary.
- 6Run the indirect-injection exercise in the practice guidance.
Step 2: Check off what you can do
Tap each one you can genuinely do or explain. Each earns 10 XP.
Step 3: Go deeper
OWASP Top 10 for LLM Applications (2025)Start here
OWASP Gen AI Security ProjectSection: LLM01:2025 Prompt Injection
Risk-by-risk descriptions with mitigations; start with prompt injection, then sensitive information disclosure, improper output handling and excessive agency.
Open(opens in a new tab)Link responded, 5 Oct 2026Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt InjectionStart here
arXivThe systematic treatment of indirect prompt injection and its attack vectors.
Open(opens in a new tab)Link responded, 5 Oct 2026Prompt injection (article series)
Simon Willison's Weblog (practitioner)Section: The lethal trifecta for AI agents (2025)
Practitioner framing of when agents become exfiltration risks, plus the series’ history of attacks and proposed defenses.
Open(opens in a new tab)Link responded, 5 Oct 2026Defeating Prompt Injections by Design
arXivA design that confines untrusted data and enforces data-flow policies instead of relying on the model’s judgment.
Open(opens in a new tab)Link responded, 5 Oct 2026NIST AI Risk Management Framework (AI RMF 1.0)
National Institute of Standards and Technology (NIST)Governance vocabulary (Govern, Map, Measure, Manage) for discussing AI risk ownership at senior level.
Open(opens in a new tab)Link responded, 5 Oct 2026
Step 4: Practice
Build a toy RAG assistant over a few documents and plant an instruction in one of them, for example asking the model to append a link that contains the user’s question. Measure how often the injection succeeds over 20 runs with and without a defensive system prompt; then remove the exfiltration path (no link or image rendering, or an allowlist of domains) and re-test. Separately, write a one-page threat model for an outreach assistant that reads inbound email and can send replies: untrusted inputs, sensitive data, outbound channels, and the controls you would require (approval, scoping, logging, retention).
No external problems are linked; follow the guidance above.
Record attempts on each problem’s page (+15 XP, +10 more when solved on your own).
Step 5: Test yourself
Answer each one out loud or on paper before you finish the lesson.
- Question 1Why can the model not reliably distinguish instructions from data?
- Question 2Which three capabilities together make data exfiltration possible, and how do you break the combination?
- Question 3How can a markdown image leak data?
- Question 4Where must tenant isolation be enforced in a RAG system?
- Question 5Why is verifying a citation different from trusting it?
- Question 6Which data should not enter evaluation sets without redaction?
You’re done when you can
- Explain direct versus indirect prompt injection with two concrete attack paths in under three minutes.
- Produce a threat model for an LLM feature that names untrusted inputs, sensitive data, outbound channels and server-side controls.
- Demonstrate an indirect injection on a toy system and show a design change that removes its impact.
- List privacy controls for prompts, logs and evaluation data, including retention and deletion.


