Skip to content

Keep scan_packages.py from tripping Bitdefender's Python stealer signature - #12169

Merged
danielhanchen merged 2 commits into
mainfrom
av-fp-scan-packages
Sep 28, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
av-fp-scan-packages

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Summary

Bitdefender (and the engines that license its signatures: ALYac, Arcabit, Emsisoft, GData, eScan, VIPRE) quarantine scripts/scan_packages.py as Generic.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_ACCESS and RE_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

  • A small _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.
  • Nothing else in the file changes. Baselines, allowlists and the CLI output are untouched.

Verification

  • Every compiled pattern (text and flags), constant, rule table and the bytecode of every function is identical to main, apart from the new helper.
  • scan_archive over 346 real archives (site-packages plus this repo's scripts/, studio/, tests/, unsloth/) gives byte-identical findings (1478, including all 12 credential and wallet hits).
  • The full CLI run with the real baseline on requests, cryptography, paramiko and web3 prints the same output and exit code.
  • tests/security/test_scan_packages.py, studio/backend/tests/test_consent_gate.py and the related script tests pass.
  • VirusTotal: main's file is 8/62 with BitDefender Generic.PY.STEALER.B.EE7760D1; this version is 0/62.

…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.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-28T05:29:11.927869Z fb7106e Manual request
🔒 Security Review ✅ Completed 2026-09-28T05:31:10.050108Z fb7106e Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: fb7106e764

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: fb7106e764

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

danielhanchen added a commit to Datta0/unsloth-staging-3 that referenced this pull request Sep 28, 2026
@danielhanchen
danielhanchen merged commit 99c3928 into main Sep 28, 2026
25 of 27 checks passed
@danielhanchen
danielhanchen deleted the av-fp-scan-packages branch September 28, 2026 06:05
danielhanchen added a commit that referenced this pull request Sep 28, 2026
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.
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…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.
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
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.
danielhanchen added a commit that referenced this pull request Nov 24, 2026
… 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants