Treat an AI feature as a new access path into your systems. Apply the same identity and least-privilege rules as the rest of the application, keep system instructions, retrieved content and user input separate, validate every tool call on the server and recheck permissions before consequential actions. Log decisions without hoarding sensitive text, and re-test for prompt injection and data leakage whenever models, prompts or data change.
Treat the AI feature as a new access path
A model can expose or act on data through prompts, retrieval and tools. Apply the same identity and least-privilege principles used for the rest of the application.
Map what the feature can reach
List every data source the model can read, every tool it can call and every user role that can reach it. If a user cannot open a record in the normal interface, the AI feature must not be able to read it to them either.
Secrets and credentials
Never place API keys, connection strings or internal URLs in prompts or retrievable content. Keep credentials on the server, scope each key to the narrowest use and rotate keys on a schedule and after any suspected exposure.
Threat-model the feature
Ask who might misuse the feature and how: a user trying to see another tenant's data, a document planted with hidden instructions, or an attacker running up usage costs. Write the likely attacks down, decide which control stops each one, and turn them into test cases.
Use a framework to organise the work
NIST's AI Risk Management Framework, released in January 2023 for voluntary use, and its Generative AI Profile, released in July 2024, give enterprise teams a shared vocabulary for identifying and managing AI risk. They help assign ownership; they do not replace application security controls.
Separate instructions, data and actions
System policy, retrieved content and user input should have clear boundaries. Tool execution must validate structured arguments on the server and recheck the user's permission for every consequential action.
Why prompt injection is first on the list
Prompt injection is the first entry in the OWASP Top 10 for LLM applications. Text inside a document, email or web page can carry instructions the model may follow. Treat retrieved content as data, never as instructions, and never let a model's output decide on its own whether an action is allowed.
Constrain tools
Give each tool the narrowest permission it needs, require structured arguments, validate them in ordinary code and run consequential actions with the end user's identity rather than a powerful service account. OWASP lists excessive agency as a separate risk for exactly this reason.
Filter retrieval by permission
Apply access rules when content is retrieved, not after the model has seen it. Store tenant and permission metadata with every indexed passage, filter on it in the search itself, and keep separate indexes where isolation requirements are strict.
Handle output as untrusted
OWASP also lists improper output handling. Model output that is inserted into a web page, a database query or another system can carry injected content, so encode, validate and sanitise it like any other user-supplied input.
Log what matters
Record model version, relevant context identifiers, tool calls, approvals, outcomes and user feedback without retaining unnecessary sensitive text.
- Identity and authorisation decision
- Model and prompt configuration version
- Sources used for grounded answers
- Tools requested and executed
- Approval, correction and escalation events
Logs are evidence
Good logs let you answer three questions after an incident: who asked for what, which data and tools were involved, and who approved the result. Design the log format with the people who will investigate incidents, not only with the developers who write the code.
Personal data and impact assessments
Prompts and logs can contain personal data. Ireland's Data Protection Commission explains that a data protection impact assessment is mandatory where processing is likely to result in a high risk to people's rights and freedoms, and that it should be carried out before the processing starts. Decide retention periods and redaction rules for prompts and outputs at design time.
Monitor for abuse
Watch for unusual patterns: a user sending many near-identical requests, prompts that try to reveal system instructions, or a sudden rise in cost for one tenant. Alert on them and rate-limit automatically, so a single misuse does not become an outage or a large bill.
What not to keep
Full prompts and responses are useful for debugging but can hold personal or confidential data. Prefer identifiers and hashes over raw text, redact known sensitive fields, restrict who can read the logs and delete them on a schedule.
Make decisions reviewable
When a user asks why the system did something, the logs should show which sources, tools and approvals were involved. Clear Talent, a founder-owned venture built by Seditio, keeps human approval in its agentic workflows for this reason; see the Clear Talent case study.
Evaluate continuously
Security testing includes prompt injection, data leakage, over-broad tool use and unsafe output handling. Regression tests should run when models, prompts, retrieval logic or source data change.
Build a red-team set
Collect attempts to extract hidden instructions, reach other users' data, trigger unapproved actions and produce unsupported claims. Run them in CI with the rest of the test suite, and add every real incident as a new case.
Check outputs before users see them
Validate structured outputs against a schema, check that cited sources exist and remove content that breaks your rules. Seditio's Evidence Engine works this way: answers are built from cited passages of seditio.ie and checked before display, and visitors can try to make it say something untrue.
Test with realistic data
Security and quality tests are only meaningful with content that looks like production: long documents, mixed languages, messy formatting and records with restricted fields. Use anonymised or synthetic data that keeps those properties rather than a handful of tidy examples.
Watch the supply chain
Supply chain is another entry in the OWASP list. Models, libraries, plug-ins and datasets come from third parties and change over time. Pin versions, review provider terms on data use and retention, and rerun your evaluation and red-team sets before adopting a new model version.
Separate test and production models
Try new prompts, models and tools in a test environment with the evaluation and red-team sets before they reach users. Keep the production configuration under change control, so every change to what the model sees or can do is reviewed and reversible.
Prepare for AI incidents
Decide in advance what counts as an AI incident, such as data shown to the wrong user or an unapproved action, who is told, and how the feature is switched off. Practise the switch-off before you need it.
Operate it like production software
Set budgets and rate limits, monitor cost and latency, and keep a way to switch the AI feature off without taking the product down. For delivery support, see AI implementation services, custom AI development and LLM application development.
Sources
- 2025 Top 10 Risk & Mitigations for LLMs and Gen AI Apps, OWASP Gen AI Security Project
- LLM06:2025 Excessive Agency, OWASP Gen AI Security Project
- AI Risk Management Framework, National Institute of Standards and Technology (NIST)
- Data Protection Impact Assessments, Data Protection Commission (Ireland)