Learn

System Prompts

What a system prompt is, what it can reasonably do, why it is neither a secret nor a security boundary, how to compose dynamic prompts safely, and which controls belong outside the model.

By Norbert HofmannPublished: 2026-09-26Last reviewed: 2026-09-26Level: FundamentalsAudience: Security Engineers, Developers, AI Engineers, General Technical Readers
Area
Learn - application architecture
Core idea
A system prompt steers behavior; it does not enforce security
Confidentiality
Treat as potentially exposable; never store secrets in it
Terminology
Product term; semantics are provider-specific
Examples
Synthetic, with neutral placeholders
Table of contents

What is a system prompt?

A system prompt is the application-authored instruction text that a product places into model context to frame a task: what the assistant is for, how it should respond, which constraints it should follow and how it should treat other content. It is usually written by the developer or deployer and is not shown to the end user.

This article builds on Instructions and Instruction Hierarchies, which explains how models resolve competing instructions. Here the focus is narrower and practical: how system prompts are built and operated, what they are good for, and where their responsibility ends.

The term is provider- and product-specific

"System prompt" is a practical product term, not one universally standardized technical primitive. Different APIs expose different roles or channels, such as system, developer or instruction fields, and assign them different precedence and capabilities. Some products also add their own provider-level instructions that the application never sees.

For example, the dated OpenAI Model Spec describes a provider-specific chain of command with levels of authority. That is one provider's documented design for its own models and surfaces, not a cross-provider rule. There is no universal "system over developer over user over tool" ordering; follow the documentation for the exact model and API in use and retest when either changes.

Where it sits in model context

At inference time the system prompt is one part of the assembled context, alongside user messages, retrieved documents, tool results, memory and schemas. As described in Trust Boundaries and Model Context, everything in that context is model-visible and can influence the output.

A privileged role or position makes it more likely that the model follows the text. It does not change what the text is: data that the model interprets. Role markers, delimiters and labels are part of the input the model reads, not a separately enforced layer.

What system prompts are good for

Legitimate uses of a system prompt
UseExample of intentNature
Task framingSummarize support tickets for internal staffBehavioral guidance
Output style and formatAnswer in short bullet points; return the agreed JSON shapeBehavioral guidance, checked by output validation
Policy guidanceDo not give legal advice; refer billing questions to the billing teamBehavioral guidance, backed by application policy where it matters
Handling of other contentTreat attached documents as material to analyze, not as instructionsRobustness aid, not a trust boundary
Tool usage guidancePrefer read-only lookups; explain before proposing a changeImproves proposals; authorization still decides

These uses are valuable. A clear system prompt improves quality, consistency and robustness. The limits start when a system prompt is expected to guarantee a security property.

What they cannot enforce

The position or role of a system prompt does not by itself:

  • authenticate any content or identify who wrote a message;
  • grant application permissions, including privileges the caller or agent does not already hold;
  • create confidentiality for its own text or for data in context;
  • guarantee that the model complies in every case;
  • make model output trusted, correct or safe to execute.

The model's response remains variable data: a proposal. A system prompt therefore cannot be the only control preventing data exfiltration, cross-tenant access or dangerous tool use. Direct and indirect prompt injection both describe content competing with these instructions; sometimes it succeeds.

Hidden is not secret

A system prompt is usually not displayed, but it is fully visible to the model and can be disclosed, paraphrased or inferred through its output. The NIST glossary names the attempt to divulge a system prompt or other hidden context "prompt extraction". OWASP's 2026 guidance on hidden context exposure advises designing under the assumption that hidden context is discoverable, and Microsoft's security planning guidance recommends not storing credentials or connection strings in the system prompt.

Practical consequence: never place API keys, passwords, tokens, internal hostnames that act as secrets, or security-only data in a system prompt. Write it so that disclosure would be unwelcome at most, not harmful. The attack view is covered in System Prompt Extraction.

Prompt confidentiality vs prompt integrity

Two distinct concerns
ConcernQuestionMain safeguards
ConfidentialityCan the prompt text be seen by someone it was not meant for?Keep secrets out; assume discoverability; limit impact of disclosure
IntegrityCan someone change or add to the instructions the application actually sends?Access control on templates, review, versioning, safe composition of dynamic fields

They fail independently. A fully disclosed prompt can still be intact, and a prompt that has never leaked can still have been altered through an unreviewed template change or an untrusted value spliced into it. Both deserve attention; neither replaces controls outside the model.

Dynamic and templated system prompts

Many applications assemble the system prompt at run time: a fixed template plus variable values such as user locale, product tier, feature flags, tenant name or document metadata. Generated prompts are still application data and configuration, and should be handled like it.

Composition practices

  • Keep fixed, developer-controlled instruction templates separate from variable values.
  • Record the source and provenance of every dynamic field.
  • Do not concatenate third-party or user content into privileged instruction text.
  • Use structured fields or separate channels where the API supports them, and remember that the model still interprets that boundary.
  • Version prompt templates and record which version produced each run.
  • Retest behavior after prompt, model or provider changes.

Never splice untrusted content into authority-bearing instructions

If an untrusted value is inserted into the instruction text itself, anyone who controls that value writes part of the most authoritative-looking section of the context. Keep such values as clearly labeled data, pass them in the channel intended for content, or map them to a fixed set of allowed values before use.

Delimiters, XML-style tags, labels and Spotlighting / Data Marking can make the difference between instruction and data clearer to the model and improve robustness. They are not hard trust boundaries: the model may still follow instruction-like text inside marked data. Data Provenance keeps track of where each value came from, so application logic can decide how it may be used.

System prompts in tool calling and agents

