An AI assistant connected to your documents, tickets, source code and databases is one of the most useful tools you can give a team — and one of the most interesting targets you can give an attacker. Conversations with an assistant are often more candid than emails, and the assistant itself can read far more data than any single employee.
This article explains the main risks specific to large language model (LLM) applications and the guardrails we build into every AI assistant we deliver. It is written for engineering leaders, security teams and product owners who need a realistic picture rather than hype.
Why AI assistants need their own threat model
Traditional applications have clear boundaries between code and data. An LLM blurs that line: instructions and data arrive through the same channel — text. A sentence inside a document can be interpreted by the model as a command. That single property is the root of the most important new class of vulnerabilities.
At the same time, all the classic risks still apply: weak authentication, over-privileged service accounts, insecure APIs, missing logging, secrets in configuration files. A secure assistant is mostly good, boring engineering plus a few LLM-specific controls.
Risk 1: Prompt injection
Direct prompt injection happens when a user types instructions designed to override the system prompt: “ignore your previous instructions and…”. Indirect prompt injection is more dangerous: the malicious instruction is hidden in content the assistant reads — a web page, an email, a PDF, a code comment or a support ticket submitted by an outsider.
Imagine a support assistant that summarizes incoming tickets and can look up customer records. An attacker submits a ticket containing hidden text instructing the assistant to include another customer’s data in its reply. If the assistant has broad permissions and no output controls, it may comply.
What actually reduces the risk:
- Least privilege for the assistant. The model should only be able to reach data and tools the current user is allowed to use. If the model cannot access it, injection cannot exfiltrate it.
- Separate trusted and untrusted content. Mark retrieved documents and external content clearly as data in the prompt, and instruct the model never to follow instructions found inside them. This helps, but never rely on it alone.
- Human confirmation for side effects. Any action that sends, deletes, pays or changes something should require explicit user approval with a clear preview.
- Output filtering. Block responses that contain secrets, credentials, or data from records the user is not entitled to.
- Restrict outbound channels. Do not let the assistant render arbitrary external images or links from untrusted content; these are classic exfiltration paths.
Risk 2: Sensitive data leakage
Leakage can occur in several ways:
- Over-broad retrieval. The search index contains HR, finance and legal documents, and the assistant retrieves them for anyone who asks.
- Training on sensitive data. Fine-tuning on raw data bakes secrets into model weights.
- Logs and telemetry. Prompts and responses are logged in plain text to a system with weaker access controls.
- Third-party processing. Data is sent to services outside your agreed data boundary.
Controls that work:
- Security trimming at retrieval time. Store access control metadata with every chunk and filter by the user’s identity and group membership on every query.
- Data classification before indexing. Decide which repositories are in scope. Exclude secrets stores, personal data and privileged legal material unless there is a clear need and control.
- Secret scanning in the pipeline. Scan source code and documents for keys, passwords and tokens before they reach the index.
- Private deployment. Run the model endpoint, search and storage inside your own cloud subscription with private networking, so your data and intellectual property stay under your control.
- Log hygiene. Treat conversation logs as sensitive data: encrypt them, restrict access, define retention and redact where possible.
Risk 3: Excessive agency and insecure tool use
Modern assistants can call tools: query a database, create a ticket, run code, send a message. Every tool is an API with permissions. Common failure modes include giving the assistant a database account with write access “for convenience”, or letting it execute generated SQL without validation.
Guardrails:
- Expose narrow, purpose-built tools instead of generic ones (“get order status by ID” rather than “run any SQL”).
- Use read-only credentials unless writing is essential, and scope them per user.
- Validate tool arguments in code, not in the prompt.
- Run code execution in an isolated sandbox without network access to internal systems.
- Rate-limit tool calls and alert on unusual patterns.
Risk 4: Insecure output handling
Model output is untrusted input to whatever consumes it. If your application renders the assistant’s answer as HTML, a crafted answer could inject scripts. If it passes generated code or commands to another system, that system must validate them. Apply the same encoding and validation you would apply to user input.
Risk 5: Denial of wallet
LLM calls cost money. An attacker — or a buggy integration — can generate thousands of long requests and run up a large bill. Protect yourself with authentication on every endpoint, per-user quotas, maximum context and output sizes, budget alerts in your cloud subscription and caching for repeated questions.
Risk 6: Overreliance and misinformation
Not every risk is an attack. Users may trust a fluent but wrong answer. Ground answers in retrieved sources, show citations, define the assistant’s scope clearly and train users to verify critical information. For high-stakes domains, keep a human in the loop.
A layered architecture for a secure assistant
| Layer | Controls |
|---|---|
| Identity | Single sign-on, MFA, conditional access, per-user tokens passed to back-end services |
| Network | Private endpoints for model, search and storage; no public data stores; egress restrictions |
| Data | Classification, secret scanning, encryption at rest, per-chunk access metadata |
| Retrieval | Security trimming, source allow-lists, freshness filters |
| Orchestration | System prompt with scope rules, untrusted-content tagging, token budgets |
| Tools | Narrow APIs, least privilege, argument validation, confirmation for side effects |
| Output | Secret and PII filters, HTML encoding, citation requirements |
| Operations | Audit logs, anomaly alerts, quotas, budget alerts, incident runbooks |
Threat modeling your assistant
We recommend a short, structured threat modeling session before go-live. Map the data flows — user, front end, orchestrator, search index, model, tools, logs — and walk through each element asking what could be spoofed, tampered with, repudiated, disclosed, denied or elevated (the classic STRIDE categories). Our guide to threat modeling for software teams explains the method step by step.
Testing: red-team before your users do
- Build a library of injection attempts, including indirect ones embedded in documents and tickets.
- Test as users with different roles to verify that trimming works.
- Try to make the assistant reveal its system prompt, credentials or other users’ data.
- Verify that all side-effecting tools require confirmation.
- Re-run these tests whenever the model, prompt, tools or data sources change.
Implementation checklist
- ☐ Inventory every data source and decide what is in scope.
- ☐ Enforce per-user access control at retrieval time.
- ☐ Deploy model, search and storage privately in your own subscription.
- ☐ Scan for secrets before indexing; never fine-tune on sensitive raw data.
- ☐ Give tools least privilege and require confirmation for side effects.
- ☐ Filter and encode outputs.
- ☐ Log securely, set retention and monitor for anomalies.
- ☐ Add quotas and budget alerts.
- ☐ Run a threat model and a red-team exercise before launch.
Conclusion
AI assistants are secure when they are engineered like any other critical system — with least privilege, defense in depth and good observability — plus a small set of LLM-specific controls. The organizations that get this right gain a powerful productivity tool without turning it into a liability.
Want an independent review of your AI assistant or a secure implementation in your own Azure environment? Talk to us — the first consultation is free.