By NHI Mgmt Group Editorial TeamBased on HiddenLayer: “Inside the Prompt: How LLMs Learn Roles, Follow Instructions, and Get Exploited” (May 26, 2026)

TL;DR: Modern LLMs learn role separation, instruction hierarchy, and prompt templating through control tokens and system prompts, but those same mechanisms can be abused through control token injection, fake context resets, and XML prompt spoofing, according to HiddenLayer. The security boundary is probabilistic, not absolute, so AI teams need layered runtime controls around the model, not prompt engineering alone.


At a glance

What this is: This is HiddenLayer's analysis of how LLM role tokens, instruction hierarchy, and prompt templates shape agentic AI behaviour, and how attackers can abuse those same mechanisms through prompt injection and spoofing.

Why it matters: It matters because teams securing agentic AI cannot rely on prompts as hard controls; IAM, PAM, and runtime governance need to account for untrusted context and tool-connected model behaviour.


Context

LLM role control is the set of tokens, templates, and instruction hierarchies that teach a model which instructions matter most. In agentic AI systems, that mechanism becomes part of the identity and authorisation problem because the model is deciding which context to trust before it touches tools or downstream systems.

HiddenLayer's analysis shows why prompt injection is not just a content issue. Once a model can be steered through control tokens, fake resets, or XML spoofing, the boundary between user input and privileged instruction becomes blurry enough to undermine governance assumptions in AI workflows.

The practical issue is not whether an LLM can be made helpful. It is whether the surrounding AI control plane can keep untrusted text from changing what the model is allowed to do, especially when tools, APIs, and enterprise data sources are in scope.


Key questions

Q: How should security teams reduce prompt injection risk in AI agents?

A: Security teams should reduce prompt injection risk by constraining what enters the context window, limiting tool permissions, and separating untrusted retrieval content from privileged instructions. The practical goal is not perfect detection. It is to ensure that a successful injection cannot trigger wide data access, uncontrolled writes, or irreversible actions through a delegated identity.

Q: Why do system prompts not provide a hard security boundary?

A: System prompts shape model behaviour, but they are still interpreted by the model rather than enforced as an external access control. Attackers can exploit that by mimicking privileged structure, so the boundary remains probabilistic unless runtime controls and monitoring sit outside the model.

Q: What are the signs that an LLM may be vulnerable to instruction spoofing?

A: Warning signs include the model treating user content as if it were developer guidance, unexpected role changes, fake context resets, or tool calls that do not match the approved workflow. Those symptoms suggest the model is over-trusting structure inside the prompt.

Q: Should agentic AI tool access be controlled differently from chat-only use?

A: Yes. Once the model can call tools or touch enterprise systems, prompt manipulation becomes an operational security problem rather than a text-quality problem. Tool access should be gated by external policy, least privilege, and logging, because a compromised prompt can otherwise become a compromised action.


Technical breakdown

How role tokens teach an LLM who is speaking

Modern instruction-tuned LLMs use control tokens and role tags such as system, user, and assistant to separate context into meaningful lanes. Tokenisers preserve those markers so the model can learn that some text carries higher priority than other text, and fine-tuning reinforces that hierarchy across many examples. This is not a hard security boundary. It is a learned pattern that usually works because the model has seen enough structured conversations to generalise the intended ordering.

Practical implication: Treat role separation as a behaviour-shaping layer, not an enforcement layer, when deciding where to place trust in an AI workflow.

Why prompt injection can override intended instruction hierarchy

Prompt injection works when attacker-controlled text is made to look more authoritative than it should, such as by imitating system-style tokens, spoofing XML structure, or faking a context boundary. In effect, the model is nudged into reclassifying user content as privileged instruction. That matters most in retrieval-augmented generation and tool-using agents, where documents, emails, web pages, and repository files can carry malicious instruction content alongside legitimate data.

Practical implication: Assume any external content entering context may carry instructions, and inspect untrusted sources before they reach the model.

Why the attack surface expands once the model can use tools

A standalone chat model is a content manipulation problem, but an agent connected to tools becomes an operational security problem. If the model is tricked into elevating the priority of injected text, it may change how it calls tools, what data it reveals, or which downstream actions it takes. That turns prompt spoofing into a control-plane issue because the model's interpretation of authority directly affects execution in connected systems.

Practical implication: Add runtime policy checks around tool use so a manipulated prompt cannot directly translate into privileged actions.


Threat narrative

Attacker objective: The attacker wants to override the model's intended instruction hierarchy so it performs actions or disclosures that the developer did not authorise.

  1. Entry occurs when attacker-controlled text reaches the model through prompts, retrieved documents, emails, web pages, or repository content.
  2. Escalation happens when spoofed tokens, fake resets, or templated instructions convince the model that the injected text has higher authority than it should.
  3. Impact follows when the model changes tool use, exposes sensitive content, or alters downstream behaviour in connected enterprise systems.

Read and download The State of NHI & AI Agent Breach Report 2026, covering 200+ breaches impacting Non-Human Identities including AI Agents.


NHI Mgmt Group analysis

Prompt injection turns instruction hierarchy into a governance problem, not just a model behaviour problem. The article shows that role tokens and system prompts can teach an LLM to prefer one instruction over another, but they do not create an absolute boundary. That means AI programmes should stop treating prompt structure as a control substitute and start treating it as one input to a broader governance design.

