Security Objective
Data marking changes how untrusted external content is represented in a model's context so that its source and role are easier for the model to recognize. System components add boundaries, labels, continuous marks, transformations or separate message channels to content that came from documents, web pages, email, retrieval or tools.
The objective is to reduce the chance that instruction-like text inside that content is treated as an instruction. It is a mitigation for indirect prompt injection, applied before or during context assembly, and it works only through the model's interpretation.
Threat Model
An attacker controls some content that a system later places into model context: a shared document, a web page, an email body, an indexed record or a tool response. The attacker cannot change the system prompt or the application code, but can write text that looks like instructions. The risk is that the model follows that text because, once concatenated, it looks like any other part of the prompt.
Marking assumes the attacker may know that marking exists and may try to imitate or disrupt it. It does not address a malicious user typing into their own session, which is direct prompt injection and needs other controls.
Ownership Boundaries
| Control | Question it answers | Relation to marking |
|---|---|---|
| Spotlighting / data marking | How is untrusted content represented so its role is salient to the model | Owns the marking and transformation of model-visible representations |
| Data provenance | Where did this content come from and how was it derived | Supplies the authoritative metadata that decides what gets marked |
| Input / content inspection | Does this content raise risk signals | May inform marking policy; a clean result never skips required marking |
| Prompt injection detection | Do content, behavior and actions together indicate an attack | Separate runtime detection; marking detects nothing |
| Information flow control | May data with these attributes reach this sink | Deterministic and independent; marked content cannot lower its own label |
| Agent authorization | May this fully resolved action execute | Deterministic and independent; marked content cannot authorize itself |
| Output validation | Is this output well-formed and within the structural and format constraints of its sink | Separate sink-side structural and format control |
Data provenance decides what content is and where it came from. Input / content inspection produces probabilistic signals about it. Marking only changes how it is presented to the model.
Marking Is Not Trust
A trusted component applied the marking. The marked content is still variable, untrusted content.
A delimiter, label, special marker or encoding is a signal to the model, not an enforcement point.
Marking may make the model less likely to follow embedded instructions. It does not make that impossible.
Marking provides no noninterference property and no deterministic separation between data and instructions inside the model.
Trust Model
The marking component and its output are separate objects. The component runs under system control; the representation it produces carries attacker-influenced text and stays variable.
The model and planner run as system processes, but what they produce is a variable proposal. Authorization and information flow control decide whether it has any effect, independently of how the input was marked.
Why Concatenated Text Blurs Source Roles
A language model receives one sequence of tokens. When system instructions, a user request and a retrieved document are joined into that sequence without clear separation, nothing inherent in the text tells the model which part carries authority. Instruction-like text inside the document can then compete with the real instructions. Marking aims to restore some of that lost role information in a form the model can use.
Provenance Signal Versus Provenance Truth
A mark is a signal about provenance, not the provenance itself. The system must decide what to mark from authoritative metadata recorded outside the payload, never from labels or claims inside the content. A document that declares itself trusted is still external content and is marked as such.
Marking Points
- 01Ingestion
Record role metadata when content enters a store; apply marks later.
- 02Retrieval
Mark selected chunks or search results before they join the context.
- 03Context assembly
Place external content in its own marked region or channel.
- 04Tool results
Mark tool and connector responses before the model reads them.
- 05Agent handoffs
Keep or reapply marks when content passes between agents.
Marking at context assembly sees the final representation and is usually the most reliable point. Marks stored at ingestion can be lost or altered by later transformations.
Marking Strategies
Approaches fall into a few conceptual categories. They can be combined, and none is a security boundary on its own. This page describes categories only and does not publish specific strings, token formats or encoded samples.
| Category | Idea | Main trade-off |
|---|---|---|
| Channel and role separation | Put external content in a distinct message role or field | Depends on model and API support for roles |
| Delimiting | Surround external content with boundary markers | Boundary can be imitated or lost |
| Datamarking | Interleave a mark throughout external content | Changes text; can affect task quality |
| Encoding / transformation | Represent external content in a different form | Token cost, model compatibility, utility |
| Structured envelopes | Wrap content in fields with metadata outside the payload | Metadata must stay outside attacker-editable text |
Delimiting
Delimiting places boundary markers around external content and tells the model, in system-level instructions, that text between them is data. It is simple and cheap. Its weakness is that it signals only at the edges: if a boundary can be predicted, reproduced inside the content or lost during truncation, the signal weakens. Boundaries chosen by the system per request are harder to imitate than fixed ones.
Datamarking
Datamarking spreads a mark throughout external content rather than only at its edges, giving the model a continuous signal about which text is data. Because the signal persists across the whole span, it can survive partial truncation better than edge boundaries. The cost is that the text the model sees differs from the original, which can affect tasks that depend on exact wording.
Encoding and Transformation
Encoding represents external content in a different form, so it is visibly separated from natural-language instructions. The model must still be able to read the transformed form, which depends on model capability. Encoding usually increases token count, can push long content past input limits, and can reduce quality on tasks that need close reading. It changes representation, not meaning.
Structured Envelopes, Message Roles and Field Boundaries
Where an API supports distinct message roles or structured inputs, external content can be passed in a channel that is separate from system and user instructions. Structured envelopes can carry role and source metadata in fields that the content cannot edit. The metadata comes from provenance; the payload inside the envelope remains untrusted however it is wrapped.
Content Types
| Source | What gets marked | Note |
|---|---|---|
| Web pages | Extracted page text | Extraction may add or drop hidden content |
| Bodies, quoted threads, attachments | Forwarded text can mix several authors | |
| Documents | Parsed text and metadata fields | Mark the representation the model sees |
| RAG | Retrieved chunks | Each chunk needs its own mark |
| Tool output | Free-text fields in responses | Schema-valid fields can still carry language |
| Multimodal | OCR, captions, transcripts | Only derived text can be marked |
See website, email, document, RAG, tool output and multimodal prompt injection for the entry paths.
Model-Visible Representation and Transformation Lineage
What matters is the representation that actually reaches the model. Record which marking method and version produced it, and keep a link to the unmarked source. Without that lineage an investigator cannot tell whether a mark was applied, lost or altered before the model saw the content.
Interaction with Input / Content Inspection
Inspection and marking are independent. A policy may choose stronger marking for content with risk signals, but a clean inspection result is never a reason to skip marking that policy requires, because not detected does not mean safe. Inspection should analyze the same representation the model will see, which may be the marked one.
Interaction with Data Provenance
Marking consumes provenance and never establishes it. The decision to mark content as external comes from authoritative metadata about its entry path and source. Marking itself should be recorded as a transformation in the lineage so derived artifacts can be traced back.
Marking Policy
A policy outside the model decides which content is marked, with which method, at which point. Typical inputs are entry path, source type, workflow risk tier and model capability. External content in workflows with tools or side effects is the usual default for marking. The policy should be versioned so results can be tied to the rules in force.
Marker Integrity
Marks lose value if content can imitate them, if they collide with legitimate text, or if content can cause them to be removed. Conceptually: markers should be chosen by the system, not predictable from outside, applied after any content-controlled processing, and verified in the final representation. This page intentionally does not describe how markers can be bypassed.
Preservation Through Transformations
- 01Summarization
A summary of marked content is new text and may carry no mark.
- 02Truncation and chunking
Edge boundaries can be cut off.
- 03Translation
Marks may be dropped or translated as content.
- 04OCR and extraction
Marks must be applied to derived text, not to the image.
- 05Agent handoffs
Receiving agents may re-wrap content without the original mark.
Derived content that re-enters context should be marked again based on the provenance of its inputs, not on whether the derived text still looks marked.
Trade-Offs
Marking can reduce utility on tasks that need exact text, increases tokens and latency for some methods, depends on the model's ability to interpret the chosen representation, and can confuse users if the model mentions the marking. Measure these costs for your models and tasks rather than assuming them.
Limitations and Failure Modes
- 01Model ignores the signal
The model follows embedded text despite correct marking.
- 02Mark lost
A transformation removed or broke the mark before the model saw it.
- 03Mark forged
Content imitated a marker or role label.
- 04Wrong source marked
Marking relied on content claims instead of provenance.
- 05Model mismatch
A new model interprets the representation differently.
Worked Scenario
Synthetic example. A support assistant summarizes a ticket and can draft and send replies. Retrieval adds a customer-provided document whose text contains synthetic instruction-like content asking to forward internal notes externally. No payload text is shown here.
| Gate | Observation | Outcome |
|---|---|---|
| Provenance | Document recorded as customer-supplied, external | Determines that marking applies |
| Marking policy | External content in a send-capable workflow | Document marked and placed in a separate context region |
| Model | May or may not be influenced by the embedded text | Variable proposal |
| Authorization / IFC | Internal notes cannot flow to an external recipient without the user's action | Deny regardless of marking outcome |
In a controlled test, the same synthetic case runs with and without marking on the same model and task, and the rate of influenced proposals is recorded for each. Both numbers are reported, together with benign task quality.
What the Scenario Proves and Does Not Prove
It shows where marking sits, how its effect can be measured against a matched control, and that the harmful effect is prevented by authorization and flow control. It does not show that marking prevents influence in general, that results carry over to other models or content, or that marked content became trustworthy.
Telemetry and Evidence
Record per request
- Content items marked, with provenance reference
- Marking method, version and policy version
- Link from marked representation to unmarked source
- Verification that marks were present in the final context
- Items that could not be marked and why
- Correlation ID linking context, proposal and enforcement decision
Incident Response
When marking fails or is bypassed
- Preserve the raw and the marked representations together with the transformation version
- Identify where marks or role separation were lost, altered or forged in the chain
- Trace affected requests and derived artifacts through provenance
- Contain the faulty transformation path, for example by routing affected content to a restricted workflow
- Check whether downstream authorization and flow control held
- After remediation, regression-test the same transformation chain with synthetic cases
Controlled Testing
Use synthetic markers in bounded, labelled test sets. Compare matched marked and unmarked runs on the same model, task and content. Test every transformation path where marks can be lost. Re-run tests when models, marking methods or context assembly change. Do not maintain a reusable attack payload library.
Metrics
Each measure keeps its own denominator. There is no composite score. Marking detects nothing, so no detection metric is attributed to it.
| Measure | Numerator | Denominator |
|---|---|---|
| Marking coverage rate | External items marked as policy requires | External items requiring marking |
| Model-visible marking preservation rate | Marked items whose marks are intact in the final context | Marked items |
| Boundary / role preservation rate | Items keeping role separation across a transformation | Items passing through that transformation |
| Influence rate, marked | Marked test cases producing an influenced proposal | Marked test cases run |
| Influence rate, matched unmarked control | Unmarked test cases producing an influenced proposal | Matched unmarked test cases run |
| Downstream unauthorized action rate (full stack) | Test cases with a disallowed effect | Test cases executed end to end |
| Marking failure / unknown representation rate | Items entering context with failed or unknown marking | Items requiring marking |
| Transformation integrity rate | Marked outputs matching the expected transformation | Marked outputs checked |
| Token and latency overhead | Distribution of added tokens and time | Marked requests |
| Benign task utility | Benign tasks completed acceptably | Benign tasks attempted |
Common Mistakes
- 01Marking as permission
Treating marked content as safe or letting it lower a label.
- 02Content-chosen markers
Letting content claims decide how it is marked.
- 03Skipping on clean scan
Omitting required marking because inspection raised no signal.
- 04Unverified marks
Assuming marks survived later transformations.
- 05Single layer
Relying on marking without authorization and flow control.
Standards, Research and Vendor Context
Sources referenced
- OWASP
- LLM01:2026 Prompt Injection
- Microsoft Research
- Defending Against Indirect Prompt Injection Attacks With Spotlighting (research)
- Microsoft
- Defend against indirect prompt injection attacks (vendor guidance), How Microsoft defends against indirect prompt injection attacks (vendor blog), Prompt Shields in Microsoft Foundry: Spotlighting (preview) (product documentation)
On source use: OWASP LLM01:2026 is the current classification for prompt injection. Microsoft Research introduced spotlighting as a family of prompt engineering techniques that use transformations of input to give a continuous signal of its provenance, and reported it as an effective defense with limited impact on task quality in its evaluated GPT-family setups; those findings are specific to the configurations tested. Microsoft Learn's guidance on indirect prompt injection is vendor guidance that lists spotlighting, using data marking and metaprompting, as one layer in a defense-in-depth strategy. Microsoft's security response blog describes delimiting, datamarking and encoding modes at a conceptual level. Microsoft Foundry documents a product feature named Spotlighting (preview) that transforms document content for document-attack protection, with documented token cost, API scope and default-off behavior; that is one product's current behavior, not a description of the general technique.
Frequently Asked Questions
Does marking make external content trusted?
No. A system component applied the mark, but the content stays untrusted and variable.
Is a delimiter a security boundary?
No. It is a signal to the model. Enforcement belongs to authorization and flow control.
Will a marked prompt stop injection?
It may reduce influence. It cannot guarantee the model ignores embedded instructions.
Who decides what gets marked?
A policy based on authoritative provenance, never on labels inside the content.
Can content fake its own marker?
It may try. Markers should be chosen and verified by the system, and marking should never be treated as authorization.
Should marking be skipped if inspection finds nothing?
No. A clean inspection result does not mean safe, so required marking still applies.
Is every structured prompt Spotlighting?
No. Spotlighting is Microsoft Research's name for a specific family of techniques within the broader idea of role marking.
Does Foundry's Spotlighting preview describe the technique in general?
No. It documents one product's current preview behavior and limits.
Do marks survive summarization?
Often not. Re-mark derived content based on the provenance of its inputs.
How should effectiveness be measured?
Against a matched unmarked control on the same model and task, reporting both rates and benign utility separately.
References
- OWASP GenAI LLM Top 10 2026 (LLM01:2026 Prompt Injection)OWASP GenAI Security Project · GuidanceReviewed 2026-09-25
- Defending Against Indirect Prompt Injection Attacks With SpotlightingMicrosoft Research · Research publication · 2024Reviewed 2026-09-25
- Defending Against Indirect Prompt Injection Attacks With Spotlighting (arXiv:2403.14720)arXiv · Research paper · 2024-03Reviewed 2026-09-25
- Defend against indirect prompt injection attacksMicrosoft Learn · GuidanceReviewed 2026-09-25
- How Microsoft defends against indirect prompt injection attacksMicrosoft Security Response Center · Guidance · 2025-07Reviewed 2026-09-25
- Prompt Shields in Microsoft FoundryMicrosoft Learn · Technical documentationReviewed 2026-09-25