Skip to content

CM-78367: Scan images attached to Codex prompts for secrets - #593

Merged
Altruistus merged 3 commits into
CM-78366-block-secrets-in-images-claude-codefrom
CM-78367-block-secrets-in-images-codex
Nov 17, 2026
Merged

Altruistus merged 3 commits into
CM-78366-block-secrets-in-images-claude-codefrom
CM-78367-block-secrets-in-images-codex

Conversation

@Altruistus

@Altruistus Altruistus commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

TL;DR

A secret in a screenshot pasted into Codex goes to the model unscanned, because the prompt hook only scans the prompt's text. The Codex prompt hook now finds the clipboard images pasted into 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. Codex's UserPromptSubmit payload has the prompt text only. It has an [Image #N] chip for each attached image, but no path. The terminal UI saves a clipboard paste as codex-clipboard-<random>.png in the temp directory and keeps the file, so those pastes can be found.

Reviewer notes

  • Grounded in the Codex 0.160.1 source (rust-v0.160.1), checked again on 0.169.0, and live terminal-UI runs on 0.169.0:
    • The hook input has no image field, and its prompt joins the text parts only (UserPromptSubmit hooks drop image attachments from the hook payload openai/codex#41128). The terminal UI keeps each image's [Image #N] placeholder in the text, so a pasted image alone arrives as [Image #1], not an empty prompt.
    • The hook runs before the turn is recorded, and a blocked turn is never recorded.
    • Accepted turns record each image as <image name=[Image #k] path="…"> in the transcript.
  • Which images belong to the prompt:
    • one clipboard paste per distinct chip: the newest pastes of the last hour that the session's transcript doesn't already record as sent;
    • plus @path mentions.
    • The transcript, not a prompt mark, decides what was already sent. A blocked prompt isn't in it, so resending it scans its paste again. A mark would have moved past the paste and let the resend through.
  • A chip doesn't say whether its image was pasted, dragged in or picked from the @ popup. In a live run a dragged or picked image got a chip but no paste, so the prompt took the newest unsent paste of the last hour in its place. Two Codex sessions pasting at the same time can also see each other's pastes. Accepted as rare: it needs an unsent paste from the last hour, and the dragged or picked image itself is a known gap.
  • Codex sends a second prompt to title a new thread, after the first prompt goes through. It has no transcript and quotes the user's prompt, chips included, so a payload without a transcript takes no paste. Otherwise it would scan the paste the user's prompt had just sent a second time.
  • Known gaps, since the hook can see none of these:
    • images dragged in, picked from the @ popup, or passed with --image/-i: the original file is attached and nothing names it;
    • the VS Code extension: pastes are inline data URLs.
  • Checked live on Codex 0.169.0's terminal UI: a paste with text and a paste alone were each collected; a blocked prompt sent again found its paste again; after a prompt went through, the transcript named its paste and the next prompt skipped it.
  • Stacked on CM-78366: Scan images attached to Claude Code, Codex and Cursor prompts for secrets #592 (CM-78366, Claude Code); review only this PR's commit. CM-78368: Scan images attached to Cursor prompts for secrets #594 (Cursor) is stacked on this one.

Tests: pytest tests 1534 passed, 1 skipped. New Codex cases cover the newest paste per chip, pastes already sent, no chip, a repeated chip, old pastes, no transcript, a transcript not written yet, and mentions. ruff is clean.

Jira

CM-78367

🤖 Generated with Claude Code

Codex's prompt hook gets the prompt text only, with an [Image #N] chip per
attached image. The terminal UI saves an image pasted from the clipboard as
codex-clipboard-<random>.png in the temp directory and keeps it. The hook now
sends the newest pastes of the last hour that no earlier prompt of the
session sent (read from its transcript), one per chip, plus @path mentions,
with the prompt text in one scan. Codex records a prompt only after its hook
lets it through, so a blocked prompt sent again is scanned again.

Images dragged in, picked from the @ popup or passed with --image, and the
VS Code extension's attachments, are not named anywhere the hook can read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Altruistus and others added 2 commits November 17, 2026 16:39
Codex sends a second prompt to title a new thread. It has no transcript
and quotes the user's prompt, chips included, so it took the paste the
user's prompt had just sent and scanned it again. Without a transcript
nothing tells a sent paste from an unsent one, so no paste is taken.

The docstring also says what a live run showed: a dragged image, or one
picked from the @ popup, gets a chip but no paste, so the prompt takes
the newest unsent paste in its place.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@Altruistus
Altruistus merged commit 23ba3f3 into CM-78366-block-secrets-in-images-claude-code Nov 17, 2026
10 checks passed
@Altruistus
Altruistus deleted the CM-78367-block-secrets-in-images-codex branch November 17, 2026 16:19
Altruistus added a commit that referenced this pull request Nov 18, 2026
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant