AI Chatbot Security Best Practices: Protecting Data in Conversational AI
How to secure AI chatbots against prompt injection, data leaks and misuse, meet UK GDPR requirements and avoid costly incidents, with a practical security checklist.

In January 2024, a customer trying to track a missing parcel with DPD’s online chatbot grew frustrated and started testing its limits. Within a few messages, the bot was swearing, calling itself useless and writing a poem about how bad the company was. The screenshots were viewed more than a million times, and DPD disabled the AI element of its chatbot, blaming an error after a system update. No customer data was stolen, yet the incident showed how quickly a poorly controlled chatbot can become a public problem.
Chatbots now sit on the front line of customer service, often connected to CRMs, order systems, payment platforms and account data. That makes them attractive targets and potential sources of data leaks, fraud and reputational damage. Following AI chatbot security best practices is no longer optional for any organisation deploying conversational AI.
Generative AI adds new risks to familiar ones. Traditional application security still matters: authentication, encryption, API security and access control. On top of that come threats specific to large language models, such as prompt injection, system prompt leakage and “excessive agency”, where a bot can take actions it should not. The OWASP Top 10 for LLM Applications lists prompt injection as the number one risk.
This guide is for CISOs, CTOs, IT and security managers, compliance officers and business leaders in UK and US organisations. It explains the main chatbot vulnerabilities, the controls that address them, UK GDPR and compliance considerations, lessons from real incidents, and a practical checklist for secure conversational AI.
Why Chatbot Security Is Different
A chatbot is unusual among business applications because it accepts free text from anyone and responds with generated text, sometimes taking actions in connected systems. This creates three distinct risk areas:
- Input risks. Malicious users craft messages to manipulate the model, extract data or bypass rules.
- Output risks. The bot generates harmful, inaccurate, offensive or confidential content.
- Action risks. Connected bots can read or change data, trigger workflows or make commitments on your behalf.
Each needs its own controls, alongside standard infrastructure security.
Key AI Chatbot Vulnerabilities
| Vulnerability | What happens | Example impact |
|---|---|---|
| Prompt injection | User input or hidden instructions override the bot’s rules | Bot ignores policies, reveals data or performs unintended actions |
| Sensitive information disclosure | Bot reveals personal, confidential or internal data | Data breach, regulatory penalties |
| System prompt leakage | Attackers extract hidden instructions and configuration | Exposes business logic and aids further attacks |
| Excessive agency | Bot has more permissions than it needs | Unauthorised refunds, account changes or data access |
| Insecure output handling | Generated content passed unchecked to other systems | Cross-site scripting, injection into downstream tools |
| Misinformation | Confident but wrong answers | Customer harm, liability, complaints |
| Unbounded consumption | Abuse drives excessive model usage | Runaway costs, service outages |
| Weak authentication | Account data shared without proper verification | Account takeover, fraud |
Chatbot Security Best Practices
1. Apply Least Privilege and Chatbot Access Control
Give the chatbot access only to the data and actions each journey needs. A bot answering delivery questions does not need to change bank details. Use separate service accounts per function, scope API credentials tightly and review permissions regularly. For high-impact actions, require human approval or step-up authentication.
2. Strong Chatbot Authentication
Keep account-specific conversations inside authenticated sessions such as your app or logged-in website. If authentication happens within the chat, use secure methods (one-time passcodes, app confirmation) rather than easily guessed personal details. Never reveal whether an account exists to an unauthenticated user.
3. Defend Against Prompt Injection
No single technique eliminates prompt injection, so layer defences:
- Separate system instructions from user input and treat all user and retrieved content as untrusted
- Use input filters to detect known manipulation patterns
- Validate outputs against policies before displaying them or passing them to other systems
- Restrict tool use so even a manipulated model cannot perform high-risk actions
- Test regularly with adversarial prompts, including indirect injection hidden in documents or web content the bot reads
4. Protect Sensitive Data
- Minimise personal data collected in conversations
- Mask or redact card numbers, bank details and identifiers in logs
- Encrypt data in transit (TLS) and at rest using strong, current standards
- Set clear retention periods for transcripts and delete data when no longer needed
- Check model provider terms to confirm your data is not used for training and is processed in suitable locations
5. Secure the Chatbot API Layer
Chatbot API security deserves as much attention as the model. Use OAuth with scoped tokens, rotate secrets, validate every input, apply rate limiting, monitor for unusual patterns and log every call. Treat the chatbot as an untrusted client of your internal APIs, not a privileged insider.
6. Ground Answers and Filter Outputs
Use retrieval from approved content so answers are based on verified information. Add output moderation to block offensive, off-brand or out-of-scope responses. For pricing, contracts and policies, pull facts from systems rather than letting the model generate them.
7. Control Costs and Abuse
Set limits on message length, conversation length and requests per user. Monitor model spending in real time and alert on spikes. Use bot detection to block automated abuse.
8. Monitor, Log and Respond
Log conversations, tool calls and security events in a way that supports investigation without over-retaining personal data. Monitor for anomalies, review samples regularly and have an incident plan that includes the ability to disable AI features quickly, as DPD did.
9. Test Before Every Release
Updates to prompts, models or integrations can change behaviour unexpectedly. The DPD incident followed a system update. Run regression tests, safety tests and adversarial tests before every release, not just at launch.
GDPR Compliant Chatbots: UK Data Protection Essentials
Chatbots process personal data, so UK GDPR and the Data Protection Act 2018 apply. Key requirements include:
- Lawful basis for processing conversation data
- Transparency: tell users they are talking to AI and explain how their data is used
- Data protection impact assessments for high-risk processing, which generative AI chatbots handling personal data often are
- Data processing agreements with model and platform providers
- International transfer safeguards where data leaves the UK
- Individual rights, including access, deletion and objection, applied to chat transcripts
- Automated decision rules where chatbot outputs have significant effects on people
Sector rules add further obligations, such as FCA Consumer Duty in financial services and clinical safety standards in healthcare. Our AI security and governance services help organisations meet these requirements in practice.
Real-World Lessons: When Chatbots Go Wrong
DPD (UK, 2024). The challenge was a customer service chatbot with a generative AI element and insufficient guardrails. After a system update, a frustrated customer persuaded it to swear and criticise the company. DPD disabled the AI element and updated it. The outcome was widespread negative coverage from a single conversation. The lesson: test after every update, apply output filtering and ensure customers can reach a human when the bot cannot help.
Air Canada (Canada, 2024). The airline’s chatbot gave a customer incorrect information about bereavement fares. A Canadian tribunal ruled that Air Canada was responsible for its chatbot’s statements and ordered it to compensate the customer. The lesson: ground policy answers in approved content, because businesses remain liable for what their bots say.
Neither incident involved a sophisticated attack. Both show that everyday security and governance, such as testing, guardrails and grounding, prevent most chatbot failures.
Secure AI Architecture Checklist
| Area | Control |
|---|---|
| Identity | Authenticated sessions, step-up verification for sensitive actions |
| Permissions | Least privilege, scoped API credentials, human approval for high-impact actions |
| Input | Filtering, length limits, untrusted treatment of all user and retrieved content |
| Output | Moderation, policy validation, safe rendering |
| Data | Minimisation, redaction, encryption, retention limits |
| Providers | Data processing agreements, no-training settings, suitable hosting regions |
| Operations | Logging, monitoring, cost alerts, kill switch for AI features |
| Assurance | Penetration testing, red teaming, regression tests before each release |
| Governance | DPIA, risk register, named owners, incident response plan |
Enterprise Chatbot Security and Risk Management
For larger organisations, chatbot risk management should sit within wider AI governance. Maintain an inventory of every chatbot and AI assistant, assign business and technical owners, classify risk levels and set review cycles. Align controls with established frameworks such as the NCSC’s guidelines for secure AI system development, the OWASP Top 10 for LLM Applications and ISO/IEC 42001 for AI management systems.
IIH Global’s AI chatbot development services build these controls into chatbots from the start, and our AI integration services secure the connections between chatbots and business systems.
Security Questions to Ask Chatbot Vendors
- Where is conversation data processed and stored, and for how long?
- Is our data used to train any models, including the vendor’s or its providers’?
- What prompt injection defences are in place, and how are they tested?
- How are permissions scoped when the chatbot connects to our systems?
- What security certifications does the vendor hold, such as ISO 27001 or SOC 2?
- How are incidents reported, and how quickly can AI features be disabled?
- Can we obtain independent penetration test results?
Clear, specific answers to these questions are a good sign. Vague reassurance is not.
The Future of Chatbot Security
As chatbots evolve into AI agents that take actions across systems, security focus is shifting from what the bot says to what it can do. Expect more emphasis on agent permissions, transaction limits, human-in-the-loop approvals and continuous monitoring. Regulation is tightening too, with the EU AI Act in force and UK regulators applying existing data protection, consumer and sector rules to AI. Organisations that build security and governance in from the start will be able to expand their use of conversational AI with far less risk.
Conclusion
AI chatbot security best practices combine traditional application security with defences for new LLM-specific threats. Least privilege, strong authentication, layered prompt injection defences, data protection, output controls, monitoring and testing before every release form the core. The DPD and Air Canada incidents show that most failures come from missing basics rather than advanced attacks.
If you need to secure an existing chatbot or build a new one safely, contact IIH Global.
Frequently Asked Questions
1. What are the biggest security risks for AI chatbots?
Key risks include prompt injection, sensitive data disclosure, excessive permissions, system prompt leakage, weak authentication, insecure output handling, misinformation and uncontrolled usage costs.
2. What is prompt injection?
Prompt injection is when users or hidden content supply instructions that override a chatbot’s intended rules, potentially causing data leaks, harmful responses or unauthorised actions.
3. How do you make a chatbot GDPR compliant?
Establish a lawful basis, be transparent about AI use, minimise data, complete a DPIA, sign processing agreements with providers, set retention limits and support individual rights.
4. Should chatbot conversations be encrypted?
Yes. Conversations should be encrypted in transit and at rest, with sensitive details redacted from logs and access restricted to authorised staff and systems.
5. How often should chatbots be security tested?
Test before every significant release, including prompt and model changes, and carry out periodic penetration testing and red teaming at least annually or after major updates.





