New to ShortSpan? We distil the AI-security research that matters into practitioner takeaways — edited by Ben Williams (NCC Group).Get the weekly email
// Analysis
Agents Leak Privilege via Context Assembly
Published: Wed, 02 Sep 2026 • By Lydia Stratus
Agents
New research dissects how AI agents assemble context and shows two privilege-escalation paths inside real harnesses. Attacker-controlled content can jump message roles (M-CPE) or persist across scopes (X-CPE), leading to tool abuse, denial of service and remote code execution. Analysis across 12 agents, including Claude Code and Codex, finds hundreds of viable paths.
Agent builders love to talk about prompts. The real mess sits underneath, where the harness hoovers up context from config files, tool outputs, memory stores, repos and whatever the environment hands it, then feeds that stew to a Large Language Model (LLM). This paper looks squarely at that plumbing and shows how it breaks in practice.
Two escalation paths
The authors name two families of attacks. Message-Role Context Privilege Escalation (M-CPE) is when attacker-controlled content from a low-privilege source ends up embedded in a higher-privilege message role. Cross-Scope Context Privilege Escalation (X-CPE) is when attacker content is allowed to persist beyond the scope where it was introduced, so it influences later steps or future sessions.
They analyse 12 real agent harnesses, including Claude Code and Codex, and catalogue where context comes from: system prompts and instruction files, configuration and memory, skills and plugins, tool outputs, version-control metadata and environment data. Opaque assembly logic and role mislabelling turn these inputs into attack surfaces with consequences that go well beyond prompt goofs: full agent compromise, remote code execution, denial of service and manipulated tool or skill invocations.
How they proved it
The team built an LLM-assisted analysis pipeline, ContextRiskAnalyzer (CoRA), to trace and validate context flows. CoRA statically inspects harness code to map sources, roles and scopes; instruments the agent to intercept requests to model endpoints; spins up isolated environments seeded with canaries; and then enumerates and validates escalation paths end to end.
The numbers are not hand-wavy. Across the targets, CoRA identified 463 candidate context sources and verified 282 at runtime. It enumerated 1,761 candidate CPE paths (940 M-CPE, 640 X-CPE, 181 both). Under evaluated models, many paths actually load and behave as expected: with GPT-5.4-mini, 1,284 paths loaded and 1,028 were behaviourally verified; with GPT-5.5, 1,315 loaded and 1,034 verified.
The attack catalogue hits familiar weak points. Memory and instruction files let low-privilege content ride into high-privilege slots. Skill discovery and configuration loading enable attackers to smuggle instructions or override behaviour through crafted packages or manifests. Environment-derived context and version-control metadata leak untrusted strings into trusted prompts. Markup wrapping and model-output tags let content morph roles in transit. Inline shell execution and dynamic content blocks convert those escalations into code running on the host.
None of this relies on sci-fi jailbreaks. It is what happens when harnesses conflate provenance, role and scope under delivery pressure. The interesting open question is standardisation: without a common way to tag and enforce source trust, scope and message role across agents, this class of bugs will keep showing up in different guises.
Additional analysis of the original ArXiv paper
📋Original Paper Title and Abstract
What's in Your Agent's Context? Context Privilege Escalation Attacks against AI Agent Harness
Real-world, high-profile AI agent harnesses often rely on vendor-proprietary or opaque designs for context assembly, leaving the sources and underlying logic of assembled context poorly understood and the resulting security risks largely unexplored. In this paper, we present the first systematic analysis of context assembly designs in real-world AI agent harnesses. We study and uncover how an agent harness is designed to collect and assemble context from diverse sources, and identify a set of practical attack vectors arising from these designs. Our analysis brings to light two novel categories of attacks in the context assembly of real-world harnesses: (1) MessageRole Context Privilege Escalation (M-CPE), which occurs when attacker-controlled content originating from a low-privileged context is incorporated into a higher-privileged message role. (2) Cross-Scope Context Privilege Escalation (X-CPE), which occurs when attacker-controlled content persists beyond the context in which it was introduced. We performed a systemic security analysis of the CPE attacks against 12 real-world agent harnesses, including Claude Code and Codex. The resulting consequences include full agent compromise, remote code execution, denial of service, and manipulated tool or skill invocations, etc.
🔍ShortSpan Analysis of the Paper
Problem
This paper studies how real-world AI agent harnesses assemble context for large language models and the security risks that arise when that assembly is opaque or vendor-specific. The authors show that agents collect context from heterogeneous sources such as system prompts, configuration and memory files, skills and plugins, tool outputs, version-control metadata and environment information. Because agents label those pieces with privilege roles and persist some across sessions, attacker-controlled content from low-trust sources can influence higher-privilege instructions or persist beyond its origin, creating novel privilege-escalation threats with serious consequences for agent behaviour and host security.
Approach
The authors performed a systematic analysis of 12 real-world agent harnesses, implemented proof-of-concept end-to-end attacks using state-of-the-art models, and built an LLM-assisted analysis pipeline named ContextRiskAnalyzer (CoRA). CoRA statically analyses harness source code to identify candidate context sources and their roles and scopes, instruments agent code to intercept requests to model endpoints, constructs isolated environments with canaries to validate sources, and automatically enumerates and validates context privilege-escalation (CPE) paths.
Key Findings
Two new classes of attacks: Message-Role Context Privilege Escalation (M-CPE), where attacker-controlled content from a low-privileged source is incorporated into a higher-privileged message role; and Cross-Scope Context Privilege Escalation (X-CPE), where attacker-controlled content is persisted into broader or more persistent scopes.
Taxonomy and prevalence: the authors identify a taxonomy of 16 attack vectors spanning memory and instruction files, skill discovery, configuration manipulation, environment-derived context, markup-wrapping and model-output tags, inline shell execution and dynamic content blocks. Across 12 agents CoRA identified 463 candidate context sources and verified 282 at runtime.
Exploitability and impact: CoRA enumerated 1,761 candidate CPE paths (940 M-CPE, 640 X-CPE, 181 both). Under evaluated models, many paths load and some produce the expected behaviours: under GPT-5.4-mini 1,284 paths were loaded and 1,028 behaviourally verified; under GPT-5.5 1,315 were loaded and 1,034 verified. Demonstrated consequences include full agent compromise, remote code execution, denial of service and manipulated tool or skill invocations.
Limitations
CoRA requires constructing validation environments and may fail when sources need complex runtime setup or special configuration; some identified sources were filtered due to limited payload capacity; and attack validation can be affected by the target LLM’s instruction-following or alignment, so automated validation gives a conservative lower bound. The work focuses on open harnesses and controlled proof-of-concept attacks rather than adversary access to host systems.
Implications
From an offensive security viewpoint, the findings show concrete, practical paths for attackers who can control third-party content or third-party components to escalate privileges inside an agent harness. Attackers can move low-privilege tool outputs into system-level or user-level memory, inject high-privilege skills or override configuration, and persist attacker instructions across sessions to influence future tasks or execute arbitrary commands on the host. These vectors enable supply-chain and repository-based attacks such as malicious pull requests, crafted archives, or package contents that exploit discovery and loading logic to achieve remote code execution or persistent compromises.
- It shows a vulnerability class in MCP-based agents where coordinating legitimate tasks across multiple services can create harmful, cross-domain att...
- It maps a wide range of real advisories in an AI agent framework, showing how security problems appear across layers from LLM reasoning to host exec...
- It shows a real risk: attackers can steer AI agents by embedding harmful instructions in external content, often leaving no obvious signs in the fin...
- Why it’s relevant: It exposes a new stealthy attack surface in modular AI agent ecosystems (implicit trust in third-party tools) where a backdoored ...
- Why it’s relevant: It analyzes the security risks that come with connecting LLMs to data and tools via the Model Context Protocol, showing how “cont...
- Reveals a new attack surface where web-use agents can be steered by malicious content they encounter online, exploiting gaps in LLMs’ reasoning.
- I...
- It shows that manipulating an agent’s execution context (files, memory, tools, etc.) can trigger unsafe behavior even if the task looks fine, reveal...
- It surveys security risks in autonomous LLM-powered agents, covering how bad inputs and inter-agent communications can be exploited, and it offers a...
- It assesses security for tool-augmented AI agents (not just the base models), which is crucial for real-world deployments where agents use tools and...
- It shows that even “safe” personal AI agents with high privileges can be tricked by real-world prompts, not just toy chat prompts, posing immediate ...
Get the weekly digest
The few AI-security papers that matter, with the practitioner takeaway. No spam.