Skip to content

scan_packages: baseline sentencepiece dup2 finding after upstream reindent - #7120

Merged
danielhanchen merged 1 commit into
mainfrom
scan-packages-baseline-sentencepiece-reindent
Jul 14, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
scan-packages-baseline-sentencepiece-reindent

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

What

Add the current-indentation variant of the sentencepiece os.dup2 finding to the scan_packages.py allowlist so the supply-chain scan stops blocking on it.

Why it was failing

pip scan-packages :: hf-stack and pip scan-packages :: studio both fail on the "Scan declared + transitive Python deps" step with a single non-baselined CRITICAL:

[1] CRITICAL  Reverse shell / bind shell pattern
    Package:  sentencepiece
    File:     sentencepiece/__init__.py
    Evidence: L772: os.dup2(self.ostream.fileno(), self.orig_stream_fileno)
            | L777: os.dup2(self.orig_stream_dup, self.orig_stream_fileno)

This is a benign false positive: sentencepiece redirects stdout/stderr file descriptors to capture its C++ logs, and the heuristic flags os.dup2 because reverse shells dup socket fds onto 0/1/2. No socket or networking is involved.

The finding is already allowlisted, but the baseline key is (package, package-relative file, check, evidence_hash), where evidence_hash is over the matched code with the L<NN>: markers stripped and the code's own indentation preserved. A newer sentencepiece release reindented this block, moving it from L1221/L1226 to L772/L777 and changing its leading indentation. That changed the hash (bba233.. to 65b5a11c..), so the existing entry no longer matched and the finding resurfaced as a blocking CRITICAL. The scan gate only trips on non-baselined CRITICAL/HIGH, which is why the MEDIUM findings are unaffected.

Fix

Add the new indentation variant to scripts/scan_packages_baseline.json. The old L1221 entry is kept so both sentencepiece versions stay covered.

Verified with the scanner's own _load_baseline / _finding_key: the L772/L777 finding key is now present in the baseline set, and the old L1221 variant is still covered.

…ndent

The supply-chain scan gates on non-baselined CRITICAL/HIGH findings. A newer
sentencepiece release reindented the stdout/stderr fd-redirect helper in
sentencepiece/__init__.py (the os.dup2 pair the heuristic flags as a
reverse/bind-shell pattern), moving it from L1221/L1226 to L772/L777 and
changing its leading indentation.

The baseline key is (package, package-relative file, check, evidence_hash),
where evidence_hash is over the matched code with the L<NN>: markers stripped
but the code's own indentation preserved. The reindent therefore changed the
hash (bba233.. -> 65b5a11c..), so the existing entry no longer suppressed the
finding and it resurfaced as a blocking CRITICAL in the hf-stack and studio
scan legs.

Add the new indentation variant to the allowlist. The calls are sentencepiece
redirecting stdout/stderr file descriptors to capture its C++ logs, not a
shell; no socket or networking is involved. The old L1221 entry is kept so
both versions stay covered.
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a baseline exception for the 'sentencepiece' package in 'scripts/scan_packages_baseline.json' to ignore a critical severity 'Reverse shell / bind shell pattern' check. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@danielhanchen
danielhanchen merged commit 744b59f into main Jul 14, 2026
14 checks passed
@danielhanchen
danielhanchen deleted the scan-packages-baseline-sentencepiece-reindent branch July 14, 2026 08:38
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