Repository navigation
CM-78366: Scan images attached to Claude Code, Codex and Cursor prompts for secrets - #592
Merged
Merged
Conversation
This was referenced Nov 17, 2026
Ilanlido
previously approved these changes
Nov 17, 2026
Ilanlido
reviewed
Nov 17, 2026
Claude Code saves each image attached to a prompt (pasted, dragged in, or attached in VS Code or the desktop app) as <number>.<ext> in the session's images folder of its temp directory before the prompt hook runs. The hook now sends the images the prompt's [Image #N] chips name and those saved since the session's previous prompt, plus @path mentions, with the prompt text in one scan. The @path mention parser moves from the Copilot integration to prompt_images so both integrations share it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hasattr(os, 'getuid') can be true where calling it fails (a faked os module on Windows), so decide by the platform instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
… through A Codex chip doesn't say whether its image was pasted, dragged in or picked from the @ popup, and a dragged or picked image leaves no paste. Its chip took the newest unsent paste of the last hour instead: one a blocked prompt or another session had left, which could block a prompt for an image it never had. A prompt now takes only pastes made since the session's last prompt that went through. Codex writes a prompt into the transcript as a user message only once its hook lets it through; a blocked prompt leaves only turn bookkeeping, so a blocked prompt sent again still finds its paste. Before any prompt goes through, the window reaches back ten minutes from the session's start, which Codex writes when the first prompt is submitted. The one-hour cap stays. Checked against a live Codex 0.169.0 session: a drag after a prompt that went through, and one after another session's paste, now take nothing, while pastes, resends after a block and a new session's first paste are found as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The transcript grows with every turn, images included, and the prompt hook read all of it on every prompt to find the last prompt that went through, which is usually near the end. It now reads from the end with the reverse line reader the Claude Code integration already had (moved to a shared helper) and stops there. Read backwards, a user message is a prompt once a turn's start shows up before it, and the session's context once the session's start does. A session where no prompt has gone through yet is still read back to its start, which is short. A message with no readable time no longer hides behind a time of 0: any readable time counts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Altruistus
force-pushed
the
CM-78366-block-secrets-in-images-claude-code
branch
from
November 18, 2026 08:34
977bae6 to
8b1bfc4
Compare
omer-roth
requested changes
Nov 18, 2026
…window Review follow-ups, with no change in behavior: - VS Code and Cursor share one per-platform user data directory helper and one read-only SQLite query helper (ides/_vscode_utils.py), so the rule never to lock the app's database lives in one place. - The [Image #N] placeholder parsing used by Claude Code and Codex moves to prompt_images.image_chips, returning the numbers as written so Codex still counts #1 and #1 as two. - Claude Code and Copilot collect through prompt_images.collect_since_prompt_mark, which keeps the order of reading the mark, selecting the images and moving the mark. - Codex's paste window is two named steps: the last prompt that went through, then the session's start as the fallback. - The Claude Code docstring says why chips are followed even though the time window finds re-saved images: they are the prompt's own reference to its files, so a named image is found even if it wasn't saved again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
omer-roth
approved these changes
Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
A secret in a screenshot attached to a Claude Code, Codex or Cursor prompt goes to the model unscanned, because each prompt hook only scans the prompt's text. Each hook now finds the images attached to the prompt and scans them with the text in one scan, the same way the GitHub Copilot hook already does. Start with
ides/claude_code.py,ides/codex.pyandides/cursor.py; the shared helpers are inscan/prompt_images.py.Why
The Secret in prompt guardrail should block or report a secret whether it is typed or shown in an attached image. None of the three agents puts the images in the hook payload, so each hook finds them where its agent keeps them when the hook runs. The server decides whether to read images, so the client always sends them.
Reviewer notes
Each agent was checked live with a probe hook that blocked every prompt, so nothing reached a model unless the probe let it through.
<$CLAUDE_CODE_TMPDIR or /tmp>/claude-<uid>/<project>/<session_id>/images/<N>.<ext>.[Image #N]chips name. It also takes the files saved since the session's previous prompt (the Copilot hook's prompt marks; a first prompt looks back 600 s), which covers VS Code and the desktop app, whose prompts have no chips.@pathmentions are added on top.claude*folder of the temp directory is read; this is unverified.[Image #N]chip, even for an image-only prompt, but names no file. The terminal UI saves a clipboard paste ascodex-clipboard-<random>.pngin the temp directory.@-popup pick and--imageleave no paste. Each still gets a chip, so it can take a paste that a blocked prompt or another session made since the last prompt that went through. The VS Code extension sends images as data URLs. On WSL, a paste is saved as Windows'tmp*.png.requestIdis the hook'sgeneration_id, incursorDiskKVof the globalstate.vscdb, opened read-only. It listscontext.selectedImages[].path.@-mentioned file is a link that the agent may read later, not an attachment, so it isn't collected here. Images the agent reads are a separate change to the file-read check, which reads them as text today.cursor-agentand remote windows are untested.@pathmention parsing moves unchanged from the Copilot integration toprompt_images.py.Tests:
pytest tests1554 passed, 1 skipped. Each agent has its own cases: Claude Code's chips and windows, Codex's paste window against realistic transcripts, and Cursor's record in a real SQLite file.ruff checkandruff format --checkare clean.Jira
CM-78366 (Claude Code), CM-78367 (Codex), CM-78368 (Cursor)
🤖 Generated with Claude Code