undefined
contact@undefined.qa العربية

HomeResearchR.01

Sovereign AI Needs Secure AI: Security Risks in Self-Hosted Models and Agents

Many organizations in Qatar now run language models on their own infrastructure instead of sending data to an external AI service. This gives real benefits, but it also makes the organization responsible for security work that a commercial provider would otherwise carry out.

01Why organizations host models themselves

The main reason is data residency. Sector regulators, government contracts and internal policies often restrict where personal, financial and commercial data may be processed. When a model runs on servers inside the organization, prompts, documents and outputs stay within its own network and within Qatar.

The second reason is control. The organization chooses which model version runs, how it is configured, what it is connected to and when it is updated. It can also audit the whole system.

02Self-hosting moves the security burden

A commercial AI service handles authentication, rate limiting, logging, patching, abuse monitoring and isolation between customers. When the model runs internally, each of these tasks becomes the organization's responsibility.

A typical deployment adds several new components: a model server, model files downloaded from public sources, a retrieval system that indexes internal documents, and an agent framework that lets the model call tools. Each one handles sensitive data and needs the same review as any other internal system. The weaknesses below are common because these components are often deployed quickly and with default settings.

03Prompt injection through content the model reads

What it is

A language model cannot reliably tell the difference between instructions from its operator and text it reads while doing a task. When a model summarizes an email, reads a web page or processes an uploaded file, text inside that content can be treated as an instruction. This is known as indirect prompt injection.

Why it matters

In a simple chat assistant the result may be a wrong or misleading answer. In a system connected to internal data or tools, injected text can lead the model to reveal information or take actions the user never asked for. No current model resists this reliably, so the system around the model has to limit the risk.

Controls

  • Treat all content the model reads as untrusted input, including internal documents and email.
  • Limit what the model can do after it has read untrusted content, so that a successful injection has little effect.
  • Keep secrets and credentials out of prompts and system instructions.
  • Validate and log model output before it is passed to other systems or shown as a trusted result.

04Agents with excessive tool permissions

What it is

An AI agent is a model that can call tools: send email, query databases, read and write files, run code or call internal APIs. During development, agents are often given a broad service account for convenience, and that account stays in place in production.

Why it matters

The permissions of an agent set the limit of damage from any failure, whether the cause is prompt injection, a model error or a faulty workflow. An agent that can write to a production database or send messages outside the organization can do so at the wrong time.

Controls

  • Apply least privilege to every tool. Grant only the actions and data each task needs, and prefer read-only access.
  • Run tool calls with the identity and permissions of the requesting user where possible, not a shared administrator account.
  • Require human approval for sensitive actions such as payments, deleting records, sending external messages and changing access rights.
  • Keep an audit log of every tool call, its parameters and its result.

05Unauthenticated model servers on internal networks

What it is

Common inference servers are designed to be easy to start. Many listen on a network port without authentication by default and accept requests from anyone who can reach them. Some also expose management functions, such as loading, replacing or deleting models.

Why it matters

An internal network is not a security boundary on its own. Any compromised workstation or any user on the same network can send requests to an open model server, use its computing capacity, read logged prompts or change the model it serves.

Controls

  • Require authentication on every model endpoint, for example through an authenticating reverse proxy or API gateway with a separate key for each application.
  • Use network segmentation. Place model servers in a segment that only approved applications can reach, and bind them to specific interfaces.
  • Disable management functions that are not needed, or restrict them to administrators.
  • Encrypt traffic between services with TLS and keep inference software up to date.

06Retrieval systems that ignore document access controls

What it is

Retrieval systems let a model answer questions from an organization's own documents. Documents are split into passages, indexed and passed to the model when they are relevant to a question. In many implementations all documents go into one shared index, and the access permissions of the original files are lost.

Why it matters

A user who cannot open a document in the file share or document management system may still receive its contents through the assistant. Personnel records, legal advice and customer data can become available to every employee who uses the tool. The model cannot be relied on to withhold information once it has been placed in its context.

Controls

  • Store the access permissions of each source document with its indexed passages.
  • Enforce the user's permissions at retrieval time, by filtering search results before any content reaches the model.
  • Test with accounts at different access levels to confirm that restricted content is not returned.

07Unverified model files from public repositories

What it is

Open model weights are usually downloaded from public repositories where anyone can publish, and where names can imitate well-known publishers. Some model file formats, in particular those based on Python's pickle serialization, can run code when the file is loaded.

Why it matters

Loading an untrusted model file can run code on the server with the permissions of the inference process. A model can also be modified to behave differently in specific situations, which is difficult to detect through normal use.

Controls

  • Download models only from verified publishers, and record the source and version of every model in use.
  • Verify file hashes against the values published by the original source before deployment.
  • Use safe formats that store only data, such as safetensors, and do not load pickle-based files from unknown sources.
  • Evaluate new models in an isolated environment, and run inference processes with minimal operating system privileges.

08Pre-production checklist

Before a self-hosted AI system handles real data, confirm the following.

  • Every model endpoint requires authentication and is reachable only from approved network segments.
  • Each agent tool has a documented purpose and the minimum permissions it needs.
  • Sensitive actions require human approval and are logged.
  • Content read by the model is treated as untrusted, and injection scenarios have been tested.
  • Retrieval enforces each user's document permissions, confirmed with test accounts at different access levels.
  • Model files come from verified sources, their hashes have been checked, and safe formats are used.
  • Personal data processed by the system has been identified, with a documented purpose and retention period.
  • An independent security assessment has been completed and its findings addressed.

09A note on Qatar's data protection law

Qatar's Personal Data Privacy Protection Law (Law No. 13 of 2016) applies to personal data processed by AI systems in the same way as to any other processing. Self-hosting can help an organization keep data in Qatar, but it does not by itself make processing lawful or secure.

The law requires controllers to take appropriate measures to protect personal data against loss, damage and unauthorized access, and to report breaches to the National Cyber Security Agency. Organizations should review their AI deployments against the law and the agency's guidance, and take legal advice for their specific situation.

Undefined CyberSecurity Solutions carries out security assessments of self-hosted AI systems, including model servers, agents and retrieval systems. Every engagement requires a signed services agreement and written testing authorization.

Contact: contact@undefined.qa