Use AI safely
Protect data and secrets
Keep credentials and sensitive information out of prompts, generated source, logs, repositories, and browser code.
8 minute lesson
AI workflows can copy data into prompts, conversation history, tool results, logs, traces, and generated files. Review the whole path, not just the final answer.
Before sharing data, ask:
- What exact fields am I sending?
- Does this task require the real values?
- Where will input and output be stored or logged?
- Which people, services, tools, or models can access it?
- When will it be deleted?
Check the current provider and product policy. Consumer chat, API, enterprise, and local deployments may handle retention and training differently.
Minimize before you share
Use a synthetic record instead of a production record when possible. Keep only the fields needed to reproduce the problem. Replace names, emails, tokens, and identifiers consistently so relationships still make sense.
Do not paste a complete customer export to explain one failing row. Do not attach an entire .env file when one configuration name is enough.
Data categories need different treatment. A public schema may be safe to share. A customer email should be sanitized. A credential should not enter the prompt at all.
Environment variables are not automatically secret
API keys and passwords belong in protected server-side configuration or a secrets manager. But an environment variable exposed to browser code becomes public when the application builds or runs.
The browser must never receive a private model-provider key. Put the model call on a server and expose only the narrow operation the client needs.
Also keep secrets out of screenshots, command history, test fixtures, logs, error messages, and generated documentation.
If a secret leaks
Deleting the visible line is not enough. Assume a committed, logged, or shared value may have been copied.
- Stop using the credential.
- Revoke or rotate it at the provider.
- Update deployed configuration.
- Check usage and logs for abuse.
- Remove visible copies and clean history where appropriate.
- Fix the process that allowed the leak.
Rotation limits future use. Repository cleanup alone does not.
Try this
Classify these as safe to share, sanitize first, or do not share: a public database schema, an anonymized fixture, a production stack trace containing an authorization header, a customer export, and a private API key.
Lesson completed