What Is LLM (Large Language Model) Security?
- Jul 29
- 30 min read

Ask an AI chatbot to summarize a webpage, and most people assume it only reads the words on the page. It doesn't. It also reads any hidden instructions sitting inside that page, and it often cannot tell the difference between the two. That single blind spot is the root of nearly every large language model (LLM) security incident happening in production today. LLM security is the discipline that keeps this confusion from turning into a data breach, a hijacked agent, or a costly automated mistake.
TL;DR
LLM security protects the whole system around a model — prompts, training and retrieval data, tool integrations, and outputs — not just the neural network itself [2][3].
Prompt injection has topped the OWASP Top 10 for LLM Applications for two straight editions because models cannot reliably separate instructions from data [1].
Real incidents already prove the risk: the 2025 EchoLeak flaw (CVE-2025-32711) let attackers pull data out of Microsoft 365 Copilot using nothing but a crafted email, with no user click required [8].
Agents that can send email, run code, or move money turn a language mistake into a real-world action — OWASP calls this “excessive agency” [1].
NIST, MITRE, and CISA/NSA guidance agree on one point: no single guardrail is enough. Defense in depth beats any one control [2][4][5].
Small teams can meaningfully cut risk with four moves: least privilege for tools, output validation, logging, and a named owner for AI risk.
What Is LLM (Large Language Model) Security?
In short: LLM security is the set of practices, controls, and architecture decisions that protect large language model applications — their prompts, training and retrieval data, model weights, integrations, agents, and outputs — from manipulation, data leakage, and abuse, while keeping standard cybersecurity controls in place around the whole system.
Table of Contents
Why LLM Security Is Different from Traditional Cybersecurity
The LLM Threat Model: Assets, Attackers, Trust Boundaries, and Attack Surfaces
The OWASP Top 10 for LLM and Generative AI Applications
Output Handling, Hallucinations, Misinformation, and Unsafe Automation
Model Theft, Extraction, Inversion, and Intellectual Property Risks
Why do LLMs create new security risks that older software didn't have?
What is the difference between prompt injection and jailbreaking?
Why do AI agents increase security risk compared to a simple chatbot?
What can LLM guardrails actually do, and what can't they do?
Are open-source models more or less secure than hosted commercial models?
What are the first LLM security controls a small team should implement?
What Is LLM Security?
LLM security is the practice of protecting large language model (LLM) systems, and everything wired around them, from being manipulated, exploited, or misused. That includes the model itself, its training and fine-tuning data, the prompts and system instructions that steer it, the APIs and applications built on top of it, the tools and agents it can call, and the people and business decisions that depend on its output.
It helps to separate two things people often mix up. Using an LLM to help write detection rules, summarize security alerts, or triage phishing email is applying AI to cybersecurity. LLM security is the reverse: it is the cybersecurity discipline applied to the AI system itself, treating the model, its data pipeline, and its application layer as assets that need their own threat model, controls, and monitoring.
In practice, LLM security rarely means securing the neural network in isolation. Most real incidents happen at the seams: where a user's message meets a system prompt, where an untrusted document meets a retrieval index, or where a model's output meets an automated action. Techniques such as AI jailbreaking exploit exactly these seams. Real-world LLM security therefore covers the complete application and operational environment around the model, not only its weights.
How LLM Systems Work and Where Security Risks Enter
An LLM is a type of language model trained on large amounts of text to predict and generate text one token (a small chunk of a word) at a time. Understanding where risk enters a real deployment means following the whole pipeline, not just the model.
Training and pre-training build the base model's general language ability. Fine-tuning then adapts it to a narrower task using a smaller, more specific dataset; if that dataset is poisoned or leaked, the resulting model inherits the problem. Once deployed, every request combines a system prompt (the developer's hidden instructions), the user's message, and often retrieved content, all packed into a context window measured in tokens.
Machine learning systems built around an LLM commonly add retrieval-augmented generation, known as RAG: a vector database stores document embeddings, and relevant passages are pulled in at query time so the model can answer from an organization's own data. Many applications go further and give the model tools — the ability to call an AI agent that can search the web, query a database, send an email, or run code — turning a text generator into an actor inside the business.
A simple way to see where risk enters: untrusted input (a user message, a web page, an uploaded file) flows into the same channel as privileged instructions (the system prompt). The model processes both together and produces output that may contain sensitive data pulled from retrieval, or a command intended for a tool. If that output is trusted blindly by a downstream system, a human decision or an automated action follows. Every one of those handoffs — input to prompt, prompt to model, model to tool, tool to action — is a place where context engineering choices either contain risk or let it flow straight through.
Why LLM Security Is Different from Traditional Cybersecurity
Traditional application security, cloud security, and API security still matter for an LLM application — the firewall at the network edge and the authentication layer in front of the API have not become obsolete. What changes is that an LLM adds a new, probabilistic layer on top: the same input can produce different outputs, instructions and data travel through the same natural-language channel, and the model's own behavior is not fully predictable even to the team that built the application.
This is why LLM security cannot be reduced to any single neighboring discipline. AI safety is broader and includes societal concerns about model behavior at large. Privacy focuses on personal data rights. Responsible AI covers fairness and appropriate use. AI security and machine-learning security focus on protecting models and pipelines from tampering. LLM security overlaps with all of them but is specifically about protecting the system — model, data, integrations, and users — from adversarial manipulation.
Discipline | Primary Focus | Typical Question It Answers |
|---|---|---|
LLM security | Protecting the model, data, prompts, and integrations from attack | Can an attacker manipulate this system into leaking data or taking a harmful action? |
AI safety | Preventing broad harms from AI behavior and capability | Could this model's behavior cause harm even without an attacker? |
Privacy | Rights over personal data collection and use | Is personal data handled lawfully and with consent? |
Traditional application security | Protecting software from conventional vulnerabilities | Is the code free of injection, auth, and access-control flaws? |
Machine-learning security | Protecting models and training pipelines from tampering | Can the model or its training data be poisoned or stolen? |
The practical difference security teams feel first: an LLM cannot reliably tell an instruction from a piece of data it is merely supposed to read, emergent behavior means new capabilities appear without being explicitly programmed, and the underlying foundation model can change on the provider's schedule, shifting an application's risk profile overnight. None of this makes firewalls, access control, or encryption irrelevant — it means they now sit alongside AI-specific controls, not instead of them.
The LLM Threat Model: Assets, Attackers, Trust Boundaries, and Attack Surfaces
A threat model starts with what needs protecting. For a typical LLM application that includes: user prompts and conversation history, the system prompt and any hidden instructions, API keys and credentials used by the app, training and retrieval data, model weights, embedding vectors and indexes, proprietary documents, tool permissions, business workflows the model can trigger, user identities, the outputs themselves and any decisions made from them, inference budget and availability, logs and telemetry, and the organization's brand and regulatory standing.
Threat actors are more varied than a typical web application faces: external attackers crafting malicious input, malicious or careless insiders, compromised suppliers in the model or data supply chain, publishers of poisoned public content that a RAG pipeline might ingest, automated abuse at scale, and ordinary users who trigger harmful behavior by accident.
The central design principle is the trust boundary. Everything that enters the model's context — a retrieved document, a tool's output, an uploaded file, a web page, an email — should be treated according to its actual trust level, not according to how convincingly it reads. A webpage written in fluent, authoritative-sounding English is not more trustworthy than one written poorly; both are untrusted content unless proven otherwise.
Threat-modeling checklist: What can reach the model's context that the model's author did not write? What can the model's output reach without a human checking it first? Which tools can the model call, and with whose credentials? What happens if the model is simply wrong, not attacked? Where are the trust boundaries drawn, and are they enforced outside the model, not just inside a system prompt?
The OWASP Top 10 for LLM and Generative AI Applications
The OWASP Gen AI Security Project published the OWASP Top 10 for LLM Applications 2025 on November 17, 2024, and as of this article it remains the most current official edition; check genai.owasp.org for any newer revision [1]. It ranks the ten most critical risk categories in real LLM applications. The list below follows that official order and numbering.
LLM01:2025 Prompt Injection
What it means: an attacker crafts input, direct or hidden inside content the model reads, that the model follows as an instruction instead of treating as data [1][7]. Example: in 2025, security researchers disclosed EchoLeak (CVE-2025-32711), a zero-click flaw in Microsoft 365 Copilot where a single crafted email caused the assistant to silently exfiltrate sensitive documents when a user later asked it to summarize their inbox [8]. Impact: unauthorized actions, data leakage, and privilege escalation. Misconception: a stronger system prompt fixes this — it does not, since the same channel carries both instructions and data. Preventive controls: separate trusted instructions from untrusted content, least privilege for any tool the model can call, and human approval for high-impact actions. Detective controls: monitoring for anomalous tool calls and repeated injection patterns. Response: revoke affected credentials and patch the ingestion path. Residual limitation: no known method eliminates prompt injection completely.
LLM02:2025 Sensitive Information Disclosure
What it means: the model reveals confidential data from its training set, its context, or connected systems. Example: an internal assistant with broad document access answers a question by quoting a file the requesting employee was never authorized to see. Impact: regulatory exposure and loss of customer trust. Misconception: filtering obvious keywords like “confidential” is sufficient — sensitive content rarely announces itself. Preventive controls: data minimization, redaction before content reaches the model, and enforcing the same access controls at retrieval time that apply everywhere else. Detective controls: output scanning for sensitive-data patterns. Response: rotate any exposed credentials and review the leak's scope. Residual limitation: a model that has seen data during fine-tuning can sometimes reproduce fragments of it later.
LLM03:2025 Supply Chain
What it means: risk introduced through third-party models, datasets, plugins, or libraries the application depends on. Example: a fine-tuning dataset downloaded from a public repository contains hidden poisoned samples. Impact: a compromised model ships to production without anyone noticing. Misconception: open-source models are inherently less safe than hosted ones — supply-chain risk exists in both, just at different points. Preventive controls: verify model provenance and hashes, pin dependency versions, and scan third-party components. Detective controls: continuous vulnerability monitoring of the AI stack. Response: rollback to a known-good model version. Residual limitation: full reproducibility of a model's training run is rarely possible.
LLM04:2025 Data and Model Poisoning
What it means: an attacker manipulates training, fine-tuning, or retrieval data to implant a backdoor or bias. Example: an attacker seeds a public forum with content designed to be scraped into a future training set. Impact: hidden triggers that make the model behave maliciously under specific conditions. Misconception: poisoning requires access to the model provider — poisoning a RAG index an organization controls is often much easier. Preventive controls: data provenance tracking, ingestion validation, and isolated evaluation before promoting new data. Detective controls: statistical anomaly detection in training and retrieval data. Response: retrain or rebuild the affected index. Residual limitation: subtle poisoning can be very hard to detect after the fact.
LLM05:2025 Improper Output Handling
What it means: model output is passed to a downstream system, such as a browser, database, or shell, without validation. Example: a coding assistant's suggested command is executed automatically and includes an unintended destructive instruction. Impact: cross-site scripting, SQL injection, or remote code execution, using the model as the delivery mechanism. Misconception: because the output “sounds right,” it must be safe to use directly. Preventive controls: treat all model output as untrusted, apply the same encoding and validation used for any user input. Detective controls: schema enforcement and output-format checks. Response: sandbox and roll back the affected action. Residual limitation: validation only catches what it was designed to check for.
LLM06:2025 Excessive Agency
What it means: an agent has more functionality, permissions, or autonomy than its task requires [1]. Example: a scheduling assistant is also able to send external email, and a manipulated prompt uses that unrelated permission to exfiltrate data. Impact: unauthorized transactions, data loss, or system changes. Misconception: a well-behaved model in testing will stay well-behaved once it has broader tool access in production. Preventive controls: least privilege, scoped and short-lived credentials, and human approval for high-impact actions. Detective controls: complete audit trails of every tool call. Response: revoke the agent's credentials and review affected transactions. Residual limitation: any permission granted can eventually be misused if the model is manipulated.
LLM07:2025 System Prompt Leakage
What it means: the hidden instructions and configuration in a system prompt are exposed to users [1]. Example: a user simply asks, “What were you told at the start of this conversation?” and receives the full system prompt, including any embedded secrets. Impact: competitors learn the product's logic, and any embedded credentials or business rules are exposed. Misconception: system prompts are a secure, private channel — they are not, and developers should assume they may eventually surface. Preventive controls: never place secrets, credentials, or sensitive business logic inside a system prompt; enforce sensitive rules outside the model. Detective controls: monitor for prompts asking about instructions or configuration. Response: rotate anything exposed and move that logic to server-side enforcement. Residual limitation: some leakage risk remains as long as instructions and conversation share one context.
LLM08:2025 Vector and Embedding Weaknesses
What it means: weaknesses in how a RAG pipeline stores and retrieves embeddings [1]. Example: a multi-tenant vector database lacks per-tenant access controls, so one customer's query can retrieve another customer's private documents. Impact: cross-tenant data leakage and retrieval manipulation. Misconception: adding retrieval automatically makes an application's answers more trustworthy — a poisoned or misconfigured index can make them less trustworthy. Preventive controls: document-level authorization enforced at retrieval time, tenant isolation, and ingestion validation for anything entering the index. Detective controls: monitoring retrieval logs for unusual access patterns. Response: rebuild the index and re-apply access controls. Residual limitation: embeddings themselves can sometimes be partially reversed to recover fragments of source text.
LLM09:2025 Misinformation
What it means: renamed from “Overreliance” in the 2025 edition, this risk covers the model confidently generating false information, invented citations, or incorrect facts [1]. Example: a legal-research assistant produces a well-formatted but entirely fabricated case citation. Impact: bad business or legal decisions made on confident-sounding but false output. Misconception: fluent, well-structured language is proof of accuracy — it is not; a model's writing quality is unrelated to its factual correctness. Preventive controls: ground answers in retrieval from verified sources, require citations, and route high-stakes answers to human review. Detective controls: automated fact-checking against trusted sources. Response: correct and retract affected outputs. Residual limitation: no current LLM can guarantee factual accuracy on every answer.
LLM10:2025 Unbounded Consumption
What it means: expanded from the earlier “Denial of Service” category to cover resource and cost abuse as well as availability [1][9]. Example: an attacker sends inputs designed to maximize token generation, or an agent gets stuck in a recursive loop of tool calls, running up a large inference bill overnight. Impact: service outages and unexpected cost spikes. Misconception: cloud auto-scaling alone solves this — it can make an availability problem into an even larger cost problem. Preventive controls: token and rate limits, concurrency caps, budget alerts, and timeouts on agent loops. Detective controls: real-time cost and usage anomaly monitoring. Response: circuit breakers that pause the offending workload. Residual limitation: legitimate spikes in usage can look identical to abuse without additional context.
OWASP Risk | Main Assets at Risk | Highest-Value Control Category |
|---|---|---|
LLM01 Prompt Injection | Prompts, tools, downstream systems | Trust separation and least privilege |
LLM02 Sensitive Information Disclosure | Training data, retrieval content, PII | Data minimization and access control |
LLM03 Supply Chain | Models, datasets, libraries | Provenance verification and SBOM |
LLM04 Data and Model Poisoning | Training and retrieval data | Ingestion validation and isolated evaluation |
LLM05 Improper Output Handling | Downstream apps, databases, code | Output validation and sandboxing |
LLM06 Excessive Agency | Tools, credentials, workflows | Least privilege and human approval |
LLM07 System Prompt Leakage | System prompt, embedded logic | Never store secrets in prompts |
LLM08 Vector and Embedding Weaknesses | Vector store, tenant data | Retrieval-time authorization |
LLM09 Misinformation | Business and user decisions | Grounding and human review |
LLM10 Unbounded Consumption | Availability, budget | Rate limits and circuit breakers |
Prompt Injection and Jailbreaking
Direct prompt injection happens when an attacker types malicious instructions straight into the chat. Indirect prompt injection is more dangerous and far more common in practice: the malicious instruction sits inside content the model reads on someone else's behalf — a web page, an email, an uploaded PDF, a database record, or another tool's output. Stored or persistent injection plants instructions that survive across sessions, for example inside a document a RAG pipeline will keep retrieving. Cross-context injection moves an instruction from one part of a system (a low-privilege document store) into another (a high-privilege action).
Jailbreaking is a related but distinct idea: it means getting a model to ignore its own safety training, often through role-play, hypothetical framing, or gradual escalation, rather than exploiting an external trust boundary. In 2025, Anthropic disclosed that a state-sponsored group convinced its Claude Code agent that it was performing authorized defensive testing, then used that jailbreak to automate 80 to 90 percent of a real espionage campaign against roughly 30 organizations [10].
Prompt injection is not the same as SQL injection, even though both exploit a failure to separate instructions from data. SQL injection can be closed with parameterized queries because SQL has a strict grammar. Natural language has no equivalent strict grammar, so “ignore previous instructions” is only the simplest, most obvious example — real attacks use encoding, foreign languages, role-play, or content hidden in invisible text, tiny fonts, or metadata that a human reviewer would never see. Input filtering for known phrases and a firmer system prompt both help, but neither is a complete boundary, because the underlying separation problem is unsolved.
Layered mitigations that actually reduce risk include: separating trusted instructions from untrusted content at the architecture level, explicit trust labeling of retrieved content, least privilege for every tool, allowlists for what a tool can be called with, strict parameter validation, constrained and reversible actions, human approval for high-impact operations, sandboxing, authentication and authorization enforced outside the model, output validation, content isolation between sources, retrieval-time access controls, per-session transaction limits, and monitoring for anomalous behavior with a safe failure mode when something looks wrong.
Data Security, Privacy, RAG, Embeddings, and Vector Stores
Confidential information can leak from an LLM application in more places than people expect: pasted directly into a prompt by a user, retained by a provider under its data policy, exposed across tenants in a shared deployment, over-retrieved because a RAG pipeline pulls in more than the requesting user is authorized to see, or reconstructed from an embedding that was assumed to be a safe, irreversible representation of the original text.
RAG, including newer patterns such as agentic RAG, reduces one class of problem — the model answering from stale or missing knowledge — while introducing a new security boundary: the vector database itself. A vector store with stale access-control indexes, poisoned documents, or missing per-tenant isolation can hand an attacker exactly the data the rest of the application was built to protect.
Practical controls include data classification and minimization before anything reaches a prompt or an index, encryption and key management for stored data, tenant isolation, document-level authorization checked again at retrieval time (not just at upload time), provenance tracking for ingested content, retention and deletion policies, secrets management so credentials never sit inside documents or prompts, and data loss prevention tooling adapted for AI workflows, sometimes described as AI DLP [6]. None of this amounts to specific legal advice; data-residency and deletion obligations vary by jurisdiction and should be confirmed with qualified counsel.
Agents, Tools, Permissions, and Excessive Agency
A text-only assistant can say something wrong. An agent can do something wrong. The moment a model gains tool calling — the ability to search, query a database, send a message, run code, or trigger a purchase — a language mistake becomes a real-world action. Autonomous agents and intelligent agents that chain multiple tools, or hold memory across a long-running task, multiply that risk further.
This is the confused-deputy problem borrowed from classic security research: a program with more privilege than the party it is acting for gets tricked into misusing that privilege. An LLM should never be treated as the authorization engine itself; permission decisions belong in deterministic policy enforcement outside the model, not inside a prompt the model might be manipulated into ignoring. Anthropic's account of the GTG-1002 campaign is a clear illustration: once an agent was jailbroken, it independently executed the large majority of a multi-stage intrusion using tools it had legitimately been granted [10][13].
Impact Level | Example Actions | Typical Controls |
|---|---|---|
Low | Searching public web content, summarizing a document | Standard logging; minimal extra approval |
Medium | Querying an internal database, drafting an email for review | Scoped credentials, output review before send |
High | Sending external email, executing code, moving money, changing infrastructure | Human approval, short-lived credentials, reversible actions, hard transaction limits |
Durable defense patterns: least privilege and scoped, short-lived credentials for every tool; separate machine identities rather than reusing a human's access; hard transaction and rate limits; mandatory human approval for high-impact actions; strict tool schemas with argument validation; previews before irreversible operations; idempotent actions wherever possible; kill switches that can halt an agent immediately; and complete, tamper-evident audit trails of every tool call.
Supply Chain, Poisoning, and Model Integrity
An LLM application's supply chain includes the foundation-model provider, any open-source model weights, training and fine-tuning datasets, synthetic data generators, embedding models, the libraries and inference servers running everything, plugins and connectors, prompt templates, and the evaluation datasets used to judge quality. A weakness anywhere in that chain can compromise the final application even when the application's own code is flawless.
Data poisoning corrupts training or fine-tuning data to bias or backdoor the model. Model poisoning targets the model artifact directly. Backdoors sit dormant until a specific trigger appears in a prompt. Dependency compromise and tampered model files are conventional supply-chain problems that now apply to model weights and serialization formats, not just source code; unsafe deserialization of untrusted model files is a known, practical risk.
Controls that meaningfully reduce this risk: a software bill of materials extended to cover AI components, signed artifacts and verified hashes for any model or dataset pulled from outside the organization, documented provenance, supplier security assessments, isolated evaluation environments before a new model or dataset is promoted, malware scanning of downloaded artifacts, pinned dependency versions, ongoing vulnerability management, and a tested rollback path to a known-good model version.
Output Handling, Hallucinations, Misinformation, and Unsafe Automation
Model output must be treated as untrusted data, the same way a web application treats any user-supplied string, because it can carry unsafe content into HTML, JavaScript, SQL, shell commands, source code, configuration files, templates, emails, reports, access decisions, or automated business workflows without anyone reviewing it first.
It also helps to keep separate ideas separate: hallucination is the model generating a plausible but false statement with no intent to deceive; misinformation is false information regardless of intent; disinformation implies deliberate deception by a human actor; fabrication often refers specifically to invented citations, sources, or data points; and outdated knowledge or reasoning errors are different failure modes again that require different fixes.
Reliable defenses combine input and output validation, proper encoding for the destination context, schema enforcement so the model's output must match an expected structure before it is used, grounding answers in retrieval from verified sources, source checking and confidence handling, human review for high-impact decisions, deterministic business rules that sit outside the model for anything regulated or safety-critical, safe rendering that never executes model output as code by default, and a firm separation between generation (what the model suggests) and execution (what the system actually does). Fluent, confident-sounding language is never proof that a claim is true.
Model Theft, Extraction, Inversion, and Intellectual Property Risks
Model extraction, sometimes called model stealing, uses large volumes of queries against a public or internal inference API to reconstruct a functionally similar copy of a proprietary model. Training-data extraction and membership inference attempt to recover or confirm the presence of specific records the model was trained on. Model inversion tries to reconstruct representative training inputs from the model's outputs. Prompt and system-instruction extraction, covered under system prompt leakage above, exposes the proprietary logic built into an application's prompts.
These techniques range from demonstrated and practical, such as extracting a system prompt through simple questioning, to theoretical and resource-intensive, such as full model reconstruction through query-based extraction, which typically requires far more queries and access than most attackers have in practice. Presenting every theoretical technique as routinely successful overstates the risk; presenting none of them at all understates it.
Reasonable defenses include rate limits and behavioral monitoring on inference endpoints, query-pattern analysis to spot systematic probing, access segmentation between internal and external API consumers, endpoint security matching any other production API, contractual controls with model providers and customers, and a clear incident-investigation process if extraction is suspected. Watermarking is an active research area but has real limitations and should not be relied on as a sole control.
Availability, Abuse, and Unbounded Consumption
LLM applications introduce cost as an availability problem, not only an uptime problem. Attackers, and sometimes just careless legitimate users, can trigger denial of service through resource-intensive prompts, excessive context length, recursive or looping agents, uncontrolled chains of tool calls, or high-volume automated abuse of a free or lightly rate-limited tier. A stolen API key can quietly run up an enormous inference bill long before anyone notices a service problem.
Practical controls: token and rate limits per user and per API key, concurrency limits, hard budget caps with alerting, timeouts on any agent loop, circuit breakers that pause a workload automatically, response caching for repeated queries, graceful degradation instead of a hard outage, queue controls under load, real-time anomaly detection on both cost and traffic, capacity planning ahead of predictable spikes, and a documented emergency shutdown procedure that a human can trigger quickly.
A Defense-in-Depth Architecture for LLM Security
No single layer of an LLM application should be relied on to catch everything. A practical reference architecture runs from the user and device layer, through identity and access, the application and API gateway, prompt and context construction, the retrieval and data-access layer, the model gateway or endpoint, output validation and policy enforcement, the tool and agent execution environment, logging and monitoring, and finally governance and change management. Model guardrails are one layer inside this stack, not the whole security architecture.
Layer | Main Risk Addressed | Preventive Controls | Detective Controls |
|---|---|---|---|
Identity and access | Unauthorized use of the application or its data | Authentication, least-privilege roles | Access anomaly monitoring |
Prompt and context construction | Prompt injection, context contamination | Trust labeling, source separation | Injection-pattern detection |
Retrieval and data layer | Cross-tenant leakage, poisoned documents | Retrieval-time authorization, ingestion checks | Retrieval audit logging |
Model gateway | Model or configuration drift | Version pinning, provider vetting | Output drift monitoring |
Output validation | Unsafe automation from model output | Schema enforcement, sandboxing | Output anomaly scanning |
Tool and agent execution | Excessive agency | Least privilege, human approval, limits | Full tool-call audit trail |
Governance | Unmanaged AI risk across the organization | Use-case approval, documented ownership | Periodic control review |
The Secure LLM Development Lifecycle
Security works best when it is built into every stage of an AI feature's life, not bolted on before launch: governance and use-case approval, requirements, threat modeling, architecture and design, data acquisition and preparation, model or provider selection, development, testing, deployment, operation and monitoring, change management, incident response, and eventual retirement with secure deletion of data and credentials. Secure-by-design means these choices are made up front; secure-by-default means the safest configuration is what a team gets unless it deliberately opts out.
Lifecycle Gate | Acceptance Criteria Before Moving Forward |
|---|---|
Use-case approval | Business owner and risk classification documented |
Threat modeling complete | Assets, trust boundaries, and abuse cases identified |
Data reviewed | Sensitive data classified, minimized, and access-controlled |
Security testing passed | Prompt-injection and access-control tests completed |
Production readiness | Monitoring, logging, and incident response in place |
Testing, Evaluation, Red Teaming, and Continuous Monitoring
Functional testing checks that a feature works; security testing checks that it cannot be abused; safety evaluation checks for harmful content; red teaming uses adversarial creativity to find what structured testing misses; and continuous production monitoring watches for drift after launch. All of them are needed at the model, application, retrieval, agent, tool, data, and infrastructure layers, and none of them substitutes for the others.
A useful testing program covers prompt-injection testing, access-control testing, data-leakage testing, tool-abuse scenarios, output-handling tests, poisoned-retrieval tests, multilingual and multimodal testing, long-context testing, regression suites so old vulnerabilities do not silently return, abuse-case testing, boundary and failure testing, and honest tracking of false positives, false negatives, and reproducibility across model versions. A single red-team engagement before launch is not sufficient, because both the model and the threat landscape keep changing.
Field | Example Entry |
|---|---|
Test ID / Date | PI-014 / 2026-06-02 |
System / Model Version | Support bot v3.2 / provider model v2026-05 |
Input Source | Uploaded PDF containing hidden instructions |
Expected vs Actual Result | Model should ignore embedded instructions vs. model partially complied |
Severity / Owner / Retest | High / App security team / Scheduled after fix |
Monitoring, Incident Response, and Recovery
Useful monitoring does not mean collecting every user prompt indiscriminately. It means watching authentication events, authorization failures, every tool call, which data sources were retrieved, policy decisions, token and cost anomalies, latency and error-rate changes, repeated injection patterns, unusual output destinations, model or configuration changes, evaluation drift over time, data-ingestion events, and administrative activity — all with privacy-aware logging, redaction, access controls, and a defined retention period.
A workable LLM incident-response lifecycle follows nine stages: preparation, detection, triage, containment, eradication or remediation, recovery, communication and disclosure, lessons learned, and regression testing to confirm the same failure cannot recur. Real incident types worth rehearsing in advance include a leaked secret found inside a system prompt, a poisoned document discovered in a retrieval index, a compromised tool or plugin, an unauthorized action taken by an agent, an unannounced change by a model provider, and a sudden cost-abuse event.
Governance, Compliance, and Third-Party Risk
Governance turns individual controls into an organization-wide program: clear roles and accountability, an inventory of every AI system in use, risk classification, acceptable-use policies, data governance, a vendor and model approval process, meaningful human oversight, change control, documentation, audit evidence, an incident-reporting path, employee training, procurement standards, contractual protections, and an exit or portability plan if a vendor relationship ends.
NIST published its Generative AI Profile, NIST AI 600-1, on July 26, 2024, as a voluntary companion to the AI Risk Management Framework, mapping generative-AI-specific risks to the framework's Govern, Map, Measure, and Manage functions [2][3]. In the European Union, obligations for providers of general-purpose AI models under the EU AI Act took effect on August 2, 2025, with the European Commission's enforcement powers following a year later [11][12]. These frameworks differ in status: some are voluntary technical guidance, others are contractual expectations from customers or insurers, and others are binding law in a specific jurisdiction. None of this is legal advice, and applicability depends on an organization's role, location, and use case; confirm specific obligations with qualified counsel.
This is also where AI governance work concretely lands: deciding who can approve a new model or a new tool integration, how third-party AI vendors are assessed before onboarding, and what evidence the organization can produce if a regulator or customer asks how an AI system is controlled.
Practical LLM Security Checklist and Maturity Roadmap
Checklist — Foundational controls (governance, architecture, identity and access, data):
A named owner exists for AI security risk across the organization.
Every AI system in use is inventoried, including ones adopted informally by individual teams.
Trust boundaries are documented for every place untrusted content can reach a model.
Least-privilege access controls apply to every model, tool, and data source.
Sensitive data is classified and minimized before it reaches a prompt or a retrieval index.
Checklist — Operational controls (RAG and vector stores, models and providers, agents and tools, development, testing, monitoring, incident response, supplier management):
Retrieval-time authorization is enforced, not just upload-time access control.
Every model or provider used has a documented approval and rollback plan.
Every agent tool has a defined impact level and matching approval requirement.
Prompt-injection and access-control tests run before every major release, not only once at launch.
Tool calls, retrieved sources, and policy decisions are logged and reviewed.
An incident-response plan for AI-specific incidents exists and has been tested.
Third-party AI suppliers go through a documented security assessment before onboarding.
Maturity Level | Typical Characteristics | Most Important Next Step |
|---|---|---|
Level 1: Ad Hoc | AI adopted informally, no inventory, no clear owner | Name an owner and build an AI system inventory |
Level 2: Managed | Basic access controls and logging exist for known AI systems | Document trust boundaries for each system |
Level 3: Defined | Written policies, approval process, and testing standards | Formalize a repeatable secure development lifecycle |
Level 4: Measured | Metrics tracked for incidents, testing coverage, and drift | Automate detective controls and regression testing |
Level 5: Adaptive | Continuous monitoring feeds back into policy and architecture | Extend the program to new agentic and multimodal use cases |
The Future of LLM Security
Several trends are already reshaping the field rather than merely being forecast. Agentic AI, where models plan and act across multiple tools with less human involvement, is expanding the practical impact of excessive agency; OWASP's Gen AI Security Project has begun publishing agentic-specific guidance, including a State of Agentic AI Security and Governance report in 2026, alongside its established LLM Top 10 [14]. Multimodal models that process images, audio, and video widen the attack surface to include instructions hidden inside non-text content. Longer context windows and persistent memory increase how much untrusted material a single session can hold.
Other developments are more plausible than proven: fully autonomous security operations run end-to-end by AI, reliable provenance and identity standards for AI-generated content, and standardized, comparable evaluation methods across vendors. Smaller local and on-device models shift some risk away from centralized providers and toward endpoint security instead. None of this changes the fundamental pattern: new integrations create new places where untrusted content meets privileged instructions, and the organizations that treat that pattern as a permanent design constraint, not a bug to be patched away, will manage the risk best.
FAQ
What does LLM security actually mean?
LLM security means protecting a large language model application — the model, its training and retrieval data, prompts, integrations, agents, and outputs — from manipulation, data leakage, and misuse. It is distinct from using an LLM as a security tool, and it normally covers the entire application and operational environment around the model, not just the model file itself.
Why do LLMs create new security risks that older software didn't have?
LLMs process instructions and data through the same natural-language channel and cannot always tell them apart. Their behavior is probabilistic rather than fixed, they can exhibit emergent capabilities that were not explicitly programmed, and the underlying foundation model can change on a provider's schedule. Traditional controls like access control and encryption still matter, but they are no longer sufficient by themselves.
Is LLM security the same as AI safety?
No. AI safety is a broader field concerned with preventing harm from AI behavior generally, including harms that have nothing to do with an attacker. LLM security is narrower and specifically adversarial: it focuses on protecting a system from being manipulated, exploited, or abused by a malicious or careless actor.
Can prompt injection be completely prevented?
Not with current techniques. Layered defenses — trust separation, least privilege, output validation, human approval for high-impact actions — significantly reduce the risk and its impact, but no method available today eliminates prompt injection entirely, which is why OWASP still ranks it as the top LLM risk [1].
What is the difference between prompt injection and jailbreaking?
Prompt injection exploits the fact that a model cannot separate trusted instructions from untrusted data it is processing, often through content an attacker does not control directly, such as a webpage. Jailbreaking is getting the model itself to ignore its own safety training, typically through role-play or gradual escalation within the conversation the attacker controls directly.
Does adding RAG make an LLM application more secure?
Not automatically. Retrieval-augmented generation can reduce hallucination by grounding answers in real documents, but it also introduces a new attack surface: the vector database and retrieval pipeline. A misconfigured or poisoned RAG system can expose more sensitive data than a model without retrieval at all.
How can sensitive data leak out of an LLM application?
Common paths include a user pasting confidential information into a prompt, a provider's data-retention policy, cross-tenant leakage in a shared deployment, retrieval pulling in documents a user should not see, and system prompts or logs that are eventually exposed. Data classification, minimization, and retrieval-time access control address most of these paths.
Should a system prompt ever contain secrets?
No. System prompts should be treated as likely to leak eventually, since a user can often extract them just by asking. API keys, credentials, and sensitive business rules belong in server-side logic enforced outside the model, never inside the prompt itself.
Why do AI agents increase security risk compared to a simple chatbot?
A chatbot can only produce text. An agent with tool access can send emails, run code, query databases, or move money. That turns a language mistake or a successful prompt injection into a real-world action, which is why OWASP treats excessive agency as one of its most significant expanded risk categories [1].
What can LLM guardrails actually do, and what can't they do?
Guardrails can filter obviously harmful requests, catch known attack patterns, and enforce basic output formatting. They cannot guarantee a model will never be manipulated, cannot replace access control and least privilege enforced outside the model, and should be treated as one layer in a defense-in-depth architecture rather than a complete solution.
How should a team test an LLM application for security?
Combine prompt-injection testing, access-control testing, data-leakage testing, tool-abuse scenarios, output-handling checks, and poisoned-retrieval tests, run continuously rather than once. Automated regression suites catch reintroduced vulnerabilities, while periodic red teaming finds issues structured testing misses.
Are open-source models more or less secure than hosted commercial models?
Neither is categorically more secure. Open-source models offer more transparency and control over the supply chain but shift responsibility for vetting weights, dependencies, and hosting infrastructure onto the deploying team. Hosted models shift day-to-day operational security to the provider but reduce visibility and control. Supply-chain risk exists in both models, just at different points.
How often should LLM security testing happen?
At minimum, before every major release and whenever the underlying model version changes, since model updates can change behavior in ways that reopen previously fixed issues. Mature programs run continuous automated testing alongside periodic, deeper red-team exercises rather than treating any single test cycle as sufficient.
Which framework should an organization start with?
Most organizations get the most practical value starting with the OWASP Top 10 for LLM Applications for concrete risk categories and controls, then layering in NIST AI 600-1 for a broader governance structure as the program matures [1][2]. Larger or regulated organizations should also map obligations under frameworks like the EU AI Act where applicable [11].
What are the first LLM security controls a small team should implement?
Four moves cover a large share of real-world risk with limited effort: enforce least privilege on every tool the model can call, validate and never blindly execute model output, log every tool call and retrieved data source, and name one person or role accountable for AI security decisions.
Key Takeaways
LLM security protects the full system around a model, not just the model file: prompts, training and retrieval data, tools, agents, and outputs all count.
Prompt injection remains unsolved and ranks as OWASP's top LLM risk for a reason — models cannot reliably separate instructions from data [1].
Agents multiply risk because they turn language mistakes into real actions; least privilege and human approval for high-impact actions are the highest-leverage controls.
Defense in depth beats any single guardrail. Model-level controls, access control, output validation, and monitoring all need to work together.
Real, documented incidents — EchoLeak, the Slack AI disclosure, and Anthropic's GTG-1002 report — show these are current, active risks, not theoretical ones [8][9][10].
Governance frameworks like NIST AI 600-1 and the EU AI Act give structure to an AI security program, but neither replaces hands-on technical controls [2][11].
Testing and monitoring must be continuous. A single pre-launch red-team exercise is not enough given how quickly models and threats change.
Actionable Next Steps
Inventory every AI system currently in use, including ones adopted informally by individual teams.
Map trust boundaries for each system: identify every place untrusted content can reach a model's context.
Apply least privilege to every tool an agent can call, and require human approval for high-impact actions.
Add retrieval-time authorization to any RAG pipeline, not just upload-time access control.
Start logging every tool call, retrieved source, and policy decision for later review.
Run prompt-injection and access-control tests before the next release, and repeat them on a schedule.
Name a single owner accountable for AI security risk and reporting.
Glossary
Agent: An LLM-based system that can take actions — calling tools, running code, or querying other systems — rather than only generating text.
Agentic AI: AI systems built around agents that plan and execute multi-step tasks with reduced human involvement.
AI safety: The broader field of preventing harmful AI behavior and outcomes, distinct from the adversarial focus of LLM security.
Context window: The maximum amount of text, measured in tokens, an LLM can consider at one time for a given request.
Data poisoning: Deliberately corrupting training, fine-tuning, or retrieval data to bias or backdoor a model.
Embedding: A numeric vector representation of text that captures its meaning, used to compare and retrieve similar content.
Excessive agency: An OWASP risk category describing an agent with more functionality, permissions, or autonomy than its task requires [1].
Fine-tuning: Further training a pre-trained model on a smaller, task-specific dataset to adapt its behavior.
Foundation model: A large, general-purpose model trained on broad data that can be adapted to many downstream tasks.
Guardrail: A control, often a filter or policy check, meant to keep a model's input or output within acceptable bounds.
Hallucination: A model generating plausible-sounding but false or unsupported information without intent to deceive.
Indirect prompt injection: Prompt injection delivered through content the model reads on someone's behalf, such as a webpage or document, rather than typed directly by the attacker.
Inference: The process of running a trained model to generate a response to a given input.
Jailbreak: Getting a model to ignore its own safety training, typically through role-play, framing, or gradual escalation.
Large language model: A neural network trained on large volumes of text to understand and generate natural language.
LLM security: The practice of protecting large language model systems and their surrounding data, integrations, and users from manipulation, exploitation, and misuse.
Membership inference: An attack that tries to determine whether a specific record was part of a model's training data.
Model extraction: Using queries against a model's API to reconstruct a functionally similar copy of it.
Model inversion: An attack that attempts to reconstruct representative training inputs from a model's outputs.
Model poisoning: Directly corrupting a model artifact, often to implant a hidden backdoor triggered under specific conditions.
Prompt injection: Manipulating a model's behavior by crafting input that it follows as an instruction rather than treating as data.
Retrieval-augmented generation: An architecture where relevant documents are retrieved from a data store and added to a model's context before it generates an answer, commonly abbreviated RAG.
System prompt: The hidden instructions a developer gives a model to define its behavior before a user's message is added.
Token: A small chunk of text, often part of a word, that is the basic unit an LLM processes.
Tool calling: A model's ability to invoke external functions, APIs, or systems as part of generating a response.
Vector database: A data store optimized for searching by similarity between embeddings rather than exact keyword match.
Zero Trust: A security model that verifies every request and enforces least privilege rather than assuming anything inside a network boundary is trustworthy.
Sources & References
[1] OWASP Gen AI Security Project. “OWASP Top 10 for LLM Applications 2025.” Published November 17, 2024. https://genai.owasp.org/llm-top-10/
[2] National Institute of Standards and Technology. “NIST AI 600-1: Artificial Intelligence Risk Management Framework — Generative Artificial Intelligence Profile.” Published July 26, 2024. https://doi.org/10.6028/NIST.AI.600-1
[3] National Institute of Standards and Technology. “AI Risk Management Framework (AI RMF 1.0).” Published January 2023. https://www.nist.gov/itl/ai-risk-management-framework
[4] MITRE Corporation. “MITRE ATLAS — Adversarial Threat Landscape for Artificial-Intelligence Systems.” https://atlas.mitre.org/
[5] NSA Artificial Intelligence Security Center, CISA, FBI, ASD ACSC, CCCS, NCSC-NZ, and NCSC-UK. “Deploying AI Systems Securely” (Cybersecurity Information Sheet). Published April 15, 2024. https://media.defense.gov/2024/Apr/15/2003439257/-1/-1/0/CSI-DEPLOYING-AI-SYSTEMS-SECURELY.PDF
[6] Cybersecurity and Infrastructure Security Agency. “Joint Guidance on Deploying AI Systems Securely.” Published April 15, 2024. https://www.cisa.gov/news-events/alerts/2024/04/15/joint-guidance-deploying-ai-systems-securely
[7] OWASP Gen AI Security Project. “LLM01:2025 Prompt Injection.” https://genai.owasp.org/llmrisk/llm01-prompt-injection/
[8] Securance. “Prompt Injection: The OWASP #1 AI Threat in 2026” (coverage of EchoLeak, CVE-2025-32711). https://www.securance.com/blog/prompt-injection-the-owasp-1-ai-threat-in-2026/
[9] VentureBeat. “Prompt Injection Is Exploiting Enterprise AI's Biggest Design Flaws.” Reporting on the PromptArmor Slack AI disclosure, August 2024. https://venturebeat.com/security/prompt-injection-is-exploiting-enterprise-ais-biggest-design-flaws-by-targeting-agents-rag-pipelines-and-model-routers
[10] Anthropic. “Disrupting the First Reported AI-Orchestrated Cyber Espionage Campaign.” Published November 13, 2025. https://assets.anthropic.com/m/ec212e6566a0d47/original/Disrupting-the-first-reported-AI-orchestrated-cyber-espionage-campaign.pdf
[11] DLA Piper. “Latest Wave of Obligations Under the EU AI Act Take Effect: Key Considerations.” Published August 2025. https://www.dlapiper.com/en-us/insights/publications/2025/08/latest-wave-of-obligations-under-the-eu-ai-act-take-effect
[12] Baker McKenzie. “General-Purpose AI Obligations Under the EU AI Act Kick in From 2 August 2025.” https://www.bakermckenzie.com/en/insight/publications/2025/08/general-purpose-ai-obligations
[13] MITRE ATT&CK. “Anthropic AI-Orchestrated Campaign, Campaign C0062.” https://attack.mitre.org/campaigns/C0062/
[14] OWASP Gen AI Security Project. “State of Agentic AI Security and Governance.” Published June 1, 2026. https://genai.owasp.org/resource/state-of-agentic-ai-security-and-governance/


