Repository navigation
Keep scan_packages.py from tripping Bitdefender's Python stealer signature - #12169
Conversation
…ature Bitdefender (and the engines that license it) quarantine scripts/scan_packages.py as Generic.PY.STEALER.B.EE7760D1. The detection comes from the credential and wallet names in RE_CRED_ACCESS and RE_CRYPTO_THEFT sitting next to the scanner's own download and archive code. The engine folds + and adjacent string literals, so those names are now stored as pieces joined at import by a small _joined helper. The compiled patterns are byte-for-byte the same, so detection and baseline keys do not change.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex security review |
|
Codex Review: Didn't find any major issues. 🚀 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
The tool sandbox keeps a deny list of credential paths (SSH keys, cloud credential files, shadow) in the same file as network code, which is the shape the Generic.PY.STEALER heuristic scores. Those names are now stored split into pieces and joined at import by a small _joined helper, as scripts/scan_packages.py does since #12169. The compiled pattern, the glob target tuple, the basename set and the escape-check prefixes are equal to their previous values, so what the sandbox refuses does not change. The AV008 baseline group for this file is removed; the file no longer carries any of the matched names.
…ature (unslothai#12169) Bitdefender (and the engines that license it) quarantine scripts/scan_packages.py as Generic.PY.STEALER.B.EE7760D1. The detection comes from the credential and wallet names in RE_CRED_ACCESS and RE_CRYPTO_THEFT sitting next to the scanner's own download and archive code. The engine folds + and adjacent string literals, so those names are now stored as pieces joined at import by a small _joined helper. The compiled patterns are byte-for-byte the same, so detection and baseline keys do not change.
The tool sandbox keeps a deny list of credential paths (SSH keys, cloud credential files, shadow) in the same file as network code, which is the shape the Generic.PY.STEALER heuristic scores. Those names are now stored split into pieces and joined at import by a small _joined helper, as scripts/scan_packages.py does since unslothai#12169. The compiled pattern, the glob target tuple, the basename set and the escape-check prefixes are equal to their previous values, so what the sandbox refuses does not change. The AV008 baseline group for this file is removed; the file no longer carries any of the matched names.
… again (#19245) ## Keep scan_packages.py clear of Bitdefender's Python stealer signature again `scripts/scan_packages.py` on main is flagged again on VirusTotal as `Generic.PY.STEALER.B`, the same detection #12169 fixed in September. Bitdefender, and every engine that ships its signatures, quarantines the file on a contributor's machine. ### What changed Comments only. The comment trim in #12969 shortened several comment blocks near the top of the file; that is what brought the detection back. This restores those comments (the 28 edits above the anti-analysis patterns) and keeps the rest of the trim. The parsed code is identical to main (same `ast.dump`), so behaviour does not change. One line is added above `_joined` noting that trimming the comments there re-triggered it, so the next cleanup rescans the file. ### Evidence (VirusTotal, fresh uploads, 2026-11-24) | Version of `scripts/scan_packages.py` | Detections | |---|---| | After #12169 (Sep 27) and after #12884 (Oct 6) | 0 | | After #12969 (Oct 26) | 8: ALYac, Arcabit, BitDefender, Emsisoft, GData, MicroWorld-eScan, VIPRE `Generic.PY.STEALER.B`; CTX `script.spyware.generic` | | main today (after #16112) | the same 8 | | main with the top 28 comment edits reverted | 0 | | This PR | 0 / 72 (sha256 `29cb47f1b33b57815d75a1a76476c53b068ce452068c8569d10ea2f949b968af`) | Bisecting the 110 comment edits between #12884 and main: applying only edits 55 to 110 stays clean, while several small subsets of edits 0 to 21 each bring the detection back on their own. The detection reacts to how much comment text separates the pattern tables near the top of the file, not to any single word. ### Tests - `tests/security/test_scan_packages.py`, `tests/security/test_lint_av_shapes.py`, `tests/test_scripts_write_lf.py`: 181 passed. - `scripts/lint_av_shapes.py`: 0 new errors. Pre-commit ruff clean. ### Not covered - Engines can change their signatures at any time; this is clean against today's. - Other files were not affected: the installers, setup scripts, uninstallers, `studio/install_*.py` helpers and `scan_npm_packages.py` on main are all 0 detections today.
Summary
Bitdefender (and the engines that license its signatures: ALYac, Arcabit, Emsisoft, GData, eScan, VIPRE) quarantine
scripts/scan_packages.pyasGeneric.PY.STEALER.B.EE7760D1. Anyone who clones the repo or downloads its source zip with one of those products installed loses the file, and the Windows diagnostic runs on real machines kept tripping over it.The detection keys on the plain-text credential and wallet names in two rule tables,
RE_CRED_ACCESSandRE_CRYPTO_THEFT(.ssh,.aws,wallet.dat,id_rsa,seed phrase, the wallet folders, and so on), sitting next to the file's download and archive code. The engine joins adjacent and+concatenated literals before matching, so splitting the strings in place is not enough.Change
_joined(*parts)helper builds those two alternations at import time from split pieces, one alternative per line, with a comment saying why and how to add a new name.Verification
main, apart from the new helper.scan_archiveover 346 real archives (site-packages plus this repo'sscripts/,studio/,tests/,unsloth/) gives byte-identical findings (1478, including all 12 credential and wallet hits).requests,cryptography,paramikoandweb3prints the same output and exit code.tests/security/test_scan_packages.py,studio/backend/tests/test_consent_gate.pyand the related script tests pass.main's file is 8/62 with BitDefenderGeneric.PY.STEALER.B.EE7760D1; this version is 0/62.