In agents, system prompts often describe the available tools and a usage policy. This helps the model propose sensible actions. The proposed call is still model output: runtime authorization checks the exact action, resource and parameters against the caller's actual permissions, and least privilege limits what any credential can reach in the first place.

A system prompt cannot widen those permissions. If the prompt says an agent may perform an action that the underlying identity is not allowed to perform, the action must fail at execution time. See AI Agent Prompt Injection for how influence turns into actions.

Controls that belong outside the prompt

Responsibilities outside the model
ResponsibilityWhere it is enforced
Identity and authenticationApplication and identity provider
Authorization and tenant isolationData layer and policy engine, per request
Tool and action authorizationRuntime check of exact action, resource and parameters
Information flow and destinationsFlow and egress policy, see Information Flow Control
Output validationValidate structure and format for the destination
Sink handlingApply required sink-specific encoding or escaping separately from validation
SecretsSecret store and server-side credentials, never model context

See Information Flow Control and Output Validation for the detailed treatment.

Synthetic examples

01Example 1: summarize only

The system prompt says the assistant only summarizes tickets. The application grants the session read-only access; no write tool exists.

02Result

Even if [content attempting to trigger an update] made the model propose a change, there is no write path to execute. The instruction shapes behavior; the permission model prevents writes.

01Example 2: fictional secret

A draft system prompt contains [FICTIONAL-API-KEY] so the model can call a service.

02Correction

The key moves to a server-side secret store; the tool call is made by application code with its own credential. The prompt only names the tool. Disclosure of the prompt now reveals nothing sensitive.

01Example 3: dynamic metadata

A template combines fixed policy text with a document title taken from an uploaded file: [third-party title text].

02Safe composition

The title is passed as labeled document data with its provenance, not inserted into the policy sentences. The template version is logged with the run.

01Example 4: agent tool policy

The agent prompt says: only look up orders for the current customer. The model proposes a lookup for a different customer ID.

02Result

Runtime authorization compares the ID with the session's customer and rejects the call. The rejection is logged; no data is returned.

Operational checklist

Running system prompts as configuration

  • Store prompt templates in version control with review for changes.
  • Restrict who can modify templates and dynamic field sources.
  • Record template version, model and provider version for each run.
  • Keep secrets and security-only data out of all prompt text.
  • Test behavior with representative and adversarial synthetic cases after every change.
  • Log policy denials and unusual tool proposals as telemetry, without treating logs as enforcement.
  • Review whether any security property currently depends only on prompt wording.

Common misconceptions

Statements that do not hold

  • The system prompt is secret because users cannot see it.
  • A strongly worded system prompt prevents prompt injection.
  • The system role authenticates or authorizes anything.
  • Delimiters or tags create a hard boundary between instructions and data.
  • If the prompt forbids an action, the application does not need to check it.
  • A generated system prompt is safe because the application produced it.

For the terminology around attempts to override these instructions, see Prompt Injection vs Jailbreaking.

Practice

The Trust Boundaries and Model Context lab separates what is model-visible from what is authoritative. The Direct Prompt Injection Basics lab shows why the authorization decision stays with the application when content competes with application instructions.

Standards and sources

How this article uses sources

OWASP
LLM08:2026 Hidden Context Exposure - assume hidden context is discoverable; no credentials; not a security boundary, GenAI LLM Top 10 2026 - prompt injection as a named risk
NIST
AI 100-2e2025 and glossary - prompt extraction and prompt-injection terminology
Microsoft
Security planning for LLM applications - system prompt leakage as a threat; keep credentials out, Indirect prompt-injection guidance - layered mitigations
OpenAI
Model Spec 2026-08-18 - provider-specific example of instruction authority only

Composition, versioning and operational practices in this article are architecture guidance, not requirements quoted from a standard.

Frequently asked questions

Is a system prompt a security boundary?
No. It steers model behavior. Security properties are enforced by application controls outside the model.
Can I keep my system prompt confidential?
You can avoid displaying it, but you should assume it can be disclosed or inferred and write it so that disclosure causes no direct security harm.
Where should API keys go?
In a server-side secret store used by application code, never in model context.
Does the system role always win over user messages?
Precedence is provider-specific and behavioral. It often helps, but it is not guaranteed in every case.
Are delimiters enough to separate untrusted data?
They help the model and improve robustness, but they are interpreted by the model and are not a hard trust boundary.
Can a system prompt give an agent extra permissions?
No. Permissions come from the identity and policy used at execution time. Text cannot mint missing authority.
What should be logged?
The template version, model and provider version, and policy decisions such as denied tool calls.

References

  1. LLM08:2026 Hidden Context Exposure (OWASP Top 10 for LLM Applications 2026)OWASP GenAI Security Project · Guidance · 2026-08Reviewed 2026-09-26
  2. prompt extractionNIST Glossary · Technical documentationReviewed 2026-09-26
  3. Security planning for LLM-based applications (threat: leakage of system prompt / metaprompt)Microsoft Learn · GuidanceReviewed 2026-09-26
  4. OpenAI Model Spec - Instructions and levels of authorityOpenAI · Technical documentationLatest revision 2026-08-18Reviewed 2026-09-26
  5. OWASP GenAI LLM Top 10 2026OWASP GenAI Security Project · GuidanceReviewed 2026-09-26
  6. Adversarial Machine Learning: A Taxonomy and Terminology of Attacks and Mitigations, NIST AI 100-2e2025NIST · Standard · 2025-03Reviewed 2026-09-26
  7. Defend against indirect prompt injection attacksMicrosoft Learn · GuidanceReviewed 2026-09-26