Best practiceModels and infrastructure
Keep secrets out of reach of models and agents
OWASP ASI03OWASP LLM02
Agents read .env files, shell history and cloud credential files as happily as source code, and models echo what they read. Nx s1ngularity turned local AI CLIs into secret hunters; LangChain's serialization bug pulled API keys straight from environment variables.
What to do
- Inject secrets at the point of use (a broker, a sidecar, workload identity) instead of environment variables and files the agent can read.
- Block agent access to ~/.ssh, ~/.aws, ~/.config/gcloud, keychains and .env by default; log any attempt.
- Redact secrets from prompts, tool results and transcripts, and scan model output for tokens before it is shown or stored.
- Rotate anything an agent could have read after any suspected hijack, in the order: cloud keys, source control, package registries, then everything else.