AI security
Security for LLMs, RAG and AI agents
We threat-model, harden and test AI systems before they reach production, then set up the monitoring and incident response that keep them secure in operation.
Last reviewed by SysArt AI Architecture TeamHow we review
In short
AI security protects applications built on large language models from attacks that ordinary application security does not fully cover: prompt injection, leakage of sensitive data through answers, poisoned or tampered models, and agents misusing their permissions. It combines a threat model, layered technical controls, adversarial testing before release, and monitoring with an incident process afterwards.
DefinitionAI security is the protection of AI systems, including their models, data, prompts, tools and supporting infrastructure, against attacks on their confidentiality, integrity or availability and against misuse of the actions they can take.
Key takeaways
- Treat every model input you do not fully control, including retrieved documents and tool results, as potentially hostile.
- No current defence fully prevents prompt injection, so limit what a manipulated model could do through permissions, approvals and output handling.
- Model weights are supply-chain artefacts: verify where they came from, check their integrity and prefer formats that cannot run code when loaded.
- Test like an attacker before release and monitor in production; red teaming finds what the threat model missed.
- For entities in scope of NIS2 or DORA, AI systems used in operations fall within the same risk-management and incident-reporting duties as other ICT systems.
What an AI security engagement delivers
We scope the work to the AI systems you run or plan. These are the controls and evidence we deliver.
-
AI threat model
Assets, trust boundaries, attackers and abuse cases for each AI system, mapped to the OWASP Top 10 for LLM Applications.
-
Prompt-injection defences
Separation of instructions and data, output handling, privilege limits and approvals, designed for direct and indirect injection.
-
Model and package supply chain
Provenance, hash and signature checks for model weights, safe serialisation formats, scanning and a bill of materials.
-
Access control and zero trust
Authenticated, authorised calls to every model, index and tool, with segmented networks and controlled egress.
-
Red teaming and security testing
Adversarial tests of prompts, retrieval, tools and infrastructure before release and after significant changes.
-
Monitoring and incident response
Detection rules, logging and playbooks for AI-specific incidents, connected to your security operations and reporting duties.
What is LLM security, and why is it different?
LLM security protects applications built on large language models against attacks that exploit how those models work. The core difference from ordinary software is that a language model receives instructions and data through the same channel, as text. NIST’s taxonomy of adversarial machine learning describes how attackers use this to steer a model through the data it reads, not only through what users type.
Three further differences shape the controls:
- New assets. Model weights, system prompts, embeddings, vector indexes, agent traces and evaluation sets all need protection.
- Probabilistic behaviour. The same input can produce different outputs, so security testing measures rates, not single results.
- Actions. Once a model can call tools, a manipulated output becomes a manipulated action.
AI security builds on identity, network, secrets and vulnerability management. It does not replace them.
What does a threat model for LLM applications include?
A threat model maps what you protect, where untrusted input enters and what an attacker could achieve. For LLM applications, the entry points are user prompts, retrieved documents, web content, tool results, uploaded files, model artefacts and the software packages around them.
The OWASP Top 10 for LLM Applications 2025 gives a shared vocabulary for these risks: prompt injection (LLM01), sensitive information disclosure (LLM02), supply chain (LLM03), data and model poisoning (LLM04), improper output handling (LLM05), excessive agency (LLM06), system prompt leakage (LLM07), vector and embedding weaknesses (LLM08), misinformation (LLM09) and unbounded consumption (LLM10). MITRE ATLAS, a public knowledge base of adversary tactics and techniques against AI systems, helps describe realistic attack paths. ETSI TS 104 223 sets baseline security requirements across the AI lifecycle. The table further down maps the main threats to controls.
How do you defend against prompt injection?
Assume it will happen, and limit the damage. In direct prompt injection, a user writes instructions that try to override the system’s intended behaviour. In indirect prompt injection, the instructions are hidden in content the system reads, such as a document or a web page, and the attacker never interacts with the application. NIST states that current mitigations do not offer full protection, so the defences are layered:
- Separate and label untrusted content in the prompt, and constrain the model’s role and output format.
- Filter inputs and outputs for known attack patterns and for sensitive data.
- Limit privileges. A manipulated model can only do what its tools and permissions allow.
- Require approval for actions that are hard to reverse.
- Close exfiltration channels. Do not render links or images from model output automatically, and restrict outbound network access.
- Test adversarially, including with documents and tool results that carry planted instructions.
Retrieval systems and agents need these controls most; see enterprise RAG and AI agents for how we apply them there, and our RAG security guide for a threat-by-threat checklist.
How do you prevent sensitive data disclosure?
By controlling what the model can see, not only what it may say. Start upstream, with retrieval that enforces each user’s permissions and with data minimisation in prompts, logs and training sets. Then:
- Keep credentials and connection details out of system prompts. OWASP advises that a system prompt should not be treated as a secret or used as a security control.
- Filter outputs for personal data and secrets where the use case allows.
- Protect vector stores like the documents they index: OWASP warns that embeddings can be inverted to recover much of the original text.
- Treat data used for fine-tuning as visible to everyone who can use the resulting model, because training data can surface in outputs.
- Restrict and monitor access to logs, which can hold some of the most sensitive text in the system: prompts, retrieved passages and answers together.
How do you secure the AI model supply chain?
Treat model weights, adapters, datasets and serving software as supply-chain artefacts that need provenance, integrity checks and patching. OWASP points out that published models carry no strong provenance assurances and that a malicious adapter can compromise a trusted base model. The controls:
- Vetted sources and an internal mirror. Bring models from vetted publishers into an internal registry, and let production load only from there.
- Integrity. Record and verify hashes, or sign the models. The Sigstore model-signing project signs a model’s files and lets you verify them before loading.
- Safe formats. Prefer safetensors, a format built to store tensors safely, over Python pickle files. Python’s own documentation warns that malicious pickle data can execute arbitrary code when loaded.
- Scanning and patching. Scan containers and packages for known vulnerabilities, and keep inference engines up to date.
- A bill of materials. Record models, datasets, dependencies and their licences, for example in a CycloneDX machine-learning bill of materials (ML-BOM).
- Evaluation. Test third-party models on your own use cases and red-team them before relying on them.
How does zero trust apply to AI systems?
Zero trust means that no request is trusted because of where it comes from on the network; each one is authenticated and authorised, as NIST SP 800-207 sets out. For an AI platform:
- Every call to a model endpoint, vector index or tool carries an identity and is authorised for that model, that data and that action. Authentication without per-model authorisation lets any signed-in user reach any model.
- Requests carry the end user’s identity all the way to retrieval and tools, so access rules apply at every hop, not only at the front door.
- GPU and inference servers sit in their own network zone without direct internet egress, and traffic between services is encrypted and mutually authenticated.
- Administrative access to models, prompts and indexes is separate from user access, and it is logged.
The on-premises AI reference architecture shows these zones and interfaces.
How do you red-team and security-test LLM applications?
Test the whole system, not only the model. OWASP’s GenAI Red Teaming Guide spans four areas: model evaluation, implementation testing, infrastructure assessment and runtime behaviour analysis. A test plan usually covers:
- direct injection and jailbreak attempts against the system instructions;
- indirect injection through planted documents, emails, web pages and tool results;
- extraction of system prompts, other users’ data and personal data;
- abuse of tools and permissions by agents;
- conventional tests of the APIs, authentication, gateway and serving infrastructure.
Open-source scanners such as garak and PyRIT, both named in NIST’s taxonomy, automate parts of the work; experienced testers find what scanners miss. Because model behaviour varies, attacks run repeatedly and results are reported as rates. Fixes are retested, and the suite runs again whenever models, prompts or tools change.
How do you monitor AI systems and respond to incidents?
Log enough to detect attacks and reconstruct decisions, and connect it to the security operations you already run. Useful signals include repeated injection patterns, unusual tool calls, retrieval of highly sensitive documents, spikes in tokens or cost, and guardrail blocks.
Prepare playbooks for AI-specific incidents: disable a tool or an agent, roll back a model or prompt version, remove a poisoned document and re-index, rotate exposed credentials, and preserve traces as evidence. Map them to your reporting duties. Under NIS2, an early warning of a significant incident is due within 24 hours of becoming aware of it, an incident notification within 72 hours and a final report one month later. DORA requires financial entities to report major ICT-related incidents to their competent authorities.
How do NIS2, DORA and the AI Act shape AI security?
They regulate organisations and systems rather than AI security as a separate topic, but each reaches AI platforms:
- NIS2 (Directive (EU) 2022/2555, to be transposed into national law by 17 October 2024) requires essential and important entities to take cybersecurity risk-management measures, including incident handling, supply chain security and vulnerability handling, and makes senior management accountable. AI systems that an in-scope entity uses in its operations fall under those measures like any other information system.
- DORA (Regulation (EU) 2022/2554, applying since 17 January 2025) covers ICT risk management, incident reporting, resilience testing and ICT third-party risk for financial entities. An AI platform is ICT, and an external model API is an ICT service from a third party. Our financial services page covers the sector view.
- EU AI Act, Article 15 requires high-risk AI systems to be resilient against attempts by unauthorised third parties to exploit their vulnerabilities, and names data poisoning, model poisoning, adversarial examples, confidentiality attacks and model flaws. For Annex III systems, high-risk obligations apply from 2 December 2027.
- Cyber Resilience Act (Regulation (EU) 2024/2847) sets cybersecurity requirements for software and hardware products with digital elements, which matters if you build or sell AI products. Its reporting obligations apply from 11 September 2026 and its main obligations from 11 December 2027.
Scope depends on your sector, size and role, so confirm it with legal counsel. Our EU AI Act guidance covers classification, and our AI governance work turns obligations into evidence.
How SysArt approaches AI security
Bring us in before your AI architecture hardens around assumptions your security team cannot defend. We review the architecture against a threat model, implement the priority controls with your platform and security teams, test the result, and connect monitoring to your existing operations. The approach is the same whether the models run on-premises, in air-gapped environments or with a hosted provider.
How an AI security engagement runs
-
Scope
List the AI systems in scope with their data, users, tools and integrations, and agree the rules of engagement and the regulations that apply.
You receive
- System inventory
- Scope and rules of engagement
-
Threat-model
Map assets, trust boundaries and attack paths for each system, and rate each threat by likelihood and impact.
You receive
- Threat model
- Prioritised risk register
-
Harden
Design and implement controls for the highest risks: access, isolation, injection defences, output handling, supply chain and logging.
You receive
- Control design
- Implemented controls
- Updated architecture
-
Test
Red-team the system with injection, data-extraction, tool-abuse and infrastructure tests, then retest the fixes.
You receive
- Test report
- Retest evidence
-
Monitor and respond
Set up detection, logging and incident playbooks, and connect them to your security operations and reporting process.
You receive
- Detection rules
- Incident playbooks
- Reporting map
Which controls address which LLM threats?
| Threat | OWASP 2025 | Controls |
|---|---|---|
| Direct prompt injection and jailbreaks | LLM01 | Constrained instructions, input and output filtering, least privilege, adversarial testing |
| Indirect prompt injection through documents, web pages or tool results | LLM01 | Separated and labelled external content, no consequential tools without approval, no automatic links or images in answers |
| Sensitive information disclosure | LLM02, LLM07 | Permission-aware retrieval, data minimisation, output filtering, no credentials in system prompts |
| Tampered or malicious models, adapters and packages | LLM03, LLM04 | Vetted sources, hash and signature checks, safe weight formats, scanning, a bill of materials |
| Unsafe use of model output by other systems | LLM05 | Output treated as untrusted: validated, encoded and passed only through parameterised queries |
| Agents misusing tools or permissions | LLM06 | Narrow tools, user-scoped permissions, authorisation in downstream systems, human approval |
| Leakage and poisoning in vector stores | LLM08 | Access partitioning, validated sources, immutable retrieval logs |
| Denial of service and runaway cost | LLM10 | Authentication, rate limits, quotas, input-size limits, timeouts and usage monitoring |
OWASP also lists misinformation (LLM09). It is reduced mainly through grounding, evaluation and human review rather than a security control alone.
Frequently asked questions
What is LLM security?
LLM security covers the risks that arise when an application passes text to a large language model and acts on what comes back. The main ones are prompt injection, disclosure of sensitive data, tampered models and packages, unsafe handling of model output, and agents that misuse their permissions. It builds on application and infrastructure security rather than replacing it.
Can prompt injection be fully prevented?
Not with current techniques. NIST states that current mitigations do not offer full protection, and OWASP notes that retrieval and fine-tuning do not fully mitigate the risk, because language models receive instructions and data in the same channel. The practical answer is defence in depth: separate untrusted content, limit what the model can do, validate its output and require approval for consequential actions.
What is the difference between direct and indirect prompt injection?
In direct prompt injection, the person using the system writes instructions that try to override its intended behaviour. In indirect prompt injection, the instructions are hidden in content the system reads, such as a document, an email, a web page or a tool result. The attacker never interacts with the application, and the person harmed is often its legitimate user.
How do you secure the AI model supply chain?
Download models only from vetted sources into an internal registry, record where each came from, and verify hashes or signatures before loading. Prefer safetensors weights over Python pickle files, which can execute code when loaded. Scan containers and packages, keep a bill of materials with licences, and test third-party models on your own use cases before relying on them.
What does AI red teaming involve?
Testing an AI system the way an attacker would: direct and indirect injection, attempts to extract data or system prompts, abuse of tools, and probes of the serving infrastructure. Open-source scanners such as garak and PyRIT automate parts of the work, and skilled testers cover the rest. Findings are fixed and retested, and the suite reruns when models, prompts or tools change.
Do NIS2 and DORA apply to AI systems?
They apply to organisations, not to technologies. If your organisation is in scope, AI systems used in its operations fall within the risk-management, incident-reporting and supplier-risk duties you already have. Under NIS2, a significant incident needs an early warning within 24 hours. DORA adds ICT risk management, resilience testing and third-party oversight for financial entities. Scope depends on sector and size.
Does running AI on-premises make it secure?
It removes some risks, such as sending prompts and documents to an outside provider, and gives you control over the network, logging and model versions. It does not stop prompt injection, leakage through over-broad retrieval or misuse of tools, which depend on application design. An on-premises AI platform still needs a threat model, controls and testing.
What should we log for AI security monitoring?
Authentication and authorisation events, prompts and responses where policy allows, identifiers of retrieved documents, tool calls with arguments and results, model and prompt versions, guardrail decisions and resource use. Logs need access control, a defined retention period and a feed into your security monitoring, with alerts for patterns such as repeated injection attempts or unusual tool use.
Sources
- OWASP GenAI Security Project: Top 10 for LLM Applications 2025 · checked 27 October 2026
- OWASP GenAI Security Project: LLM01:2025 Prompt Injection · checked 27 October 2026
- OWASP GenAI Security Project: LLM03:2025 Supply Chain · checked 27 October 2026
- OWASP GenAI Security Project: LLM07:2025 System Prompt Leakage · checked 27 October 2026
- OWASP GenAI Security Project: LLM08:2025 Vector and Embedding Weaknesses · checked 27 October 2026
- OWASP GenAI Security Project: GenAI Red Teaming Guide (January 2025) · checked 27 October 2026
- NIST AI 100-2 E2025: Adversarial Machine Learning, a Taxonomy and Terminology of Attacks and Mitigations · checked 27 October 2026
- NIST SP 800-207: Zero Trust Architecture · checked 27 October 2026
- MITRE ATLAS: Adversarial Threat Landscape for AI Systems · checked 27 October 2026
- ETSI: TS 104 223, Baseline Cyber Security Requirements for AI Models and Systems (April 2025) · checked 27 October 2026
- Sigstore: model-transparency, model signing for the ML supply chain · checked 27 October 2026
- Hugging Face: safetensors documentation · checked 27 October 2026
- Python documentation: pickle module security warning · checked 27 October 2026
- CycloneDX: Machine Learning Bill of Materials (ML-BOM) · checked 27 October 2026
- European Commission AI Act Service Desk: Article 15, accuracy, robustness and cybersecurity · checked 27 October 2026
- European Commission: NIS2 Directive · checked 27 October 2026
- European Commission: NIS2 Directive FAQs · checked 27 October 2026
- EIOPA: Digital Operational Resilience Act (DORA) · checked 27 October 2026
- European Commission: Cyber Resilience Act · checked 27 October 2026
Review the security of your AI systems
Bring the AI systems you run or plan, with their data and integrations. We will sketch the threat model with you, name the priority controls and propose a test plan.