AI Chatbot Security Checklist: Input and Output Text Checks

An AI chatbot security checklist starts with the text itself. Every message a user types can carry abuse, personal data, spam or self-harm signals into your prompt, and every reply your model generates can send toxic, adult, self-harm or leaked personal content back to the person reading it. Authentication, rate limiting and prompt-injection defenses matter, but they are system controls — none of them reads the words. This article is a practical checklist for the text layer: what to check on the way in, what to check on the way out, and what your product should actually do when something is flagged. It is written to be useful whether or not you ever buy a moderation product.
What Chatbot Security Means for the Text Layer
A chatbot has two text flows, and both are untrusted:
- Input — anything a user can type or paste: chat messages, pasted documents, transcripts, profile fields reused in a prompt, and tool results that contain user-controlled text. All of it ends up inside your prompt.
- Output — anything the model returns: chat replies, summaries, generated emails, tool arguments, streamed token sequences, and text quoted from retrieved documents.
The AI chatbot security concerns in that layer are consistent across products: harmful or abusive generations, harassment between users, exposure of personal data, minors put at risk, spam and flooding, brand and legal exposure, and the downstream cost of storing or forwarding text you should never have kept.
Two directions: input and output
The general approach is two-sided. Screen input before the prompt is assembled, and screen output before it is rendered. Both checks belong on the server. A browser-side check is advisory at best, because the client is under the user's control.
Where the checks physically sit is an architecture decision. You can call a moderation service inline in the request path, or run it as a separate sidecar and route text through it. The trade-offs — latency budget, what happens when the checker is unavailable, whether you fail open or fail closed — are covered in LLM guardrails best practices.
What moderation flags can and cannot catch
A text classifier is good at telling you that a string contains abuse, personal data or spam. It is not a security boundary on its own, and being explicit with your team about the limits saves confusion later.
- It can catch harmful content classes, personal data patterns and bulk spam in the text itself.
- It cannot tell you whether a reply is factually correct, whether a user is trying to manipulate the model, or whether a message is sarcasm, quoted fiction or a genuine threat.
Content flags do not detect prompt injection. A message can be clean against every category and still try to talk your model out of its instructions. Injection needs separate handling — instruction hierarchy, treating user and retrieved text as untrusted data, tool-call allowlists and output validation — and that work sits outside the text layer described here.
Input Checks: What to Screen Before the Prompt Reaches the Model
One rule makes input screening much easier to reason about: run the check before the text is stored, logged, cached or sent to a third-party model. Once a raw prompt sits in a log store or a vendor trace, you cannot undelete it.
Harmful and abusive user messages
These are the categories worth checking on the way in, and most products treat them differently from one another:
- Toxicity — general abusive or degrading language. Often a policy judgement rather than an automatic block.
- Profanity — crude language. Some products allow it, some do not; decide once and encode it.
- Hate — attacks on people based on protected characteristics. A hard block on most surfaces.
- Harassment — targeted abuse aimed at a person, including other users. Block or refuse.
- Self-harm — expressions of intent or method. Handle with care: a supportive response and a route to human help usually beats a bare refusal.
- Adult content — sexual material. Block on most consumer surfaces; scope it deliberately if your product is adult.
- Violence — threats and graphic description. Context decides whether it is a refusal or a review.
- Drugs and weapons — requests for instructions, sourcing or use. Treat as a regulated-goods policy question.
- Minor safety — any sexualization or targeting of minors. A hard stop with no product-level exceptions.
- PII and spam — covered below.
A product-specific policy on top of these is normal. A medical assistant, a teen social app and an internal developer tool will set different actions for the same category, and that is the point.
PII in user input
Personal data in a prompt is a privacy problem even when the model never repeats it. Users paste what they should not: support tickets with card numbers, medical details, home addresses, whole emails transcribed into chat. The model may handle the request perfectly, but that text has now passed through your application logs, your tracing tool, your evaluation set and your model provider's request history.
Decide deliberately between three responses:
- Block and ask for re-entry, which is safest and most disruptive.
- Redact the flagged span and continue, which keeps the product usable.
- Allow but warn, which is reasonable only for low-risk personal data in a product people understand.
Screening user text for PII before you store it is the cheapest place in the whole system to catch the problem.
Spam and repeated abuse
Spam is not harmful content and should not get the same treatment. It is volume: repeated marketing, link drops, prompt-length flooding, copy-pasted payloads. A policy refusal is the wrong response, because the user is not being offensive, they are being noisy. The right responses are throttling, dropping, requiring a challenge, or limiting the conversation.
Rate limiting is a separate system control and should be enforced independently of any content check. What the text layer adds is the ability to notice that one account keeps sending the same flagged pattern, so aggregate decisions per user and per session rather than per message.
Output Checks: What to Screen Before the Reply Reaches the User
Harmful generations
Benign input does not guarantee benign output. Creative-writing prompts, roleplay, retrieved documents and tool outputs can all push a model into toxic, hateful, harassing, adult, violent or drug-related text. A model can also echo abuse back at a user who was provoking it.
Screen the final text, not the prompt. That includes text the model quotes from a retrieved document, which is a common way for content that never appeared in the user's message to reach the screen.
Leaked or hallucinated PII
Model output can contain personal data in two ways: copied from somewhere in the context (the prompt, the system message, retrieved documents, earlier turns) or invented outright. A hallucinated email address or phone number is still a problem — it can belong to a real person, and users may act on it.
An output-side PII check catches both cases with the same signal, which is why it belongs in the checklist even if you already screen input. Checking LLM output before users see it covers this direction in more depth.
Minor safety in model replies
Two output risks deserve extra attention. The first is any sexual or exploitative content involving minors, which should be blocked unconditionally. The second is self-harm content generated in response to a user in distress — a chatbot that improvises advice in that situation can do real harm, so route those replies to a reviewed, pre-approved response path.
Streamed responses and per-category handling
If you stream tokens, assemble and check on the server before release. Scanning only after the full reply has been displayed means retracting text the user already read, which is poor experience and, for harmful content, too late. Buffer by sentence or short chunk and release only what has passed.
Once a category fires, pick an action rather than applying one global block:
- Block with a clear refusal for hate, harassment, adult content and minor safety.
- Redact the offending span for PII.
- Regenerate once with a corrective instruction for toxic or violent drift.
- Escalate to a human for self-harm and ambiguous threats.
Decide What Happens When Text Is Flagged
Boolean flags mean explicit policy
Many moderation tools return only true/false flags per category rather than a score. That pushes the policy into your codebase, where it belongs. There is nothing to tune, no threshold to argue about, and no drift when a vendor changes a model behind the API.
The cost is that someone has to write the decision matrix. Keep it in one file, so policy changes are reviewable:
// Application policy, not a vendor call.
const POLICY = {
self_harm: { action: "escalate", reply: "..." },
minor: { action: "block", reply: "..." },
hate: { action: "block", reply: "..." },
harassment: { action: "block", reply: "..." },
adult: { action: "block", reply: "..." },
violence: { action: "review" },
drugs: { action: "review" },
weapons: { action: "review" },
pii: { action: "redact" },
spam: { action: "throttle" },
toxic: { action: "rephrase" },
profanity: { action: "allow" }
};
// Highest-precedence action wins when several categories fire.
const PRECEDENCE = ["escalate", "block", "throttle", "redact", "review", "rephrase", "allow"];
function decide(categories) {
const hits = Object.entries(categories).filter(([, on]) => on).map(([name]) => name);
if (hits.length === 0) return { action: "allow" };
hits.sort((a, b) => PRECEDENCE.indexOf(POLICY[a].action) - PRECEDENCE.indexOf(POLICY[b].action));
return { action: POLICY[hits[0]].action, categories: hits };
}Whatever the tool returns, the user experience matters. A clear refusal with a next step beats a silent failure, a hung spinner or a generic error. For rephrase actions, tell the user what to change.
Human review for edge cases
Text checks will produce ambiguous cases: threats that might be quoted fiction, self-harm mentions that might be academic, harassment reports between two users. Plan for them before launch.
- Keep a review queue with a target for how quickly it is read.
- Record every decision, including "allowed", so policy stays consistent as the team grows.
- Feed decisions back into the policy file rather than into ad-hoc overrides.
- Store flagged snippets in a restricted store with short retention — reviewers need context, and that store is now your most sensitive log.
Logging and Privacy for Chatbot Text
Store less than you think you need
Conversation logs are excellent for debugging and dangerous for privacy. Decide retention and access control before launch, not after the first incident.
What you usually need is metadata, not prose:
- Timestamp, request identifier, model and prompt version.
- The category flags that fired and the action taken.
- A hashed or internal user identifier rather than an email address.
- A short, redacted excerpt when a human needs to review.
Set a retention period per data class and delete on schedule. Restrict access to the raw-text store to the people who genuinely need it.
Redact before storage
Redact PII before text reaches a log store, an analytics pipeline or a tracing tool. The same screening user text for PII step you use in the request path can run on the way to the log.
Where the text goes also matters. A model running on your own infrastructure keeps prompts and replies inside your network, which simplifies the data-processing story considerably.
Privacy law cuts across all of this. Most regimes ask for a lawful basis, data minimization, a retention limit and a way to answer user rights requests. Read the official text of whichever laws apply to you, or get legal advice — the engineering decisions above are how you meet those duties in practice.
Choosing and Deploying a Moderation Layer
If you use a third-party checker, choose on criteria that match your threat model: category coverage, whether you get booleans or scores, latency, deployment options, data handling, language coverage and integration effort. How to choose a content moderation tool lays these out vendor-neutrally, and each vendor's own documentation is the only reliable source for its current capabilities.
Run a model on your own servers when the text cannot leave your network: regulated data, strict data residency, air-gapped environments, or a volume where a hosted call per message dominates your latency budget. The trade-off is that you operate it — hardware, upgrades and monitoring become your problem. On-premises vs. cloud content moderation walks through that decision.
Putting It Together: A Text-Layer Checklist
Input
- Screen user text before it is stored, logged or sent to a third-party model.
- Check harmful-content categories that fit your product, plus PII and spam.
- Decide whether PII is blocked, redacted or allowed with a warning.
- Treat spam as a throttling problem, not a refusal problem.
Output
- Screen assembled model text, including quoted and retrieved content.
- Check output for PII that was copied from context and PII that was invented.
- Gate streamed responses behind the check rather than retracting afterwards.
Action
- Write one policy file mapping each category to block, redact, regenerate, escalate or allow.
- Define precedence when several categories fire at once.
- Give users a clear refusal and a next step.
Logging and review
- Log flags, actions and identifiers instead of raw prompts.
- Set retention and access control before launch.
- Run a review queue for ambiguous cases and record every decision.
System controls that sit outside this list
- Authentication, authorization and rate limiting.
- Prompt-injection and jailbreak defenses, handled separately from content flags.
Questions Developers Ask
Do content checks replace prompt-injection defenses?
No. They are different controls. A clean message can still be an injection attempt, and an injection attempt can still be polite text.
Should I check input, output, or both?
Both. Input checks protect your prompt, your logs and your model provider. Output checks protect the person reading the reply, which is the failure users actually notice.
What do I do when a tool returns only true/false flags?
Write the policy yourself: one mapping from category to action, one precedence order, and a review path for ambiguous cases. That is more work up front and less work later than tuning thresholds.
How do I handle a chatbot that must answer in real time?
Check on the server in short buffered chunks before release. If the latency budget is tight, block the highest-risk categories on input so most bad replies are never generated.
Is redaction enough for personal data?
Redaction removes the visible data but not the risk that it was already logged upstream. Redact early — ideally before storage and before any third-party call.
How CautionLabs Fits the Checklist
CautionLabs returns true/false flags across twelve categories — toxic, profanity, hate, harassment, self_harm, adult, violence, drugs, weapons, pii, spam and minor — plus an overall flagged boolean. Responses contain no scores, probabilities or confidence values, and there are no thresholds to tune, so the policy file above is the whole decision layer. That is the point of explicit flags: the judgement about what to do stays with your team.
There are two ways to run it. The hosted API takes a POST /moderation request at https://api.cautionlabs.com with a JSON body containing the text to check. The on-premises model exposes POST /moderate on your own network. A request covers up to 3,000 characters, and longer texts are checked in 3,000-character pieces, one request each — plan that into your buffering logic for long prompts or transcripts.
import requests
response = requests.post(
"https://api.cautionlabs.com/moderation",
headers={
"Authorization": "Bearer YOUR_CLOUD_API_KEY",
"Content-Type": "application/json",
},
json={"text": user_message},
timeout=10,
)
result = response.json()
if result["flagged"]:
fired = [name for name, on in result["categories"].items() if on]
print("flagged categories:", fired)The response carries a categories object with one boolean per category and the overall flagged value, which is true when any category is flagged:
{
"categories": {
"toxic": false,
"profanity": false,
"hate": false,
"harassment": false,
"self_harm": false,
"adult": false,
"violence": false,
"drugs": false,
"weapons": false,
"pii": true,
"spam": false,
"minor": false
},
"flagged": true
}For deployments where chatbot text cannot leave your network, the on-premises container makes no outbound requests and has no telemetry. Note that a private on-premises key does not work with the cloud API, so keep the two integrations separate. If you want a step-by-step build, the content moderation API Python tutorial walks through wiring this into a request path.
Ready to see it on your own text? Try the playground with a real chatbot message, or read the API reference to see the twelve boolean flags and the overall flagged value.