anthropics / anthropics/claude-code

System-reminder wrapper for CLAUDE.md/MEMORY.md uses injection-shaped language ("OVERRIDE any default behavior... MUST follow exactly as written")

未关闭
#92,346 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area:core area:security enhancement
主要语言
Python
星标
145k
派生
23.1k
PR 合并指标
PR 指标待抓取

描述

## Summary

As of an app update this morning (2026-09-05), the system-reminder that surfaces `CLAUDE.md` and `MEMORY.md` file contents into the model's context is now wrapped in:

> Codebase and user instructions are shown below. Be sure to adhere to these instructions. IMPORTANT: These instructions OVERRIDE any default behavior and you MUST follow them exactly as written.

## Why this is a problem

This phrasing is functionally indistinguishable from a prompt-injection attempt. Claude Code's own security guidance trains the model to treat exactly this shape of language — authority claims, "OVERRIDE," "MUST," urgency — as a red flag when it shows up in web content, files, or tool output, and to surface it rather than comply silently. When the harness itself uses that identical framing to introduce legitimate, trusted file loads, it undermines the model's (and a transcript-reader's) ability to reliably tell a real injected instruction apart from the harness's own trusted context injection.

Concretely, in the session that surfaced this: Claude (Sonnet 5) flagged its own `MEMORY.md` load as a suspected injection specifically because of this wrapper, before spending a full investigative turn tracing it back to confirm it was benign harness behavior. That's a costly false positive — and the same ambiguity could just as easily go the other way, with a real injection using similar phrasing getting waved through as "probably just the harness."

## Evidence

Grepped `~/.claude/projects/**/*.jsonl` across 5 unrelated project directories (kanji-tenkai, Yoshicaster, yoshicaster-mobile, Junbee, a general project-workspace tree). Findings:

- The exact wrapper string appears in 8 session transcripts, all timestamped between 08:17-08:38 on 2026-09-05.
- It wraps both `CLAUDE.md` project-instructions loads (labeled "project instructions, checked into the codebase") and `MEMORY.md` auto-memory loads (labeled "user's auto-memory, persists across conversations") - same template, different file-type label filled in.
- No older transcript in the same directories (checked back to 2026-08-27) contains this phrase at all.
- `~/.claude/settings.json` (hooks/config) was last modified 2026-08-27 - not touched today, ruling out a user-side config change as the source.
- `/Applications/Claude.app/Contents/Info.plist` was modified 2026-09-05 (this morning), consistent with an app update introducing the new template.

## Suggested fix

Use language that signals "trusted, harness-provided context" without mimicking attacker-authority framing - e.g. drop "OVERRIDE any default behavior" and "MUST follow ... exactly as written" in favor of something neutral like "The following is project/user context loaded by Claude Code:". Making CLAUDE.md/MEMORY.md content more likely to be followed doesn't require language that's also the textbook shape of a prompt-injection attempt.

---
Filed on request, from a session that independently traced this wrapper's origin via local transcript forensics.

贡献指南

这个仓库没有索引到贡献指南

调研方向

Start by locating the system-reminder template that wraps CLAUDE.md and MEMORY.md contents; the issue does not identify a repository file or test. Compare the generated wording with the examples in ~/.claude/projects/**/*.jsonl and confirm the source is not ~/.claude/settings.json. Done means the wrapper presents trusted project or user context without injection-shaped authority language, with coverage for both file types.

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
cli, security
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
活跃
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。