APS-87Recommended
Keep secrets out of the system prompt
Write the system prompt as if it will be published. It holds no keys, passwords, internal addresses or private rules.
How to do it
Keep keys in the server code that runs the tools. Models can be talked into repeating their instructions, so a leak of the prompt must cause no harm. Put rules that matter in code, as in direct prompt injection. Keep the keys in a secrets store that only the tool code reads.
How to check
Ask the model to repeat its instructions word for word, in a few ways. Search the reply and the prompt file for keys and internal addresses. None are found.
Sources
Related rules
- APS-82 Resist direct prompt injection in Application security
- ENG-26 Keep secrets in a secrets store in Engineering
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/application-security/ai-features-and-agents/no-secrets-in-prompt">Agent Wranglers application security playbook</a>. In code you write, add a comment next to it with the same link.