Making AI features safe: hallucinations, privacy and security

Safe AI features ground answers in trusted sources, protect personal data, treat every input as potentially hostile, limit what the AI is allowed to do, keep humans in the loop for important decisions, and are tested and monitored continuously. Most AI failures in apps are predictable, and most can be prevented with good design.
We build AI features for businesses where mistakes matter, so safety is part of every project in our AI product development work. This guide covers the main risks and practical defences. For regulation, see the EU AI Act and UK rules for AI apps.
The main risks
| Risk | What it looks like |
|---|---|
| Hallucination | Confident but wrong answers |
| Data leakage | Personal or confidential data shown to the wrong person or sent where it should not go |
| Prompt injection | Text from users, documents or websites that tricks the AI into ignoring its rules |
| Excessive agency | The AI takes actions it should not, such as refunds or deletions |
| Harmful or off-brand output | Offensive, biased or inappropriate content |
| Cost abuse | Users or bots running up large AI bills |
The OWASP Top 10 for LLM Applications is a useful reference.
Reducing hallucinations
- Ground answers in your content using retrieval. See RAG for business.
- Instruct the model to answer only from sources and say when it does not know.
- Show citations so users can check.
- Use structured outputs for data tasks, validated by code.
- Check numbers and facts in code where possible, such as prices and dates.
- Test against real questions, including ones with no answer in your content.
Protecting personal data
- Send only the data needed for each request.
- Mask or remove personal data from prompts where possible.
- Respect user permissions when retrieving documents.
- Choose providers with suitable data terms and locations; check whether data is used for training.
- Log responsibly, with retention limits.
- Follow UK GDPR. See UK GDPR for mobile apps.
Defending against prompt injection
Prompt injection happens when instructions are hidden in content the AI reads: a user message, an uploaded document, an email or a web page. Defences:
- Treat all external content as untrusted data, not instructions.
- Keep system instructions separate from user and document content.
- Never rely on the prompt alone for security; enforce permissions in code.
- Limit tools the AI can call and validate every tool input.
- Test with known injection techniques before launch.
Limiting what AI can do
- Give the minimum tools and permissions needed.
- Require confirmation for important actions.
- Set limits, such as maximum refund amounts.
- Identify users from their authenticated session, never from what they type.
- Log every action with the reasoning.
Content safety
- Use provider safety features and your own filters for sensitive topics.
- Define off-limits subjects for your brand.
- Provide a way to report bad answers.
- Review samples regularly.
Testing and monitoring
| Activity | Frequency |
|---|---|
| Evaluation on your test set | Every prompt, model or data change |
| Red-teaming with adversarial inputs | Before launch and major changes |
| Sample review of real conversations | Weekly at first, then monthly |
| Cost and usage monitoring | Continuous, with alerts |
| User feedback review | Weekly |
See keeping AI running costs under control for cost limits.
Mobile-specific points
- Never put AI provider keys in the app; call through your backend.
- Validate everything server-side.
- For on-device AI, protect models and local data. See on-device AI on iPhone and our mobile app security checklist.
Human oversight
For decisions that affect people's money, health, jobs or access to services, keep a person in the loop. AI can draft, suggest and prioritise; people decide.
A pre-launch safety checklist
- Answers are grounded in approved sources, with citations where useful.
- The feature says "I don't know" when sources do not cover a question.
- Personal data sent to the AI is minimised and documented in the DPIA.
- Provider terms on data retention and training have been checked.
- System instructions are separate from user and document content.
- Permissions and limits are enforced in code, not only in prompts.
- Important actions require user confirmation.
- Red-team testing has been completed, including prompt injection attempts.
- Cost limits and alerts are in place.
- Users can report bad answers, and someone reviews them.
- There is a plan to switch the feature off quickly if needed.
A worked example: a support assistant
A retailer adds an AI assistant to answer order and returns questions. It retrieves policies and the customer's own orders, never other customers' data, because access is checked in code using the logged-in session. It can explain the returns policy and start a return, but refunds over a set amount go to a person. Every conversation is logged, and a weekly sample is reviewed for accuracy and tone.
See AI agents inside apps for how agents are designed.
The short version
- Ground answers in trusted sources and show citations.
- Minimise and protect personal data.
- Treat all inputs as untrusted; enforce rules in code.
- Limit AI actions and confirm important ones.
- Test, red-team and monitor continuously.
Want a safety review of your AI feature? Book a call.
Frequently asked questions
Can hallucinations be eliminated completely?
Not completely, but grounding, validation and good design reduce them to manageable levels for most business uses.
Is it safe to send customer data to AI providers?
It can be, with the right provider terms, data minimisation and legal basis. Check where data is processed and whether it is used for training.
What is prompt injection in simple terms?
Hidden instructions in text that try to make the AI ignore its rules. Treat outside text as data, not commands.
Who is responsible if the AI gets something wrong?
Your business is responsible for how AI is used in your app. Design, test and monitor accordingly.
Should we tell users they are talking to AI?
Yes. Being clear builds trust and is increasingly expected by regulators.
Talk it through with one of our co-founders. 30 minutes, no pressure.




