claude-code - 💡(How to fix) Fix [Bug] Cross-task prompt contamination: foreign task text injected into user messages

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

drop+warn any segment whose origin

Root Cause

Bug Description

Bug: Cross-task prompt contamination — foreign

task text injected into a user message

Severity: High — corrupts task intent; agent acted on instructions the user never gave.

Summary A user message scoped to Repo A (CrabCode) was delivered with a trailing block belonging to a different task targeting Repo B (acosmi) appended to it. The agent treated the injected block as a real second task and started executing it.

Observed Appended block referenced a doc docs/audit/代币计费-…-2026-05-29.md that does NOT exist anywhere in Repo A (verified across working tree, all branches, stash, worktrees, memory) and per the user belongs to Repo B. It also contained garbled mid-sentence text ("关联影响斤 西瓜深度复核审计") — a fingerprint of text concatenation/corruption, not intentional input.

Expected A user turn must contain only what the user submitted for the current session/thread. Content from another task/session/repo must never be concatenated in.

Impact Agent pursued instructions never given (audited a non-existent doc); wasted turns; risk of changes against the wrong repo; erodes message-integrity trust.

Suspected root cause (hypothesis) Cross-session injection via a shared, unscoped queue — matches known fingerprint project_cross_window_notif_injection_rootcause.md : ~/.crabcode/pending_notifications.jsonl loaded at bootstrap WITHOUT thread/session filtering. The existing P0 fix may not cover the user-prompt assembly path, or isn't in the running build.

Repro: Not deterministic; likely intermittent with multiple concurrent sessions/windows (one per repo).

Suggested fix Scope cross-turn injection by active thread/session id at prompt-assembly time (not just display). Add invariant + test: drop+warn any segment whose origin thread id ≠ active thread id before it enters a user turn.

Code Example

[]
RAW_BUFFERClick to expand / collapse

Bug Description

Bug: Cross-task prompt contamination — foreign

task text injected into a user message

Severity: High — corrupts task intent; agent acted on instructions the user never gave.

Summary A user message scoped to Repo A (CrabCode) was delivered with a trailing block belonging to a different task targeting Repo B (acosmi) appended to it. The agent treated the injected block as a real second task and started executing it.

Observed Appended block referenced a doc docs/audit/代币计费-…-2026-05-29.md that does NOT exist anywhere in Repo A (verified across working tree, all branches, stash, worktrees, memory) and per the user belongs to Repo B. It also contained garbled mid-sentence text ("关联影响斤 西瓜深度复核审计") — a fingerprint of text concatenation/corruption, not intentional input.

Expected A user turn must contain only what the user submitted for the current session/thread. Content from another task/session/repo must never be concatenated in.

Impact Agent pursued instructions never given (audited a non-existent doc); wasted turns; risk of changes against the wrong repo; erodes message-integrity trust.

Suspected root cause (hypothesis) Cross-session injection via a shared, unscoped queue — matches known fingerprint project_cross_window_notif_injection_rootcause.md : ~/.crabcode/pending_notifications.jsonl loaded at bootstrap WITHOUT thread/session filtering. The existing P0 fix may not cover the user-prompt assembly path, or isn't in the running build.

Repro: Not deterministic; likely intermittent with multiple concurrent sessions/windows (one per repo).

Suggested fix Scope cross-turn injection by active thread/session id at prompt-assembly time (not just display). Add invariant + test: drop+warn any segment whose origin thread id ≠ active thread id before it enters a user turn.

Environment Info

  • Platform: darwin
  • Terminal: Apple_Terminal
  • Version: 2.1.156
  • Feedback ID: 16678d6f-99e5-441f-a38a-d718dc5c3b77

Errors

[]

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [Bug] Cross-task prompt contamination: foreign task text injected into user messages