Repository navigation
CM-78368: Scan images attached to Cursor prompts for secrets - #594
Merged
Altruistus merged 2 commits intoNov 17, 2026
Merged
Altruistus merged 2 commits into
Altruistus merged 2 commits into
Conversation
Cursor's beforeSubmitPrompt payload never names an image: its attachments list only rules. Cursor's own record of the prompt does. It is the conversation's bubble whose requestId is the hook's generation_id, in the cursorDiskKV table of its global state database (read-only), and context.selectedImages lists each image's file: pasted, dropped and picked images are saved in the workspace's storage when attached, @-mentioned ones stay where they are. Cursor starts saving the record just before it runs the hook, so the hook waits up to a second for it. The images are sent with the prompt text in one scan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 17, 2026
Altruistus
marked this pull request as ready for review
November 17, 2026 14:37
An @-mentioned file is not listed with the prompt's images: Cursor keeps it as a link that the agent may read later with its file tool. Comment only; the code and its line numbers are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ilanlido
approved these changes
Nov 17, 2026
Altruistus
merged commit Nov 17, 2026
c97ec9e
into
CM-78367-block-secrets-in-images-codex
10 checks passed
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 Cursor chat goes to the model unscanned, because the prompt hook only scans the prompt's text. The Cursor prompt hook now reads which images Cursor attached to the prompt and scans them with the text in one scan.
Why
The Secret in prompt guardrail should block or report a secret whether it is typed or shown in an attached image. Cursor's
beforeSubmitPromptpayload never names an image: itsattachmentslist only rules. Cursor's own record of the prompt does name them: every pasted, dropped or picked image is saved to the workspace's storage when it is attached, and the record lists it.Reviewer notes
requestIdis the hook'sgeneration_id.cursorDiskKVtable of the globalstate.vscdb.context.selectedImages[].pathlists each image's file.bubbleId:<conversation_id>:. A dry run on a real past prompt found its screenshot.@-mentioned files aren't attached to the prompt, so they aren't collected here. Cursor records them undercontext.fileSelections, and the agent opens one with its file tool only if it decides to. With file reads forbidden, the model reported that nothing was attached. With reads allowed,beforeReadFilefired for the PNG before the model read its text. Scanning images the agent reads is a separate change to the file-read check, which currently reads them as text.cursor-agentand remote (SSH or container) windows are untested; the database may not be on the machine that runs the hook.Tests:
pytest tests1548 passed, 1 skipped. New Cursor cases use a real SQLite file and cover the prompt's record, a record without images, waiting for the record, giving up, missing ids, a missing or unreadable database, malformed records, and the per-platform data folder.ruffis clean.Jira
CM-78368
🤖 Generated with Claude Code