Generative AI applications introduce risks that traditional security reviews were not designed to catch. The model follows instructions written in natural language, and it cannot reliably tell the difference between instructions from you and instructions hidden in a document, email or web page it was asked to read. Combine that with access to private data and tools that take actions, and you have a new attack surface.
This guide covers the main risks, drawing on the themes in the OWASP Top 10 for LLM Applications, and the practical controls our generative AI development team builds into every assistant and agent.
Why generative AI needs its own threat model
In a traditional application, code and data are separate: user input is data, and well-written code never executes it. In an LLM application, instructions and data share the same channel, the prompt. Anything that ends up in the context window can influence behaviour. That means your threat model must include every source the model reads and every action it can trigger, not just the chat box.
The main risks at a glance
| Risk | What it looks like | Primary defence |
|---|---|---|
| Prompt injection | Input or retrieved content tells the model to ignore its rules or misuse tools | Treat content as untrusted, limit tools, require approvals |
| Sensitive information disclosure | The model reveals personal data, secrets or other users' documents | Permission filtering at retrieval, data minimisation, output checks |
| System prompt leakage | Users extract hidden instructions, including any secrets placed there | Never put secrets or access rules in prompts |
| Excessive agency | An agent takes harmful actions with broad permissions | Narrow tools, least privilege, human approval |
| Improper output handling | Model output is executed or rendered unsafely, for example as script or SQL | Validate, encode and sanitise output like any user input |
| Data and model poisoning | Tampered documents or training data change behaviour | Source control, review of ingested content, provenance |
| Unbounded consumption | Abuse drives up cost or degrades service | Rate limits, quotas, input size limits, monitoring |
The OWASP list also covers supply chain risks, weaknesses in vector and embedding stores, and misinformation. The table focuses on the risks that most often appear in business assistants and agents.
Prompt injection: direct and indirect
Direct prompt injection is a user typing instructions to subvert the system, such as asking it to ignore previous rules and reveal its configuration. Indirect prompt injection is more dangerous: the instructions are hidden in content the model reads on someone's behalf, such as a web page, a PDF uploaded to a support portal, an inbound email or a product review. A user asks for a harmless summary, and the hidden text tells the model to send data elsewhere or call a tool.
There is currently no complete technical fix for prompt injection, so the defence is to limit what a successful injection can achieve. Assume the model can be manipulated, and make sure that when it is, it cannot reach data the user is not entitled to, and cannot take consequential actions without a person approving them.
Data leakage
Leaks happen in three main ways. First, retrieval returns documents the user should not see, which is why permissions must be applied when searching, as described in our RAG explainer. Second, staff paste confidential data into public AI tools; an AI usage policy and approved internal tools address that. Third, prompts and logs containing personal data are sent to or stored by third parties; check provider data-use and retention terms, which are part of choosing an LLM, and minimise what you send. For regulated sectors such as healthcare and fintech, map these flows explicitly against your compliance obligations.
Excessive agency
Agents, which our guide to AI agents versus chatbots explains, raise the stakes because a manipulated model can act, not just talk. Give each tool one narrow purpose, run it with the end user's permissions rather than a powerful service account, set value and volume limits, and require human approval for anything irreversible, financial or external, such as sending email to new recipients.
Defence in depth
Authentication, rate limits, size limits, screening for known attack patterns and sensitive data.
Per-user permission filtering, trusted sources only, untrusted content clearly marked as data.
Clear instructions, no secrets in prompts, models and settings chosen for the risk level.
Least privilege, narrow tools, approvals for consequential actions, spending limits.
Validate structure, encode before rendering, never execute output directly, check for sensitive data.
Logs of prompts, sources, tool calls and outputs; alerts; an incident process with a kill switch.
No single layer stops every attack. Each one limits what gets through the others.
DivTech SystemUnderneath these sit the usual application and cloud controls: secrets management, encryption, network restrictions and identity management. Our cloud consulting team and the guide to cloud security best practices cover that foundation.
Supply chain and ownership
Generative AI applications depend on more third parties than most software: model providers, downloaded open-weight models, embedding services, vector databases, agent frameworks and plugins. Download models only from their official publishers, pin library and model versions, review what each plugin or connector can access, and keep an inventory of every AI component in production. Just as important, give every assistant and agent a named owner who approves new tools, reviews incidents and decides when to retire it. Many problems in practice come not from clever attacks but from features added quickly with broad permissions and no one accountable.
Logging, monitoring and red-teaming
Log enough to investigate an incident: the user, the prompt, which sources were retrieved, every tool call with its parameters and result, and the final output. Apply retention and masking rules, because these logs may themselves contain personal data. Alert on unusual patterns such as spikes in refusals, repeated tool errors or sudden cost increases.
Red-teaming means deliberately attacking your own application before someone else does: injection attempts through every input channel, including uploaded files and retrieved pages; attempts to access other users' data; jailbreaks of content rules; and abuse of tools. Turn every successful attack into a regression test. Our software testing and QA team runs these tests alongside functional checks, and our guide to testing AI and LLM applications covers building them into your release process.
- Retrieval filtered by user permissions
- No secrets or access rules in prompts
- Provider data-use and retention terms reviewed
- Personal data minimised in prompts and logs
- Tools narrow and least-privilege
- Approvals for irreversible or financial actions
- Output validated and encoded before use
- Rate limits and spending caps set
- Full logging with retention rules
- Red-team tests run and turned into regression tests
- Incident process and kill switch documented
- Staff AI usage policy published
Build it in from the start
Security is far cheaper to design in than to add after an incident. DivTech includes threat modelling, permission design, logging and red-team testing in every generative AI project. If you are planning an assistant or agent, or want an existing one reviewed, request a quote and we will scope a security review alongside the build.
Frequently asked questions
What is prompt injection?
It is an attack in which text supplied by a user or hidden in content the model reads, such as a document or web page, causes the model to ignore its instructions, reveal information or misuse its tools.
Can prompt injection be fully prevented?
Not completely with current techniques. The practical approach is to limit the impact: enforce permissions outside the model, give agents narrow tools, require approval for consequential actions, validate output and monitor behaviour.
Is it safe to let employees use public AI chat tools?
It can be, with a clear policy on which data may be entered, approved tools with suitable data-use terms, and training. Without a policy, confidential or personal data often ends up in tools the company does not control.
What is the OWASP Top 10 for LLM Applications?
It is a community-maintained list from the OWASP Foundation of the most important security risks in applications built on large language models, including prompt injection, sensitive information disclosure and excessive agency. It is a useful checklist for threat modelling.