Quick answer

To secure an AI chatbot, keep secrets out of the system prompt, give the bot access only to the data and tools it needs, enforce authorization outside the model, treat all user and retrieved content as untrusted, sanitize everything the bot outputs, rate-limit usage, log conversations for abuse, and re-test regularly because models and attacks change.

Key takeaways

  • Assume your system prompt will eventually be read by a user — never put secrets in it.
  • Authorization belongs in your backend, not in the prompt.
  • Everything the model reads (user input, web pages, documents) can contain instructions.
  • Re-test after every model, prompt or data-source change — and at least quarterly.

Most AI chatbot leaks don't come from exotic attacks. They come from a handful of predictable mistakes: secrets in prompts, over-broad data access, and trusting the model to enforce rules it was never designed to enforce. Use this checklist before launch and again every quarter.

Prompt and configuration

  1. No secrets in the system prompt. API keys, internal URLs, discount codes, staff names and business logic you wouldn't publish should never appear in prompts. Assume the prompt will be extracted. See our guide to preventing system prompt leakage.
  2. Clear scope in the instructions. Tell the bot what it's for and what it should decline. This doesn't stop a determined attacker, but it reduces accidental misuse.
  3. Pin the model version. Know exactly which model you're running and re-test when you upgrade. Behavior can change significantly between versions.

Data access

  1. Least-privilege data access. The chatbot should only be able to retrieve data the current user is already allowed to see.
  2. Authorization outside the model. Enforce permissions in your API or retrieval layer using the authenticated session — never by asking the model to "only show the user their own orders."
  3. Scrub sensitive fields. Strip or mask PII, payment data and internal notes before content reaches the model. Read more in how to stop your chatbot leaking customer data.
  4. Secure your RAG pipeline. Document-level permissions must carry through to your vector database. See securing RAG and vector databases.

Input and injection

  1. Treat all input as untrusted — including web pages, PDFs, emails and product reviews the bot reads. Any of them can carry indirect prompt injection.
  2. Separate instructions from data. Clearly delimit retrieved content and tell the model it is reference material, not instructions. Helpful, but not a guarantee.
  3. Cap input length to limit abuse and very long jailbreak payloads.

Output and actions

  1. Encode and sanitize output. Never render model output as raw HTML. Block or proxy markdown images and links, which can be used to exfiltrate data.
  2. Limit agent permissions. If the bot can take actions (refunds, emails, account changes), give it the narrowest tools possible and require confirmation for anything sensitive.

Operations

  1. Rate limits and spend caps per user, per IP and overall.
  2. Logging and alerting for extraction attempts, repeated refusals and unusual tool use — with retention and privacy rules for the logs themselves.
  3. Regular adversarial testing. Re-test at least quarterly and after every material change. This is exactly what a CertiSafe AI certification covers.

Tip: Print this list and add an owner and a "last checked" date next to each item. If you can't name an owner, that control probably isn't happening.

Frequently asked questions

How often should an AI chatbot be security tested?

At minimum every quarter, and additionally whenever you change the underlying model, system prompt, connected data sources or tool permissions. New jailbreak and extraction techniques are published constantly, so a chatbot that passed six months ago may not pass today.

Is a content filter enough to secure a chatbot?

No. Content filters help with harmful output but do not stop data leaks caused by over-broad data access, missing authorization checks or secrets embedded in prompts. Security comes from limiting what the chatbot can reach and do, with filters as one extra layer.

What is the most common AI chatbot security mistake?

Giving the chatbot access to more data than the current user is allowed to see and relying on the system prompt to tell it not to share. Instructions in a prompt are not access control and can be bypassed with prompt injection.

Get certified against the leaks covered in this article

CertiSafe AI tests your live AI features every quarter and gives you a verifiable stamp for your website.

Schedule a Meeting