Generative AI
Security, Privacy, and Abuse-Resistant Design
Threat-model generative AI applications and apply trust boundaries, least privilege, privacy controls, and layered defenses against prompt injection and abuse.
By the end you can
- Model prompt injection, data exfiltration, tool misuse, poisoning, and denial-of-service threats
- Distinguish instruction hierarchy from a security boundary
- Apply least privilege, isolation, validation, and user confirmation to tool-enabled systems
- Design privacy and abuse controls across collection, context, logging, output, and retention
Visual
A generative application crosses several trust boundaries
Attackers can shape inputs directly. They can also shape them indirectly, through content the system retrieves later and then acts on. The second route has a founding paper. Greshake and colleagues named indirect prompt injection in February 2023 and demonstrated it remotely against production systems, including Bing's GPT-4-powered Chat and code-completion engines. Their diagnosis is architectural rather than anecdotal: “We argue that LLM-Integrated Applications blur the line between data and instructions.”
That blurred line is what the boundaries below exist to redraw. Each one is a place where something the application did not write becomes something the application acts on.
User input
Direct instructions, encoded payloads, social engineering, and resource exhaustion.
Retrieved content
Web pages, documents, emails, images, and metadata carrying indirect instructions.
Model behavior
Instruction following, memorization, unsafe completion, and policy evasion.
Tools and credentials
APIs, files, browsers, databases, payments, and destructive actions.
Outputs and logs
Sensitive disclosure, harmful artifacts, injection into downstream systems, and retention risk.
Key idea
Instruction hierarchy is useful, but it is not access control
System and developer instructions do shape model behavior, and it is worth being precise about how much. OpenAI's own instruction-hierarchy paper, published in April 2024, reports the size of the effect. Fine-tuning GPT-3.5 Turbo improved defence against system-prompt extraction by 63%. It improved jailbreak robustness by over 30% on held-out attacks. Those are real gains, produced by the people with the most access to the model and the strongest incentive to report a boundary if they had built one.
They did not claim one. The paper's conclusion states the residual plainly: “Finally, our current models are likely still vulnerable to powerful adversarial attacks.” A 63% improvement is a reduction in a rate, not a permission check. Adversarial content can still alter interpretation, and it can still produce unsafe proposals.
Enforce permissions in application code. Sensitive data, tools, destinations and side effects need controls that hold even when the model follows the wrong instruction.
“Because current mitigations do not offer full protection against all attacker techniques, application designers may design systems with the assumption that prompt injection attacks are possible if a model is exposed to untrusted input sources” — NIST AI 100-2e2025, on mitigations.
Case
Attack strings produced by a program, transferring between models
Jailbreaking used to take ingenuity. In 2023 a program took the ingenuity out of it. Zou and colleagues used a greedy coordinate gradient search, GCG, to generate adversarial suffixes automatically — a sequence of characters appended to a request, chosen by an optimizer rather than by a human. Against Vicuna the suffixes elicited 99 out of 100 harmful behaviours. On the harmful-strings exact-match task against Vicuna-7B, GCG reached an 88% success rate where the prior AutoPrompt optimizer reached only 25%.
The part that matters for a system designer is what happened when the same strings were pointed at models the search had never seen: “Furthermore, we find that the prompts achieve up to 84% success rates at attacking GPT-3.5 and GPT-4, and 66% for PaLM-2; success rates for Claude are substantially lower (2.1%), but notably the attacks still can induce behavior that is otherwise never generated.” Note the last clause. Even the model at 2.1% was made to produce behaviour it otherwise never produces. A defence that cuts a transfer rate from 84% to 2.1% is a very good defence. It is still not a boundary.
Manual ingenuity is not required. A program produces these attacks, so the supply is bounded by compute rather than by imagination. NIST reached the same conclusion from the defensive side. Its adversarial machine learning taxonomy, NIST AI 100-2e2025, arrived in March 2025, and it does not file this behaviour as an incident. It gives it catalogue numbers. Prompt Injection, NISTAML.018, for the direct form. Indirect Prompt Injection, NISTAML.015, for instructions that arrive inside content the system retrieves. Attacks that get taxonomy identifiers are attacks a designer is expected to plan for.
Comparison
Layered defenses address different failure points
No single filter eliminates prompt injection or misuse. The size of what layering does buy has been measured. AgentDojo, published in June 2024, is a public evaluation environment for tool-using agents, populated with 97 realistic tasks and 629 security test cases. Its introduction gives the three numbers a defender needs: “Current LLMs solve less than 66% of AgentDojo tasks in the absence of any attack. In turn, our attacks succeed against the best performing agents in less than 25% of cases. When deploying existing defenses against prompt injections, such as a secondary attack detector, the attack success rate drops to 8%.”
Read the sequence as an argument for layers and as a warning about them. Under 25% down to 8% is a large reduction and a poor guarantee: roughly one attack in twelve still lands. The reduction is not free either. All defences lose 15–20% of utility under attack. A control that costs a fifth of the system's usefulness has to be chosen deliberately, action by action, rather than switched on everywhere.
Context controls
Reduce and label untrusted material before it reaches the model.
- Content-type separation
- Source and provenance metadata
- Secret minimization
- Sanitization with known limits
Action controls
Constrain what proposed tool calls can actually do.
- Least-privilege credentials
- Destination and operation allowlists
- Argument validation
- Confirmation for consequential actions
Detection and response
Observe attacks, contain incidents, and preserve evidence.
- Injection canaries and adversarial tests
- Tool-call and data-flow telemetry
- Rate limits and circuit breakers
- Revocation, rollback, and notification
Privacy risk appears before, during, and after generation
Training data, fine-tuning records, prompts, retrieved documents, tool responses, conversation state, outputs and logs can all contain personal or confidential information. A private model endpoint does not make the whole workflow private.
The training-data end of that lifecycle has a published price. In November 2023 Nasr and colleagues showed that a divergence attack made ChatGPT emit training data at a rate 150× higher than normal. They reported the result as a budget line: “Using only $200 USD worth of queries to ChatGPT (gpt-3.5-turbo), we are able to extract over 10,000 unique verbatim-memorized training examples.” The longest ran to over 4,000 characters. And 93% of the memorized strings were emitted only once — memorization that a sampling-based audit would mostly miss.
Collect only necessary data. Separate tenants, redact where appropriate, define retention and deletion, restrict reviewer access, and test for unintended disclosure. Explain which records may persist and how users can correct or remove them.
Privacy is a lifecycle property of the application, not a label attached to the model provider.
Analogy
A receptionist should not carry every master key
There is a version of the front desk where the receptionist carries every key in the building. It makes a great many requests convenient. It also means that one deceptive instruction exposes the entire facility.
CVE-2025-32711 is that sentence as a product defect. Microsoft, the assigning CNA, describes it in one line: “Ai command injection in M365 Copilot allows an unauthorized attacker to disclose information over a network.” The flaw is publicly known as EchoLeak. The record was published on 11 June 2025 and classified CWE-74, Improper Neutralization of Special Elements in Output Used by a Downstream Component. Microsoft scored it CVSS 3.1 9.3 CRITICAL, with the vector AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:L/A:N. NVD's own analysis of the same record scored it 7.5 HIGH.
Read the vector rather than the number. PR:N and UI:N mean the attacker needed no privileges of their own and no action from the victim. S:C means the impact crossed out of the component that was exploited. That is the receptionist problem written as a string: the caller carried no key, because the assistant already held them all.
Tool-enabled models earn the same narrow, task-specific access. Personal judgment is what keeps a human receptionist from opening the wrong door. A model has none, so the application has to do the enforcing. That is also where hidden instructions arriving at machine scale get refused.
Grant the smallest permission needed for the current task, user, destination, and time window.
Steps
Threat-model one workflow before launch
Follow data and authority from input to irreversible effect. For high-risk systems the exercise is not a suggestion. Article 15(5) of the EU AI Act, Regulation (EU) 2024/1689, makes adversarial resilience a legal requirement, and it enumerates the classes providers must handle: “The technical solutions to address AI specific vulnerabilities shall include, where appropriate, measures to prevent, detect, respond to, resolve and control for attacks trying to manipulate the training data set (data poisoning), or pre-trained components used in training (model poisoning), inputs designed to cause the AI model to make a mistake (adversarial examples or model evasion), confidentiality attacks or model flaws.” Five verbs, five attack classes. The statute is itself a threat-modelling checklist.
1. Inventory assets
List sensitive data, credentials, money, records, identities, and reputation.
2. Mark trust boundaries
Identify untrusted users, documents, websites, plugins, and model outputs.
3. Enumerate attacker goals
Include exfiltration, fraud, policy bypass, poisoning, impersonation, and disruption.
4. Constrain capabilities
Apply least privilege, isolation, allowlists, schemas, quotas, and confirmations.
5. Test adversarial paths
Use direct, indirect, encoded, multilingual, visual, and multi-turn attacks.
6. Prepare containment
Define revocation, circuit breakers, evidence preservation, notification, and recovery.
Secure design assumes that some model outputs will be wrong
Security improves when unsafe proposals cannot become unauthorized effects. Every number in this lesson points the same way. 84% transfer for automatically generated suffixes. 63%, and over 30%, of improvement that still leaves models vulnerable. 8% residual attack success after a dedicated detector. $200 to pull 10,000 verbatim training examples out of a production endpoint. One CVE with no privileges and no user interaction. The goal is not a prompt that never fails. It is a system whose boundaries contain failures and expose them for response — the design posture NIST AI 100-2e2025 recommends for any model exposed to untrusted input.
The next lesson addresses model choice and economics. Security and privacy controls affect cost, latency, architecture, and which requests should reach a powerful model at all. AgentDojo's 15–20% utility cost under attack is a reminder that those controls are priced in the same currency.
Key takeaways
- Generative applications cross trust boundaries at user input, retrieved content, model output, tools, and logs — CVE-2025-32711 in Microsoft 365 Copilot, published 11 June 2025, crossed them in a shipped product.
- Direct and indirect prompt injection exploit instruction following rather than requiring weight modification; Greshake and colleagues demonstrated the indirect form against Bing's GPT-4-powered Chat in February 2023.
- Instruction hierarchy shapes behavior but does not replace deterministic authorization. OpenAI's own fine-tuning gained 63% against system-prompt extraction and over 30% in jailbreak robustness, and the authors still record that their models are likely vulnerable to powerful adversarial attacks.
- Tool-enabled systems need least privilege, allowlists, schemas, confirmation, quotas, and auditable traces — AgentDojo's secondary detector moved attack success from under 25% to 8% across 629 security test cases, while all defences cost 15–20% of utility under attack.
- Privacy controls cover training data, prompts, retrieval, state, outputs, review, logs, retention, and deletion; $200 of gpt-3.5-turbo queries recovered over 10,000 unique verbatim-memorized training examples at 150× the normal emission rate.
- A mature security program combines prevention, adversarial testing, detection, containment, and recovery — the five obligations Article 15(5) of the EU AI Act imposes on high-risk providers, over the attack classes NIST AI 100-2e2025 catalogues as NISTAML.018 and NISTAML.015.