Misuse, privacy and moderation
People will try to make your system do things it should not, and it will handle their data. Plan for both before launch.
Words on this page (7)
- training
- : Adjusting a model's parameters on data so its predictions improve.
- prompt
- : The input text you give a model, including instructions, examples and data.
- least privilege
- : Giving a person or program only the access it needs for the job and nothing more.
- prompt injection
- : Untrusted text that contains instructions the model follows, such as a web page telling it to leak data.
- logarithm
- : The power you raise a base to in order to get a number. log base 2 of 8 is 3 because 2 to the power 3 is 8.
- sampling
- : Picking the next token at random according to the model's probabilities.
- system prompt
- : Standing instructions placed at the start of every call that set the model's role and rules.
Privacy and security
Do not send data to a provider you have not vetted. Know its retention and terms. Classify your data (public, internal, confidential, regulated) and set rules for which classes may reach which models. Redact personal data from and logs. Pass an end-user identifier with each request, where the provider supports it, so abuse can be traced to one account instead of your whole product. Limit what the system can reach: applies to models as much as to people.
Misuse and content
Run a moderation check on inputs and outputs for the harmful categories that matter to your product. Many providers offer a free endpoint, and you can add your own classifier. Red-team the system: have people and scripts try to break the rules, including , and add every success to your regression test set. Give users a way to report problems, and read the reports.
A worked example: a launch checklist
For a public chat feature: a moderation call on every user message and every reply. An end-user id on every request. A daily spend cap and a rate limit per user, so an attacker cannot run up your bill. Logs with names and emails redacted, kept for 30 days. Fifty red-team prompts in the test set, rerun on every release. A visible "report this answer" button wired to a queue someone reads.
Why limits come in layers
Invented numbers: a script sends 10 requests a second, and each request costs one cent. That is 10 cents a second, $360 an hour, $8,640 a day.
A per-user limit of 20 requests an hour caps one account at 20 cents an hour. But an attacker with 50 accounts can still spend $10 an hour. So also add a daily spend cap, for example $100, which bounds the worst case. Each layer covers a hole in the others.
What goes wrong: redaction misses
Redaction replaces personal details with placeholders before text leaves your system. "Write to dana@example.com" becomes "Write to [EMAIL_1]". Your code keeps the mapping and restores it in the reply.
Pattern-based redaction handles emails and phone numbers well. Names are harder. Symptom: personal data shows up in your logs. To confirm, sample 100 lines and count the leaks. Invented result: 3 of 100. Fix the patterns, repeat, and keep .
What goes wrong: blocking too much
A moderation filter tuned to be strict also blocks a nurse asking about drug doses, or a novelist writing a crime scene. Symptom: complaints from legitimate users. Confirm by reading a sample of blocked messages. If many are harmless, loosen the setting for that category or add a human review path.
Common mistake
Relying on the alone to stop misuse. A prompt can be overridden. Rules that matter belong in code, permissions and monitoring.
A company adds a free chat helper to its site. Within a day, someone writes a script that sends thousands of requests through it to get free model access, and the bill spikes. A per-user rate limit and a spend cap, which take an hour to add, would have turned a scary morning into a minor alert.
Check yourself
Why send an end-user identifier with each request to the provider?
Not quite. If abuse comes from one user, the provider and you can act on that account without blocking everyone.
A red-team prompt gets past your safeguards. What should you do with it?
Not quite. Adding each success to the test set makes sure the same attack cannot quietly return.
Where should the rules that must never break live?
Not quite. A prompt can be overridden. Enforced rules in code and permissions cannot be talked around.
You got 0 of 3 right.
Go deeper
- Article
OWASP · A checklist of the most common application risks.
- DocsModeration guideDocs
OpenAI · A free endpoint for flagging harmful content.
- Repo
NVIDIA · Programmable rules for what an LLM app may say and do.
Spotted a mistake or something unclear? Report it on GitHub.