Best Practices for Building LLM Apps

Chapter 3 · Practice 4 of 5

Keep secrets and other users' data out of prompts

From Prompt injection and the OWASP LLM Top 10

Why it matters

Assume the system prompt and everything in the context window can be extracted. OWASP renamed this risk Hidden Context Exposure in 2026.

These do not belong in a prompt:

  • API keys
  • internal URLs
  • other customers' records
  • business rules you would not publish

Instead:

  • Pass credentials to tools on the server side.
  • Load only the current user's data into context.
  • Keep sensitive decisions in code.