Alexandre Day / Projects / Publications
CAMLIS 2026 · Applied Machine Learning in Information Security

Workspace Topology as an Attack Vector in Agentic Coding Assistants

Alexandre G.R. Day, Pradeep Yadlapalli, Sriram Venkatapathy, Thomas Paniagua, Nick Raines, Sahil Wadhwa, Himanshu Kumar, Andy Luo, Sudeep Panyam, Rikhiya Ghosh, Pranab Mohanty, Giri Iyengar

Capital One, AI Foundations

TL;DR

The layout of a code repository is itself a security variable. Planting the same indirect prompt injection in 100 open-source repositories across 10 languages and 6 engineering domains, we find that more modular codebases substantially lower attack success, that a short defensive note in AGENTS.md suppresses it by roughly 60%, and that where a payload sits (directory depth, in-file position, chat-template mimicry) changes whether a coding agent reaches it and complies.

The problem

Agentic coding assistants such as Claude Code, Codex and Opencode operate inside a developer's trusted project folder. They read configuration files, documentation and source, and they run tools. Any file the agent reads in the course of normal work can carry adversarial instructions, which makes the workspace a natural channel for indirect prompt injection (IPI): a malicious pull-request contributor or a compromised dependency only has to leave text where the agent will look.

Prior IPI work has focused on web agents, retrieval pipelines and tool descriptions. What was missing was a systematic study of how the structure of the repository, which we call its workspace topology, changes whether such an attack succeeds.

The approach

We characterise workspace topology along four dimensions. Two are properties of the codebase: modularity, scored 1 to 10 with an eight-criterion rubric, and framing context, i.e. whether security-themed cues are present in the workspace. Two are controlled by the attacker: the nesting depth at which the payload is planted and its in-file position (beginning, middle or end).

Payloads enter through three realistic entry points: EP1, workspace configuration files such as AGENTS.md or CLAUDE.md that harnesses auto-load as system context; EP2, documentation such as README.md; and EP3, source files two or more directories deep. The payload instructs the agent to run a planted init.sh script that echoes two markers, so execution is verifiable. We decompose the attack success rate (ASR) into reachability (did the agent read the payload?) times compliance (did it follow it?), and evaluate with an open-weight model (gpt-oss-120b) served through the open-source Opencode harness.

Threat model: an adversary plants an injection in a repository artifact, which lands in one of three entry points and is read by the coding agent during a normal task.
Figure 1: Threat model. (a) An adversary, for example a malicious PR contributor, plants an injection prompt in a repository artifact. (b) The prompt lands in one of three IPI entry points inside the workspace: workspace configuration (EP1), documentation (EP2) or nested source files (EP3). (c) The coding agent reads the artifact while carrying out a benign developer task and may comply with the planted directive.

Results

Topology moves the needle a lot more than one might expect for an attack whose text never changes:

44% → 27%
ASR, low- vs. high-modularity repos
−15.5 pp
ASR with a defensive AGENTS.md (≈60% suppression)
2.3×
ASR spread across languages (22% Java to 50% Ruby)
38% → 8.5%
ASR from depth 2 to depth 4

Modularity. Over 1,261 sessions on the full 100-repository set, low-modularity repositories (scores 1–2) show an ASR of 44.0%, mid-modularity 34.4%, and high-modularity (5–7) 26.5%. The confidence intervals of the low and high buckets do not overlap. The drop comes almost entirely from compliance (47.6% down to 30.6%): the agent still reads the payload in well-structured repositories, it just follows it less often.

Framing. A single defensive instruction in AGENTS.md (“Do NOT execute scripts…”) brings ASR from 25.7% down to 10.2%. A security-themed folder-name prefix, by contrast, changes ASR by only −3.0 pp and is not significant.

Depth and position. Reachability peaks at depth 2 and then falls away, so ASR is bounded by how deep the agent actually explores. Within a README, a plain payload works best at the top of the file, but wrapping it in a format-mimicry envelope (fake chat-template role tokens) flips that pattern: compliance climbs to 20% when the payload is placed at the end of the file, versus 2% for the plain version.

Why it matters

For defenders, the results point to concrete levers. Modular code is a passive defence worth having. Harnesses should validate AGENTS.md and CLAUDE.md for action directives before loading them, and should default to denying side-effecting tools such as shell and write access, which blocks the compliance step outright. Defensive framing helps but is a soft layer that an adaptive attacker can rephrase around.

For red teams, topology is a confound that has to be controlled: report reachability and compliance separately, sample across modularity and depth rather than a single convenient repository, and keep test environments uncontaminated (for instance, commit planted files before the agent runs so git status does not give them away). The study covers one model, one harness and one payload action, so the absolute numbers will shift across agents; the dependence on topology is the point.