openai / openai/codex-security

Working-tree diff findings can show source excerpts from HEAD instead of scanned changes

Open
#514 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
10.8k
Forks
801
Avg merge
1d 8h
Merged PRs (30d)
257

Description

Summary

Finding details for a working-tree diff scan can display a source excerpt from the committed HEAD blob rather than from the uncommitted content that was actually scanned.

Root cause

workbench_scan_start.scan_target_identity() stores target_revision = diff_target["headRevision"] and leaves target_snapshot_digest = None for diff scans. A working-tree diff stores its mutable-content identity separately in diff_content_digest.

workbench_source_excerpt.scanned_source_text() currently treats a None snapshot digest as eligible for Git-object lookup and executes the equivalent of:

git cat-file blob <target_revision>:<path>

For diff_target_kind = "working_tree", <target_revision> is the repository HEAD. If the finding is in an uncommitted modification, that blob is the pre-change file and can therefore disagree with the source that produced the finding.

Committed commit and range diff targets do not have this ambiguity because their head revision is the reviewed immutable source.

Impact

The sourceExcerpt attached to a saved finding can present incorrect evidence for working-tree diff scans. This is especially confusing when the affected lines were added or materially changed in the working tree.

Expected behavior

Do not synthesize an excerpt from HEAD for a working-tree diff. Until the helper can authenticate and read the exact working-tree snapshot identified by diff_content_digest, it should fail closed and omit the excerpt.

Migrated/unknown diff target kinds should fail closed for the same reason, while committed commit and range diff targets can continue reading the stored head revision.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at workbench_scan_start.scan_target_identity() and workbench_source_excerpt.scanned_source_text(), then trace the existing diff-target identity handling. Done means working_tree and migrated or unknown targets omit excerpts, while commit and range targets still read the stored head revision; verify these cases with focused tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, typescript
Domain
cli, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.