arXiv:2610.38521cs.SEOct 2026

Manuscript Offprint

arXiv:2610.38521

Security Impact of Coding Agent's Memory Files

Thiago Santos de Moura, Selma Güler, Yannic Noller

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Thiago Santos de Moura

Ruhr-Universität Bochum

Bochum, Germany

thiago.santosdemoura@acm.org

Selma Güler

Ruhr-Universität Bochum

Bochum, Germany

selma.gueler@edu.ruhr-uni-bochum.de

Yannic Noller

Ruhr-Universität Bochum

Bochum, Germany

yannic.noller@acm.org

Abstract—Coding agents automatically load project memory files such as CLAUDE.md at the start of every session and treat them as trusted project guidance. Anyone who can change such a file, for example through a pull request, can therefore steer the agent without ever touching the developer's prompt. We study memory files as an attack surface for insecure code generation and ask (1) whether a malicious memory file makes agents produce code that passes its tests but is vulnerable, and (2) whether agents disclose to the developer that the file shaped their code. For each of 12 CWE classes, we crafted two malicious memory files, a qualified variant that presents removing defensive checks as engineering best practice and a forceful variant that demands it. We ran Claude Code (Sonnet 5.5) and OpenCode (Qwen 3.8 27B, DeepSeek V4.1 Flash) on 36 SecRepoBench tasks with and without these files. The malicious files changed the rate of secure completions by -8 to +6 percentage points, with no consistent pattern across agents or variants. Agents differ sharply in what they tell the developer about the file. Claude Code names it in about two thirds of its final messages, whereas OpenCode mentions it almost exclusively in its reasoning trace, not in the final message the developer reads. Flagging the file as an attack does not reliably protect the code, as such agents still generated vulnerable code. We outline the larger studies needed to quantify this risk across agents and to design defenses.

Index Terms—coding agents, project memory files, indirect prompt injection, secure code generation, empirical study

I. INTRODUCTION

Coding agents read a repository, edit files, and run tests [1], and developers steer them with instruction files in the repository, such as CLAUDE.md for Claude Code and AGENTS.md for other agents [2]. We call these files project memory files. The agent loads the file into its context at the start of every session as instructions for the project [3]. An attacker who can modify the file reaches the model without being part of the developer's request. This is an indirect prompt injection [4]. Prior work shows that poisoned development resources make agents run attacker commands [5] and that poisoned context or memory raises the rate of vulnerable code [6], [7]. Yet, to our knowledge, no earlier work plants a project memory file and evaluates the code of a repository agent with functional and security tests. The effect on the code matters for two reasons. First, assistants already generate vulnerable code even without an attacker [8]. Agents are mostly evaluated by whether the tests of a task pass [9], although a patch that passes all tests can still be vulnerable [10]. A memory file that suggests removing defensive checks as an engineering convention, without directly asking for a vulnerability, could therefore yield code that works and is vulnerable. Second, a reviewer of such a patch often relies on the agent's explanation of why the code was written that way, but model explanations are not reliable evidence of what drives the model [11], [12].

In this paper, we study project memory files as an attack surface for vulnerable code generation. For each of 12 considered weakness classes, we write a project memory file that presents the removal of defensive checks as ordinary C and C++ engineering guidance, in a qualified (i.e., recommending) and in a forceful (i.e., insisting) version. Three agent configurations complete SecRepoBench tasks [13] with and without the file, and dynamic tests check each completion for security and functionality. We ask two research questions:

RQ 1_{1} How do malicious project memory files change the security and the functionality of generated code? We compare the completions with and without the memory file on the same tasks, across different coding agents.

RQ 2_{2} Do the reasoning and the final message of an agent reveal that a malicious project memory file impacted the generated code? We scan the final message and the reasoning of each session for mentions of the file and compare them with the measured outcomes.

References (19)