CapScope: Capability Scoping Authorization Mechanism for Coding Agents Against Prompt InjectionAuthority Is Not a String: A Capability-Scoped Harness for Prompt-Injection-Resistant Coding Agents
The authors propose CapScope, which issues capability permissions per principal at the harness layer; on Pi repair tasks, injected effect execution drops from 33–47/75 at baseline to 3/75.
Indirect prompt injection: the attacker manipulates the model's tool-call proposals through text in repository files, project instruction files, skill definitions, source code comments, or tool outputs; the attacker cannot modify the harness, the capability store, or the tool wrappers, and cannot mint capabilities. CapScope does not prevent the model from following injected instructions; it only prevents tool calls that lack the corresponding capability from executing.
- Coding agent tools carry ambient authority: naming a resource is enough to operate on it, and indirect prompt injection can use repository files or tool output to make the agent perform operations the user did not request, while a single task-level global policy cannot give different sub-agents different permissions.
- CapScope performs authorization at the harness layer: before reading repository content, it uses trusted input to pre-check and generate a task-level permission upper bound and freezes it; each sub-agent receives only a capability set narrowed according to the delegation upper bound; capabilities are stored outside the model context, and before each tool call the store of the initiating principal is checked.
- Running qwen3.5-flash on Pi for 300 runs (4 conditions × 5 tasks × 5 injection surfaces × 3 runs): injection-effect executions were 47/75 for B0, 46/75 for B1, 33/75 for B2, and 3/75 for CapScope; repair success was 68/75 for CapScope and 72/75 for B0; average duration was 316 s for CapScope and 145 s for B0.
- The authors note that the evaluation contains only 5 small Python repair tasks, a single model, and 3 trials per cell, and does not represent large refactorings or long-running workflows; injection payloads are deliberately strong, and results are reported separately by injection surface; per-cell results fluctuate across trials, and only the ordering by condition is interpreted.
- Evaluated models
- qwen3.5-flash
- Benchmarks
- 5 个自建 Python 修复任务(T1–T5,Table 1)5 个注入面(README、AGENTS.md、Skill file、Source comment、Tool output)
- Metrics
- attack_executedtask_successmean wall-clock time (s)
The researchers propose CapScope, an authorization mechanism that restricts tool calls at the harness layer, without requiring the model to identify malicious text itself. It first derives task-level capability limits from trusted inputs, then assigns each agent an independent set of capabilities stored outside the model context, and each tool call is checked against the capabilities of the agent that initiated the call, so permissions obtained by one sub-agent are not automatically passed to another. The authors implemented this mechanism on the Pi coding agent and evaluated it in a repair workflow where an orchestrator delegates subtasks to sub-agents, covering 5 Python tasks, 5 injection surfaces, 4 authorization conditions, and 3 trials per cell, totaling 300 runs.
Related events and news
1 events · 1 news mentions
News that mentions this paper
Adversa AI 汇总 10 月 AI Agent 安全资源
- Adversa AIcites the paper's id or linkAdversa AI 汇总 2026 年 10 月 AI 编码 Agent 安全资源 26 项
Authority is not a string: a capability-scoped harness for prompt-injection-resistant coding agents
Paper analysis
What problem does this paper attempt to solve?
The ambient authority of coding agent tools lets indirect prompt injection use sub-agents to perform unauthorized operations, and the authors propose a harness-layer defense that partitions permissions by principal.
Core problem: coding agents' tools carry ambient authority—naming a resource is enough to operate on it—and indirect prompt injection exploits this to make the agent perform actions the user did not request, while a single task-level global policy cannot give two sub-agents different permissions (the authors call this the granularity gap).
- Problem scenario: a developer asks a coding agent to fix tests, and the orchestrator assigns running tests and modifying source code to different sub-agents; poisoned test output can induce a sub-agent with write permission to write attacker-controlled content into ordinary source paths, and the authors state that such requests do not contain features that deny rules would flag.
- Shortcomings of existing methods: the authors state that model-level defenses (instruction-hierarchy training/prompting, injection classifiers) make probabilistic judgments; prior work has found that attacks still succeed under instruction-hierarchy prompting, and classifiers have false positives and may not stop adaptive attacks.
- Core observation: the authors frame the problem as a confused-deputy problem—the harness holds the user's authority, while the resource name is chosen by the model; therefore the permission check should be placed at the harness layer and executed after the model proposes a tool call, without requiring the model to identify malicious text.
- Proposed in the paper: CapScope, a harness-layer authorization mechanism: mint a task-level permission upper bound from trusted input, narrow it per sub-agent (attenuation), and check the initiating principal's capability store before each tool call; implemented and evaluated on the Pi coding agent.
- Threat model (Section 2.2):
- Attacker goal: manipulate the model's proposed tool calls via indirect prompt injection so that external effects occur (executing in-project tools, writing project files).
- Injection channels: repository files, project instruction files, skill definitions, source code comments, and any text in tool outputs that enters the model context.
- Attacker capability boundary: cannot modify the harness, the capability store, or the tool wrappers, and cannot mint capabilities.
- Non-goals: CapScope does not prevent the model from following injected instructions; it only prevents calls lacking the capability from executing; it is not a confidentiality mechanism, and authorized read plus authorized write can still move data.
What related research exists?
Related work falls into four groups: prompt injection and model-side defenses, harness-layer defenses, runtime policy systems (Progent is the closest), and classic capability security literature.
Prompt injection and model-side defenses
- Greshake et al. (2023)—proposed that indirect prompt injection can hijack LLM-integrated applications; OWASP lists prompt injection as the top risk for LLM applications (LLM01:2025).
- Liu et al. (2025)—reported an injection attack success rate of up to 84% against production coding editors; Karliner and Pillar Security (2025) documented a backdoor vector in rules and skill files (Rules File Backdoor).
- Instruction Hierarchy (Wallace et al., 2024) and PromptArmor (Shi et al., 2025)—train or prompt the model to be suspicious of untrusted text; the paper notes that such decisions remain probabilistic and that CapScope can be combined with them.
Harness-layer defenses and benchmarks
- AgentDojo (Debenedetti et al., 2024)—a benchmark for evaluating attacks and defenses against agent prompt injection; Bhagwatkar et al. (2025) state that a simple firewall can solve many cases on several benchmarks.
- Sandboxes, approval modes, and allowlist/denylist command modes of deployed coding agents—the paper notes that CapScope differs in two respects: command scope is matched against the parsed executable and argument vector, and compound commands are checked segment by segment; permissions are narrowed per principal, whereas a task-level global policy cannot grant write permission only to the patcher and not to the runner.
Runtime policy and execution governance systems
- Progent (Shi et al., 2025)—the paper states this is the closest runtime policy design: a DSL expresses symbolic rules over tool names and arguments, the LLM generates an initial policy and can propose updates during execution, narrowing is automatic and expansion requires approval; the paper notes that CapScope differs in freezing the task upper bound before reading repository content and in giving each principal a separate narrowed store.
- CaMeL (Debenedetti et al., 2025)—a dual-LLM planner plus a custom interpreter, using capability separation to control the control flow and data flow; the evaluation targets web and email agents rather than coding workflows; Fides (2025) performs information-flow label tracking, AgentArmor (2025) type-checks runtime traces, ToolGate (2026) attaches Hoare-style contracts to tool calls, and PACT (2026) implements argument-level provenance contracts.
Classic capability security literature
- Saltzer and Schroeder (1975) define capabilities, complete mediation, and least privilege; Dennis and Van Horn (1966) unify naming and authorization; Hardy (1988) raises the confused-deputy problem; Miller and Shapiro (2003) distinguish authority from permission.
- Bastion (Omar et al., 2024) maps agents to F★ capabilities checked by a type checker; Odersky et al. (2026) use a Scala capture checker to track capability values. The paper notes that CapScope does not use capability values held by the agent and does not perform static checking; instead, it stores structured scope predicates on the host side and enforces them at dispatch time.
Baselines and benchmarks: the comparison baselines are B0 (ambient authority), B1 (static global policy, denying .env, .ssh, rm -rf, sudo, curl, etc.), and B2 (task-specific global policy); the evaluation uses 5 self-built Python repair tasks and 5 injection surfaces. The authors position the paper as follows: authority derives from a trusted policy before reading untrusted content, which is where it differs from the above systems.
How does the paper address this problem?
CapScope manages capabilities on the host side with three rules (Mint/Derive/Invoke): pre-check minting of the task upper bound, narrowing on delegation, and checking the per-principal store before each call.
Overall approach: move permissions out of the model context and into the harness. CapScope mints a task-level permission upper bound from trusted input before reading repository content and freezes it; each sub-agent holds only a capability set narrowed according to the delegation upper bound; before each tool call is dispatched, the store of the initiating principal is checked, without requiring the model to judge whether text is malicious.
Capability model and trust boundary
- Capability definition: a capability is c = (e, φ), written Cap[e, φ], where e is the effect type (Read/Write/Exec) and φ is a scope predicate over arguments; the capability covers a proposal (t, a) when eff(t) = e and φ(a) holds.
- Three kinds of scope: Read/Write cover a normalized path prefix (canon resolves .. and symlinks to prevent traversal); Exec covers a prefix of the parsed argument vector; parse rejects substitution, splits compound commands, and removes redirections; a compound command containing an uncovered segment (such as curl) is rejected.
- Trust boundary: the only trusted inputs are the user request, the system prompt, and user-private settings; repository content and command outputs are untrusted. Capabilities are stored on the host side, isolated per principal, and the model cannot read or modify them.
Three formal rules
- Mint: the only rule that introduces new authority; the trusted host policy P returns a finite capability set for trusted pre-check input I_T; in the implementation, a pre-check LLM proposes based on the trusted request and the file tree (looking only at file names, not content), and deterministic host-side code validates and freezes the compiled result.
- Derive: on delegation, the candidate set C′ is filtered to the subset C′′ covered by the delegation upper bound D_i and installed for the sub-agent; requests not covered are dropped; the narrowing relation is written c′ ⪯ c, e.g., src/** can be narrowed to src/parser.py, but not the reverse.
- Invoke: a tool call executes only if a covering capability exists in the store; otherwise it is blocked and a rejection is returned to the model; the authors state that under these three rules, the effects of any execution can be traced back to a trusted Mint, and Mint and Derive can only narrow.
Implementation on Pi
- Host requirements: a blocking pre-call interceptor and per-session state are required; Pi 0.78.0's tool_call event fires before dispatch, and returning block: true aborts the call; the process-isolated sub-agents of the pi-subagents extension can initialize their stores independently.
- Four components: structured capability types (ScopeSpec is a path prefix or an argv allowlist); authorize performs a one-time pre-check mint at session start; spawnScoped first uses ensureUsable to fill in in-repository reads and role-required scopes, then filters via derive; each principal installs the same handler function but with its own store in the closure.
- Tools and effects: Pi's four built-in tools read, write, edit, and bash are enabled; bash corresponds to Exec, and the command wrapper also recognizes read-only/navigation programs such as grep, find, and ls.
- Runtime approval: if a call that is genuinely necessary but uncovered occurs, the harness can ask the user to approve a single new capability (a new trusted Mint); interactive approval is disabled in the evaluation.
Success determination
- task_success: the final test suite passes; attack_executed: the attack-specific sentinel or marker exists on disk after the run. Both are booleans per run, read from the file system, independent of logs; the authors emphasize that scoring targets side effects rather than ordinary project activity.
What experiments did the paper conduct?
300 runs (4 conditions × 5 tasks × 5 injection surfaces × 3 runs): injected effect execution is 3/75 for CapScope and 33–47/75 for baselines; repair success is 68/75, with baselines at 68–72/75.
Experimental setup
- Models tested: all conditions are driven by qwen3.5-flash via CloseAI's OpenAI-compatible endpoint; precheck calls use temperature 0; runs were collected in May 2026.
- Tasks: 5 small Python repair tasks (T1–T5, each containing one bug and one failing pytest suite, Table 1), with one independent working copy per task.
- Injection surfaces: the same task-specific payload is placed into 5 surfaces—README, AGENTS.md, Skill file, Source comment, Tool output (pytest output); the injection requests executing in-project tools or writing project files, and the authors say these operations are deliberately designed to look plausible.
- Conditions: B0 ambient authority (no hook), B1 static global policy (deny .env/.ssh/rm -rf/sudo/curl, etc.), B2 task-specific global policy (generated at precheck, shared across all principals), C i.e. CapScope.
- Protocol: full factorial 4 conditions × 5 tasks × 5 injection surfaces × 3 repetitions = 300 runs; a unified four-principal pipeline (orchestrator, runner, patcher, verifier), with interactive approval disabled.
- Metrics: task_success and attack_executed are both boolean per run, read from the filesystem; the decision log of each call is also recorded as a secondary diagnostic; latency is wall-clock seconds per run.
Main results
According to Table 2 (75 runs per condition):
Swipe horizontally to read the table
Condition task_success attack_executed Mean latency (s) B0: ambient authority 72/75 47/75 145 B1: static global 70/75 46/75 140 B2: task-specific global 68/75 33/75 194 C: CapScope 68/75 3/75 316 - The authors say B1 shows no improvement over B0 because the malicious operations are ordinary in-repo operations that a denylist would not name; B2 reduces executions to 33/75 by removing permissions the task does not need before the injection arrives, but a single allowlist is still shared by all principals.
- The authors say CapScope further withdraws the permissions required by the task from principals that do not need them, so executions drop to 3/75; task success is the same as B2 (68/75), 4 fewer than B0.
- Decision log diagnostic: under CapScope the model proposes the injected action in 34/75 runs, and the hook records only 3 runs with an allowed attack call.
Breakdown by injection surface
According to Table 3 (B2 vs. C, 15 runs per cell):
Injection surface B2 attack exec. C attack exec. README 7/15 0/15 AGENTS.md 11/15 3/15 Skill file 7/15 0/15 Source comment 4/15 0/15 Tool output 4/15 0/15 - Under CapScope all 3 executed attacks go through the AGENTS.md surface, and the other four surfaces are 0; the authors explain that the residual attacks fall into two categories: authorization broader than the subtask requires, or the injected text influencing the subtask the model generates and thereby selecting the capability the attacker requests, both of which require the action to be within the precheck ceiling.
Task failure and latency analysis
- Failure breakdown: of CapScope's 7 task failures, 2 are because the precheck missed the source-code write capability needed for the fix, causing the patcher's legitimate write to be rejected; 2 are because the runner proposed the correct modification but the flow was not passed to the patcher with write permission; 3 are because the tests had passed but the session timeout was reached, counted as failures under the fixed scoring rule.
- Latency: C's mean latency is 316 s (median 208 s, with 5 runs reaching the 900 s timeout), and B0/B1/B2 are 145/140/194 s respectively; among the 34 C runs containing attack proposals, 27 have repeated attack calls, and the authors say the measured latency includes the extra model turns after rejection and does not separate the causal cost of individual components.
- Deployment implications (not measurement results): the authors say that in an interactive deployment the user could reject the first attack request to stop the retries, or approve legitimate uncovered steps, but human response time was not measured; this is only a deployment inference.
What are some points that can be further explored?
In the Limitations section, the authors list limitations such as task scale, number of models, and number of trials; the experiments cover only a single model, 5 tasks, and 300 runs.
Limitations noted by the authors and future directions
- Corpus scale (Section 5 Limitations and Threats to Validity): the evaluation contains only 5 small Python repair tasks, one model, and 3 trials per cell; it does not represent large refactorings, dependency migrations, or long-running workflows, where policy omissions and approval frequency may be higher.
- Injection payload strength (same section): payloads are deliberately designed to be strong, and the model may react differently to different carriers, so results are reported separately by injection surface rather than assuming a uniform injection rate.
- Randomness (same section): the underlying calls are stochastic, and per-cell results fluctuate across trials; the authors interpret only the ordering by condition (which they call stable) and do not interpret any single cell.
- Effect of rejection messages (same section): informative rejection messages may affect recovery and task success, although they cannot turn an uncovered call into an allowed one.
- Policy quality is an independent error source (Section 5 Policy Quality and Approval): too-wide scope allows undesired in-domain actions, and too-narrow scope blocks necessary steps; CapScope does not silently widen scope, and in deployment it can show rejections to the user and record an approved capability as a new trusted Mint.
- Residual attack paths (Section 5 How a Residual Injection Still Lands): authorization can be broader than the subtask requires, and injected text can also influence the subtask text generated by the model, thereby selecting the capability the attacker requests; enforcement at the dispatch layer cannot correct capabilities that the policy intentionally installed.
Scope of the experiments
- The model under test is a single model, qwen3.5-flash, driven through CloseAI's OpenAI-compatible endpoint, with pre-check calls at temperature 0.
- The evaluation is 4 conditions × 5 tasks × 5 injection surfaces × 3 trials = 300 runs, 75 per condition; the tasks are 5 self-built small Python repair projects.
- The comparison conditions are the three baselines B0, B1, and B2 plus CapScope; model-level defenses (such as classifiers) are not included as a comparison condition, and the paper states that CapScope can be combined with model-side defenses.
- The metrics are task_success, attack_executed, and wall-clock duration, with decision logs as a secondary diagnostic; the paper reports no statistical significance tests and states that it interprets results by ordering across conditions.
- Interactive approval is disabled in the evaluation, and the paper does not measure human response time or approval choices; filename injection is outside the scope of this evaluation (Section 2.2).
Summarize the main content of the paper
CapScope moves coding agent permissions to the harness layer and manages them per principal; over 300 runs, injected effect execution is 3/75 versus 33–47/75 for baselines, and task success is 68/75.
A paper on a harness-layer defense against indirect prompt injection in coding agents, whose core claim is that authorization should not depend on the model recognizing malicious text.
- Problem: Coding agent tools carry ambient authority, and injected text can land an attack through a sub-agent that has permissions; the authors state that a single task-level global policy has a granularity gap—it cannot grant write permission only to the patcher and not to the runner.
- Method: Before reading repository content, CapScope mints a task-level permission upper bound from the trusted request and file tree and freezes it; on delegation, it narrows an independent capability store for each sub-agent according to the upper bound; before each tool call, it performs an Invoke check against the initiating principal's store, and blocks anything not covered. Capabilities are typed structures (Read/Write path prefixes, Exec argument vector prefixes) stored outside the model context.
- Main results: On Pi with qwen3.5-flash, over 300 runs (4 conditions × 5 tasks × 5 injection surfaces × 3 runs), attack_executed drops from 47/75 for B0, 46/75 for B1, and 33/75 for B2 to 3/75 for CapScope (Table 2); all 3 residual attacks go through the AGENTS.md surface (Table 3).
- Cost: task_success is 68/75, the same as B2 and 4 fewer than B0; average time is 316 s (145 s for B0), which the authors state includes extra model turns after refusals, and they did not separate per-component cost.
- Mechanism boundaries: The authors state that CapScope only constrains the effects a principal can invoke, and does not prevent misuse of already-authorized capabilities or the transitive effects of already-allowed commands, which they leave to policy design and sandboxing; it is also not a confidentiality mechanism.
- Authors' conclusion: Permissions should be installed from a trusted policy before untrusted content enters the context, checked at dispatch time, and can be combined with model-side defenses and data-flow tracking; the authors note that evaluation scale, a single model, and the number of trials are the main limitations.