Subscribe to the Non-Human & AI Identity Journal

What breaks when teams treat system prompts as a secure place for secrets?

They turn a behavioural layer into a hidden repository for credentials, roles, and business logic. Once an attacker can extract the prompt, the organisation has lost both confidentiality and the control assumptions tied to that text. The right fix is to move secrets and policy enforcement into systems designed for them, not into the model context.

Why This Matters for Security Teams

System prompts are often treated like harmless configuration text, but once they contain secrets, they become a high-value target rather than a control boundary. That creates exposure across confidentiality, privilege management, auditability, and incident response. A leaked prompt can reveal tokens, service account names, escalation instructions, hidden policy, or data handling rules that were never meant to be user-visible. This is especially risky in agentic workflows, where prompt content may shape tool use and downstream actions.

Security teams often underestimate how easily prompts spread through logging, debugging, support exports, eval pipelines, and vendor telemetry. The problem is not only extraction by a malicious user; it is also accidental disclosure through internal access paths that were never designed for secret material. Current guidance suggests treating prompt text as behavior-shaping input, not as a secure repository for trust decisions. The OWASP Non-Human Identity Top 10 is a useful reference when those prompts govern machine-to-machine access, because prompt misuse can quickly turn into credential misuse. In practice, many security teams encounter prompt leakage only after an incident review, rather than through intentional secret management.

How It Works in Practice

The clean design pattern is to separate three layers: instructions, secrets, and enforcement. The prompt should describe what the system is allowed to do, but the actual credentials, policy checks, and scoped access should live in dedicated services. That means using a secrets manager, short-lived credentials, and explicit authorization checks outside the model context. NIST guidance such as NIST SP 800-53 Rev 5 Security and Privacy Controls reinforces this separation through access control, audit logging, and configuration management controls.

In practice, teams should assume prompts are inspectable. Any text placed there may be surfaced through UI overlays, traces, error messages, prompt injection, or model behavior that echoes context. A better pattern is to pass only the minimum context needed for task completion, then resolve secrets at execution time through an authenticated backend. For agentic systems, the model should request a capability, not hold the capability itself. That keeps the decision point in policy code, where the organisation can enforce scope, expiry, and revocation.

  • Store credentials in a secrets manager, not in system or developer prompts.
  • Use short-lived tokens and rotation so leaked values age out quickly.
  • Keep policy in code or a policy engine, not in hidden prompt text.
  • Log access to secrets separately from model prompts for better audit trails.
  • Review whether any prompt content would create privilege if disclosed publicly.

For non-human identities, this is especially important because prompts sometimes contain service account labels, API key references, or instructions that imply standing access. That is precisely the kind of hidden coupling the OWASP Non-Human Identity Top 10 warns against. These controls tend to break down when teams embed secrets in prompts to speed up prototyping because the same text later gets reused in production without a proper secret boundary.

Common Variations and Edge Cases

Tighter separation between prompts and secrets often increases implementation effort, requiring organisations to balance developer convenience against stronger containment and revocation. That tradeoff becomes sharper in fast-moving product teams, where prompt templates are edited frequently and access patterns change faster than security reviews can keep up.

There is no universal standard for whether every policy statement belongs outside the prompt, but current guidance suggests moving anything that would create material risk if disclosed. That includes API keys, static credentials, internal escalation logic, and exception handling that could be abused if an attacker learned it. Some teams use prompt wrappers or policy overlays to keep instructions readable while resolving sensitive values at runtime, which can work well if the boundary is enforced consistently.

Edge cases appear in low-code AI tooling, shared notebook environments, and rapid proof-of-concept deployments, where prompt text, secrets, and operational metadata are mixed together by default. In those environments, the main risk is not just disclosure but confusion about what is authoritative. If the prompt appears to define access rules, engineers may assume the model is enforcing them when the actual enforcement is missing. The safer pattern is to make secrets retrievable only by trusted services, keep prompts non-sensitive, and test for leakage the same way other secret sprawl is tested. This becomes even more critical when logs, exports, or browser-side tools can expose prompt history to users who should never see it.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Agentic AI Top 10 and OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST CSF 2.0, NIST AI RMF and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
NIST CSF 2.0 PR.AC Secret-in-prompt misuse is fundamentally an access control failure.
NIST AI RMF AI risk management covers leakage, misuse, and weak governance of model context.
OWASP Agentic AI Top 10 Agentic systems are vulnerable when prompts hold privileged instructions or secrets.
OWASP Non-Human Identity Top 10 Prompts containing service credentials create hidden non-human identity risk.
NIST SP 800-53 Rev 5 AC-6 Least privilege limits the damage if prompt text is exposed.

Design agents so prompts describe intent, while secrets and authority stay outside model context.