Role control is useful because it creates a privilege model, but it remains a probabilistic privilege model. HiddenLayer's analysis is important because the same structures that improve model behaviour can be impersonated by attacker-controlled text. The practitioner implication is that trust must move out of the prompt and into runtime policy, inspection, and boundary enforcement.

Context is now an identity surface for agentic AI. When documents, emails, or repository files can carry instructions into the model's active context, the question is no longer only what the user asked. It is also what the model was allowed to trust, and that makes context ingestion part of AI access governance.

XML-style templating and control tokens create a named risk we can call instruction hierarchy spoofing. The model is trained to respect structure, so an attacker who can mimic that structure can distort privilege perception without breaking the application outright. Security teams should recognise this as an authority-confusion problem at the interaction layer, not merely a prompt hygiene issue.

Agentic AI security now sits at the boundary between IAM, PAM, and model governance. The moment the model can influence tool use or downstream systems, instruction integrity becomes part of authorisation design. That is where conventional access control assumptions begin to erode, because the decision-maker is no longer fully human-paced or fully deterministic.

From our research library:

What this signals

Instruction hierarchy spoofing: the real risk is not that the model misunderstands language, but that untrusted language can alter which instruction the model treats as authoritative. That pushes AI security toward runtime enforcement, because prompt engineering alone cannot guarantee that user, document, and developer intent stay separated.

This is the same governance mistake that appears in other identity domains: assuming structure equals control. In agentic AI, once a model can ingest external content and act on tools, the security question becomes whether access is decided at prompt time or enforced at execution time.

67% of organisations still rely heavily on static credentials despite the risks they pose to agentic AI deployments, according to the 2026 Infrastructure Identity Survey. That figure matters here because model access, tool access, and context trust are becoming one governance problem.


For practitioners

  • Treat all context inputs as untrusted Classify prompts, retrieved documents, emails, web content, and repository files as potentially instruction-bearing before they reach the model.
  • Separate instruction channels from data channels Keep system prompts, developer instructions, and user or document content clearly isolated so untrusted text cannot masquerade as privileged control.
  • Add runtime policy checks around tool calls Gate high-risk actions with external policy enforcement so a manipulated model response cannot directly trigger sensitive tool use or data access.
  • Monitor model interactions continuously Inspect prompts, outputs, and agent activity for signs of spoofed structure, context resets, or suspicious instruction escalation across sessions.

Key takeaways

  • Prompt structure helps LLMs behave predictably, but it does not create an absolute security boundary around agentic AI.
  • Control token injection, fake resets, and XML spoofing show that context itself can become a privilege-escalation path.
  • Security teams need runtime policy, monitoring, and external enforcement around tool use because prompt engineering alone cannot hold the boundary.

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 addresses the attack and risk surface, while NIST AI RMF and NIST CSF 2.0 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
OWASP Agentic AI Top 10ASI06 — Memory & Context PoisoningThe article centres on attacker-controlled context changing model behaviour.
ASI03 — Identity & Privilege AbuseThe article shows injected text impersonating higher privilege instructions.
Recommendation — Harden context ingestion paths to reduce ASI06 exposure from poisoned prompts and retrieved content. Separate instruction authority from user content so ASI03-style privilege abuse cannot steer tool use.
NIST AI RMFMANAGE — AI Risk Management and GovernanceThe article argues for governance and runtime controls around model behaviour.
Recommendation — Apply MANAGE practices to govern AI context, tool access, and escalation paths.
NIST CSF 2.0PR.AA-05 — Access Permissions, Entitlements and AuthorizationsTool-connected agents need enforced authorisation beyond prompt structure.
DE.CM-01 — Networks and Network Services MonitoredThe article emphasises continuous monitoring of prompts, outputs, and agent activity.
Recommendation — Use PR.AA-05 to align model-triggered actions with explicit entitlement boundaries. Extend monitoring to prompts, outputs, and tool calls so suspicious AI behaviour is visible.

Key terms

  • Instruction Hierarchy: Instruction hierarchy is the order of authority a model applies when interpreting context, system prompts, role messages, and user input. When attackers can influence that hierarchy through templates or wrappers, they can steer behaviour without needing to change the model itself.
  • Control Tokens: Control tokens are special markers used to separate roles, sequence boundaries, or formatting instructions in LLM context. They help the model parse conversation structure, but they also become security-sensitive when attackers can imitate, spoof, or reuse them to shift perceived authority.
  • Prompt Injection (Agentic): An attack where malicious instructions are embedded in content that an AI agent reads, causing the agent to execute unintended actions using its own legitimate credentials. A primary vector for agent goal hijacking and identity abuse.
  • Context Window: The context window is the text a model receives at one time, including prompts, retrieved documents, and conversation history. Security teams care about it because it becomes the practical boundary between trusted instructions and untrusted content, especially when the application assembles that text automatically.

Deepen your knowledge

NHI governance, agentic AI identity, and machine identity security are core topics in our NHI Foundation Level course, the industry's only accredited NHI security programme. If you are responsible for identity security strategy or NHI governance in your organisation, it is worth exploring.
NHIMG Editorial Note
Published by the NHIMG editorial team on July 5, 2026.
Updated on October 11, 2026.
NHI Mgmt Group, the independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org