Table of Contents
Securing an on-premise LLM means controlling four things the model itself cannot: who can reach the inference server, which documents each user can retrieve, what is recorded about every exchange, and what the model is allowed to do when a prompt or document tries to manipulate it. Enforce all four in code and infrastructure, never in the prompt.
Key takeaways
- Self-hosting removes the third-party API, not the attack surface. In 2025, Cisco researchers found 1,139 Ollama servers exposed on the internet, 214 of them serving live models (Cisco).
- Access control belongs in the retrieval layer and the tools, not in the system prompt, which OWASP says should not be used as a security control (OWASP LLM07:2025).
- Log the full prompt, retrieved sources, answer and tool calls, as the UK NCSC and OWASP recommend, and protect the log itself: it is sensitive data.
- Prompt injection may never be fully fixed (NCSC). Design so that a manipulated model can do little damage.
- In Algeria, the amended Law 18-07 adds an automated logbook of personal data processing and a five-day breach notification, according to CMS. Confirm with counsel how it applies.
Why does an on-premise LLM still need securing?
Running the model locally means your prompts and documents are not processed by an outside provider, the main argument of our guide to sovereign, on-premise AI. But the server, the network exposure, the document index, the logs and the incident response are now yours.
Default configurations do not cover this. Ollama, a popular local inference tool, binds to 127.0.0.1 on port 11434 by default, and its FAQ explains how to expose it to the network with OLLAMA_HOST=0.0.0.0 without describing any authentication setting (Ollama FAQ, checked November 2026). Using Shodan, Cisco researchers found 1,139 exposed Ollama instances, 214 of them hosting and answering with live models. Their recommendations: authentication, firewalls or reverse proxies instead of public endpoints, rate limiting and logging (Cisco).
Inside a plant network, the same mistake gives every machine on that network a direct line to the model and the documents it can read.
What are the main threats to an on-premise LLM?
| Threat | Plant example | Main control | Reference |
|---|---|---|---|
| Unauthenticated access to the inference server | A test server on the plant LAN answers anyone who finds the port | Internal network only, authenticating reverse proxy, endpoint allowlist | vLLM security |
| Retrieval of documents the user may not open | A technician asks about salaries and the index returns an HR file | Permission filter at retrieval, from server-side identity | OWASP LLM08 |
| Direct prompt injection | A user types "ignore your instructions" to reach restricted content | Controls outside the model; output checks | OWASP LLM01 |
| Indirect prompt injection | A supplier datasheet or contractor email contains hidden instructions | Sanitise at ingestion, mark untrusted content, limit tools | Greshake et al. |
| Data exfiltration through the answer | The answer contains an image link that sends data to an outside server | Block external links and images; restrict outbound traffic | EchoLeak analysis |
| Secrets in the prompt | A database password is written into the system prompt | Keep credentials out of prompts | OWASP LLM07 |
Supply chain risks, such as tampered model files, are covered in our article on air-gapped AI deployment.
How should access control work for an LLM assistant?
Think in layers. Each one must hold even if the model is manipulated.
Network. Put the inference server on an internal segment that only the application server can reach.
Inference API. Do not rely on the server's built-in key. vLLM's --api-key option protects only endpoints under the /v1, /v2, /inference and /cohere prefixes; other endpoints on the same server, including operational ones that can alter model behaviour, have no authentication. The documentation says not to rely on --api-key alone and recommends a reverse proxy that allowlists the endpoints you expose and blocks the rest (vLLM security, checked November 2026).
User identity. Authenticate users through your existing directory, so leavers lose access when their account is disabled. Keep administrator rights (model updates, index rebuilds, log access) separate.
Retrieval. This is where most of the real access control happens. OWASP warns that misaligned access controls can expose embeddings that contain sensitive information, and recommends permission-aware vector stores and strict partitioning (OWASP LLM08:2025). Copy each document's access groups from the source system onto its chunks, and filter every search by the authenticated user's groups, as shown in our RAG guide for maintenance manuals. OWASP's general rules apply: deny by default, validate permissions on every request, and never rely on client-side checks (OWASP Authorization Cheat Sheet).
Tools. Each tool the model can call checks the user's rights itself, not those of a broad service account.
Not the system prompt. OWASP is explicit: the system prompt "should not be considered a secret, nor should it be used as a security control", credentials and connection strings do not belong in it, and authorisation checks "must not be delegated to the LLM" (OWASP LLM07:2025).
What should an LLM audit log record?
The UK National Cyber Security Centre recommends logging enough to spot suspicious activity, which may mean the full model input and output, plus tool use and API calls. It notes that failed tool or API calls can reveal an attacker's early attempts (NCSC). OWASP adds detailed, immutable logs of retrieval activity (OWASP LLM08:2025).
| Field | Why it matters |
|---|---|
| User, timestamp, source host | The "who, when, where" of every event |
| Full prompt as received | Shows injection attempts and misuse |
| Documents and chunks retrieved, with version | Proves what the answer was based on; detects permission leaks |
| Answer returned | Lets you reconstruct what the user saw |
| Tool calls, parameters and results, including failures | Failed calls are an early warning |
| Model, prompt template and index versions | Explains a change in behaviour after an update |
| Filter or classifier decisions | Shows what was blocked and why |
The OWASP Logging Cheat Sheet asks for the same "when, where, who and what" for each event. It also lists what must not be logged as is, including passwords, session identifiers, access tokens, encryption keys and some personal data, and recommends tamper detection, copying logs to read-only storage quickly, and restricting and periodically reviewing who can read them (OWASP Logging Cheat Sheet).
That last point matters: the log holds every question and every passage returned, so it can be the most sensitive store in the deployment. Keep it on the same infrastructure as the model.
The Algerian angle. Prompts and logs usually contain personal data: names, employee numbers, sometimes health or HR details. According to the CMS guide, Article 38 of Law 18-07 requires technical and organisational security measures appropriate to the risks, and Law 25-11 of 24 July 2025 adds a register of processing activities, "an automated logbook of personal data processing operations" (Article 41 bis 3), a data protection officer, and notification of a personal data breach to the authority within five days (CMS). Agree retention and access to LLM logs with your data protection officer, and confirm with legal counsel how these provisions apply to your system.
What is prompt injection, and why can't it be fully fixed?
OWASP ranks prompt injection first in its 2025 Top 10 for LLM applications. A direct injection comes from the user's own input. An indirect injection arrives in external content the model processes, such as a file or web page. OWASP adds that RAG and fine-tuning do not fully mitigate it (OWASP LLM01:2025).
Indirect injection is the bigger concern for an industrial assistant. Greshake and colleagues showed in 2023 that LLM-integrated applications "blur the line between data and instructions", so an attacker can plant instructions in data the application is likely to retrieve (Greshake et al.). In a plant, that means supplier documentation, contractor emails, scanned forms and work order comments. OWASP's own example is a résumé with instructions hidden in white text on a white background (OWASP LLM08:2025).
Real attacks have used this route. In EchoLeak (CVE-2025-32711), a crafted email retrieved by Microsoft 365 Copilot led it to produce a Markdown link or image whose URL carried private data towards the attacker's server. It was presented as the first zero-click AI vulnerability enabling data exfiltration. The email was written as if addressed to a human, which got it past Microsoft's injection classifiers (Simon Willison). That was a cloud service, but the mechanism applies to any assistant that retrieves untrusted text and renders links.
Why not just fix it? The UK NCSC argues that prompt injection "may never be totally mitigated" the way SQL injection was, because a language model has no internal separation between data and instructions. It calls the model an "inherently confusable deputy" and concludes that the realistic goal is to reduce the likelihood and the impact of attacks (NCSC).
How do you reduce prompt injection risk?
- Avoid the "lethal trifecta". Simon Willison, who coined the term prompt injection, describes the dangerous combination as access to private data, exposure to untrusted content and the ability to communicate externally (Simon Willison). An on-premise assistant always has the first two, so remove the third: no outbound internet from the model servers, and no tool that sends email or calls external URLs.
- Give the model the least privilege possible. Handle privileged functions in code, give the application its own credentials and limit the model to what the task needs (OWASP LLM01:2025). The NCSC suggests that an LLM processing someone's content should not hold more privilege than that party.
- Require human approval for high-risk actions. Any tool that changes a system should pause for a named person. Our article on human-in-the-loop for AI agents explains where to place the gates.
- Mark untrusted content. Wrap retrieved passages in clear delimiters and tell the model they are data. Hines and colleagues report that their "spotlighting" techniques cut attack success from above 50% to below 2% in experiments with GPT-family models (Hines et al.). The NCSC treats such marking as making attacks harder, not impossible.
- Filter inputs and outputs. Classifiers can flag injection attempts. Meta's Llama Prompt Guard 2 86M runs locally, but it reads 512 tokens at a time, and its evaluation languages listed on the model card do not include Arabic (Hugging Face). Test any filter on your own Arabic and French documents before relying on it.
- Do not render external links or images in answers. Strip them, or allow only internal document links. This closes the EchoLeak-style exfiltration path.
- Sanitise documents at ingestion. Detect hidden text and validate documents before they enter the index, as OWASP recommends for RAG (OWASP LLM08:2025).
- Test adversarially and repeat. OWASP recommends regular attack simulations that treat the model as an untrusted user. Add injection cases to the test set you use to evaluate the LLM on your documents and re-run it after every change.
What we have seen at KABAS AI
DALILE runs completely offline on the client's own servers, with encryption, access controls and audit logging, and connects to systems such as SAP, Oracle, Microsoft 365, LIMS and document management systems. Each connection brings permissions to mirror and untrusted text to handle, so we recommend three steps before any pilot.
Map permissions from the source systems first. If rights are unclear in the source system, the assistant will not fix them.
Agree logging with the data protection officer and the security team at the start: what is logged, who can read it and for how long.
Write injection tests alongside accuracy tests. A few planted documents with hidden instructions, in Arabic and French, show quickly whether the controls hold.
When comparing suppliers, our AI project RFP guide and build vs buy analysis list the questions to ask. Our consulting team can review an existing deployment against this checklist.
Sources
- OWASP GenAI Security Project, LLM01:2025 Prompt Injection
- OWASP GenAI Security Project, LLM07:2025 System Prompt Leakage
- OWASP GenAI Security Project, LLM08:2025 Vector and Embedding Weaknesses
- OWASP Authorization Cheat Sheet
- OWASP Logging Cheat Sheet
- UK NCSC, Prompt injection is not SQL injection (it may be worse), December 2025
- Greshake et al., Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection, arXiv 2302.12173, 2023
- Hines et al., Defending Against Indirect Prompt Injection Attacks With Spotlighting, arXiv 2403.14720, 2024
- Simon Willison, The lethal trifecta for AI agents: private data, untrusted content, and external communication, June 2025
- Simon Willison, Breaking down EchoLeak, the first zero-click AI vulnerability enabling data exfiltration from Microsoft 365 Copilot, June 2025
- vLLM documentation: Security
- Ollama FAQ
- Cisco, Detecting Exposed LLM Servers: A Shodan Case Study on Ollama, September 2025
- Meta, Llama Prompt Guard 2 86M model card, Hugging Face
- CMS Expert Guide to data protection and cyber security laws: Algeria
Frequently asked questions
Is an on-premise LLM secure by default?
No. Keeping the model on your servers stops data going to an outside API, but the inference server, the document index, the logs and the tools the model can call all need their own controls. Some inference servers protect only part of their endpoints with an API key, so they should sit behind an authenticating reverse proxy on an internal network.
Can I enforce access rights through the system prompt?
No. OWASP states that the system prompt should not be treated as a secret or used as a security control, because prompt injection can override it. Permissions must be enforced by code outside the model: in the retrieval layer, which filters documents by the authenticated user, and in each tool the model can call.
What should an LLM audit log contain?
At minimum: who asked, when, from where, the full prompt, the documents retrieved, the answer, any tool calls with their parameters and results, and the model version. Passwords, tokens and keys should be removed before logging. Because the log contains personal data and confidential content, its own access must be restricted and reviewed.
Can prompt injection be fully prevented?
Not with current technology. The UK National Cyber Security Centre considers it possible that prompt injection will never be totally mitigated, because language models do not separate instructions from data. The practical aim is to reduce both the likelihood of an attack and the damage it can do, mainly by limiting what the model can access and do.
Does a document assistant with no tools still face prompt injection?
Yes, but the impact is smaller. A hidden instruction in a retrieved document can still distort an answer or try to leak data through a link or image in the response. Sanitising documents at ingestion, citing sources, and blocking external links and images in answers reduce that risk.



