Skip to content

Stop committing the two fixture archives that antivirus vendors flag - #10979

Merged
danielhanchen merged 4 commits into
mainfrom
av-fp-fixtures-no-committed-archives
Sep 15, 2026
Merged

danielhanchen merged 4 commits into
mainfrom
av-fp-fixtures-no-committed-archives

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Follows up discussion #9577, where you and @Sermoris tracked the repeated unsloth-main.zip detections down to two specific files.

What is happening

tests/security/fixtures/malicious_sdist.tar.gz and malicious_wheel.whl embed the May-12 IOC literal on purpose, so the scan_packages.py regression tests can prove the scanner trips on it. That makes them true positives for other vendors too. Per the per-file scan in #9577, they are the only two detected files in the whole fixture set:

fixture size detections
malicious_sdist.tar.gz 561 B 2/60 (Tencent, Rising)
malicious_wheel.whl 1414 B 2/65 (Tencent, Rising)
everything else in fixtures/ 0

And their presence is what makes Panda report Exploit/CVE-2014-6271 against GitHub's repository archive.

#10060 took the test tree out of the PyPI artifacts, which fixed those. A repository archive contains tests/ by construction, so it kept matching and users kept re-reporting it, twice in that thread alone. I said there that no packaging change can affect it. That is true, but a fixture change can: fixtures/_build.py is already a complete, deterministic builder for exactly these archives, and nothing invoked it. The built outputs were simply committed beside it.

Change

Build them at session start instead of committing them.

  • tests/security/conftest.py gains a session-scoped autouse fixture calling _build.build_all(). It generates in place, so all dozen-odd FIXTURES / "malicious_wheel.whl" call sites keep working unchanged. Unlike the network_blocker fixture directly above it, this patches nothing and has no teardown, so session scope carries none of the leak-past-the-suite risk that docstring records.
  • The three archives are removed from git and added to .gitignore.
  • _build.py assembles the IOC host and artifact names from concatenated pieces, the way test_scan_packages.py already writes _ioc_host = "git-tanstack." + "com". Insurance only, since the CVE detection report on virus total #9577 scan found the .py sources undetected. The archives leaving git is the part that matters.
  • New test_no_archive_fixture_is_committed reads git ls-files, not the directory, because the files are present on disk in every run and it is the index that has to stay empty.

The scanner pattern tables in scripts/scan_packages.py, scan_npm_packages.py and lockfile_supply_chain_audit.py are untouched: they have to contain the IOC to function, and all were undetected.

The bytes are unchanged

Determinism is already pinned by SOURCE_DATE_EPOCH = 0 and the 1980 DOS-epoch zip dates, and I checked it rather than assumed it. The generated archives are byte-identical to the committed ones for all three, so the scanner trips on exactly what it tripped on before. test_fixture_bytes_are_deterministic still compares a rebuild against the copy the suite is using, so it keeps its meaning.

Verification

  • 589 passed, 6 skipped across tests/security/, with the three archives deleted from disk first, so the fixture is what produces them.
  • The new guard was confirmed to bite by re-adding the three files to the index, reproducing main's state, where it fails.
  • sha256 of each generated archive compared against the committed copy: identical.

What this does and does not do

It stops new detections against the repository archive. It does not retroactively clean the hashes already on VirusTotal, and Panda will keep flagging an archive of any older commit, since those still contain the files. Worth saying in the #9577 thread so nobody expects the existing report to change.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 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-15T13:02:05.439209Z 42a6b79 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.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

`tests/security/fixtures/malicious_sdist.tar.gz` and `malicious_wheel.whl` embed the May-12 IOC
literal on purpose, so the `scan_packages.py` regression tests can prove the scanner trips on it.
That makes them true positives for other vendors too. Per the per-file scan in discussion #9577,
they are the only two detected files in the whole fixture set: the sdist scores 2/60 and the wheel
2/65 (Tencent, Rising), and their presence is what makes Panda report `Exploit/CVE-2014-6271`
against GitHub's `unsloth-main.zip`.

#10060 took the test tree out of the PyPI artifacts, which fixed those. A repository archive
contains `tests/` by construction, so it kept matching and users kept re-reporting it, twice in
that thread alone. I said there that no packaging change can affect it. That is true, but a fixture
change can: `fixtures/_build.py` is already a complete deterministic builder for exactly these
archives, and nothing invoked it. The built outputs were simply committed beside it.

So build them at session start instead:

- `tests/security/conftest.py` gains a session-scoped autouse fixture calling `_build.build_all()`.
  It generates in place, so all dozen-odd `FIXTURES / "malicious_wheel.whl"` call sites keep
  working unchanged. Unlike the `network_blocker` fixture above it, this patches nothing and has no
  teardown, so session scope carries none of the leak-past-the-suite risk that docstring records.
- The three archives are removed from git and added to `.gitignore`.
- `_build.py` assembles the IOC host and artifact names from concatenated pieces, the way
  `test_scan_packages.py` already writes `_ioc_host = "git-tanstack." + "com"`. Insurance only: the
  #9577 scan found the `.py` sources undetected, so the archives leaving git is the part that
  matters.
- New `test_no_archive_fixture_is_committed` reads `git ls-files`, not the directory, because the
  files are present on disk in every run and it is the index that has to stay empty.

Determinism is already pinned by `SOURCE_DATE_EPOCH = 0` and the 1980 DOS-epoch zip dates, and I
checked it rather than assumed it: the generated archives are byte-identical to the committed ones
for all three. `test_fixture_bytes_are_deterministic` still compares a rebuild against the copy the
suite is using, so it keeps its meaning.

Verification: 589 passed, 6 skipped across `tests/security/`, with the archives deleted from disk
first so the fixture is what produces them. The new guard was confirmed to bite by re-adding the
three files to the index, reproducing main's state, where it fails.

This does not clean the hashes already on VirusTotal, and Panda will keep flagging an archive of any
older commit. It stops new ones.
@danielhanchen
danielhanchen force-pushed the av-fp-fixtures-no-committed-archives branch from 191043f to c56be3f Compare September 15, 2026 07:55
danielhanchen and others added 2 commits September 15, 2026 09:35
…race each other

`.github/workflows/workflow-trigger-lint.yml:130` runs `pytest -q -n 4` over `tests/security` with
the default `--dist load`, which scatters tests from ONE file across all four workers. Each worker
runs the session-scoped autouse fixture and rewrote these three archives at their fixed paths while
the others were reading them, and `write_bytes` truncates before it writes.

The failure this produces is the nasty kind. A reader that catches the truncated window does not get
a corrupt-file error; it gets a short member list and fails asserting scanner semantics --
`assert any("setup.py" in f.filename for f in blockers)` -- which nobody would trace back to a write
race.

Two guards, because either alone leaves a hole. The write is skipped entirely when the bytes on disk
are already correct, so in the normal case only the first worker writes at all; otherwise it goes to
a pid-unique temp name and `os.replace`, which is atomic on POSIX and on Windows. Without the pid the
workers would collide on the temp file instead of the final one.

What makes this sound rather than merely narrower: the build is deterministic (SOURCE_DATE_EPOCH,
1980 DOS times), so a reader sees either the complete old file or the complete new one and those are
byte-identical. The three archives still hash to fe6927b5, 0c327818 and 7516530a -- the same bytes
that were committed before they were generated -- and a test now pins that, because the equivalence
argument depends on it.

Honest note on how this was found and confirmed: a review flagged it and reported reproducing it at
16-28% with `-n 8`. I could NOT reproduce it in 22 runs on this box. The hazard is real by
construction and the CI invocation that exposes it is real, but I am not going to claim a
reproduction I did not get.
@danielhanchen

Copy link
Copy Markdown
Member Author

Fixed: the generated fixtures could race four CI workers

.github/workflows/workflow-trigger-lint.yml:130 runs python3 -m pytest -q -n 4 and line 172 includes tests/security, with the default --dist load -- which scatters tests from one file across all four workers. Every worker runs the session-scoped autouse fixture and rewrote these three archives at their fixed paths while the others were reading them, and write_bytes truncates before it writes.

The failure this produces is the nasty kind. A reader that catches the truncated window does not get a corrupt-archive error; it gets a short member list and fails asserting scanner semantics -- assert any("setup.py" in f.filename for f in blockers) -- which nobody would trace back to a write race.

Two guards, because either alone leaves a hole:

  • The write is skipped entirely when the bytes on disk are already correct, so in the normal case only the first worker writes at all. build_all() previously rewrote unconditionally on every run.
  • Otherwise it goes to a pid-unique temp name and os.replace, atomic on POSIX and Windows. Without the pid the workers would collide on the temp file instead of the final one.

What makes this sound rather than merely narrower: the build is deterministic (SOURCE_DATE_EPOCH, 1980 DOS times), so a reader sees either the complete old file or the complete new one and those are byte-identical. The three archives still hash to fe6927b5, 0c327818 and 7516530a -- the same bytes that were committed before they were generated -- and a test now pins that, because the equivalence argument depends on it.

Honest note on the evidence

A review flagged this and reported reproducing it at 16-28% with -n 8. I could not reproduce it in 22 runs on this box. The hazard is real by construction and the CI invocation that exposes it is real, but I am not going to claim a reproduction I did not get. The fix costs nothing and removes the question.

Two things independently proven clean

  • Packaging is byte-for-byte unaffected. sdist and wheel were built on the merge base and on this branch and the file lists diffed: identical, 1220 and 824 entries. The fixtures were never shipped in the first place -- MANIFEST.in already has prune tests, and wheel-smoke.yml:276 enforces it. No reference in MANIFEST.in, pyproject.toml, package_data or the Tauri bundle.resources.
  • The tree stays clean. git status is empty after a test run; all three paths are covered by .gitignore:268-270. A read-only source tree fails with an explicit RuntimeError naming the cause, which is the right outcome rather than a confusing one.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 15, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

The assignment had no teardown. That was harmless while this file was run as a script, and is not
harmless now that a session fixture calls it partway through a broader pytest run: it overwrote
any caller-provided value for the remainder of the worker, and every later test and subprocess
inherited the false epoch.

Nothing in the builder read it either. Each writer is handed the fixed timestamp directly and
zipfile takes the 1980 DOS tuple, so the assignment bought nothing in exchange for that reach.
The generated bytes are unchanged, confirmed by hash before and after: fe6927b5, 0c327818,
7516530a.
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 15, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 15, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 15, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 42a6b7994f

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

@danielhanchen
danielhanchen merged commit 0a12e13 into main Sep 15, 2026
30 of 33 checks passed
@danielhanchen
danielhanchen deleted the av-fp-fixtures-no-committed-archives branch September 15, 2026 13:23
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…nslothai#10979)

* Stop committing the two fixture archives that antivirus vendors flag

`tests/security/fixtures/malicious_sdist.tar.gz` and `malicious_wheel.whl` embed the May-12 IOC
literal on purpose, so the `scan_packages.py` regression tests can prove the scanner trips on it.
That makes them true positives for other vendors too. Per the per-file scan in discussion unslothai#9577,
they are the only two detected files in the whole fixture set: the sdist scores 2/60 and the wheel
2/65 (Tencent, Rising), and their presence is what makes Panda report `Exploit/CVE-2014-6271`
against GitHub's `unsloth-main.zip`.

unslothai#10060 took the test tree out of the PyPI artifacts, which fixed those. A repository archive
contains `tests/` by construction, so it kept matching and users kept re-reporting it, twice in
that thread alone. I said there that no packaging change can affect it. That is true, but a fixture
change can: `fixtures/_build.py` is already a complete deterministic builder for exactly these
archives, and nothing invoked it. The built outputs were simply committed beside it.

So build them at session start instead:

- `tests/security/conftest.py` gains a session-scoped autouse fixture calling `_build.build_all()`.
  It generates in place, so all dozen-odd `FIXTURES / "malicious_wheel.whl"` call sites keep
  working unchanged. Unlike the `network_blocker` fixture above it, this patches nothing and has no
  teardown, so session scope carries none of the leak-past-the-suite risk that docstring records.
- The three archives are removed from git and added to `.gitignore`.
- `_build.py` assembles the IOC host and artifact names from concatenated pieces, the way
  `test_scan_packages.py` already writes `_ioc_host = "git-tanstack." + "com"`. Insurance only: the
  unslothai#9577 scan found the `.py` sources undetected, so the archives leaving git is the part that
  matters.
- New `test_no_archive_fixture_is_committed` reads `git ls-files`, not the directory, because the
  files are present on disk in every run and it is the index that has to stay empty.

Determinism is already pinned by `SOURCE_DATE_EPOCH = 0` and the 1980 DOS-epoch zip dates, and I
checked it rather than assumed it: the generated archives are byte-identical to the committed ones
for all three. `test_fixture_bytes_are_deterministic` still compares a rebuild against the copy the
suite is using, so it keeps its meaning.

Verification: 589 passed, 6 skipped across `tests/security/`, with the archives deleted from disk
first so the fixture is what produces them. The new guard was confirmed to bite by re-adding the
three files to the index, reproducing main's state, where it fails.

This does not clean the hashes already on VirusTotal, and Panda will keep flagging an archive of any
older commit. It stops new ones.

* Publish the generated fixtures atomically, so four CI workers cannot race each other

`.github/workflows/workflow-trigger-lint.yml:130` runs `pytest -q -n 4` over `tests/security` with
the default `--dist load`, which scatters tests from ONE file across all four workers. Each worker
runs the session-scoped autouse fixture and rewrote these three archives at their fixed paths while
the others were reading them, and `write_bytes` truncates before it writes.

The failure this produces is the nasty kind. A reader that catches the truncated window does not get
a corrupt-file error; it gets a short member list and fails asserting scanner semantics --
`assert any("setup.py" in f.filename for f in blockers)` -- which nobody would trace back to a write
race.

Two guards, because either alone leaves a hole. The write is skipped entirely when the bytes on disk
are already correct, so in the normal case only the first worker writes at all; otherwise it goes to
a pid-unique temp name and `os.replace`, which is atomic on POSIX and on Windows. Without the pid the
workers would collide on the temp file instead of the final one.

What makes this sound rather than merely narrower: the build is deterministic (SOURCE_DATE_EPOCH,
1980 DOS times), so a reader sees either the complete old file or the complete new one and those are
byte-identical. The three archives still hash to fe6927b5, 0c327818 and 7516530a -- the same bytes
that were committed before they were generated -- and a test now pins that, because the equivalence
argument depends on it.

Honest note on how this was found and confirmed: a review flagged it and reported reproducing it at
16-28% with `-n 8`. I could NOT reproduce it in 22 runs on this box. The hazard is real by
construction and the CI invocation that exposes it is real, but I am not going to claim a
reproduction I did not get.

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Stop build_all leaking SOURCE_DATE_EPOCH into the rest of the worker

The assignment had no teardown. That was harmless while this file was run as a script, and is not
harmless now that a session fixture calls it partway through a broader pytest run: it overwrote
any caller-provided value for the remainder of the worker, and every later test and subprocess
inherited the false epoch.

Nothing in the builder read it either. Each writer is handed the fixed timestamp directly and
zipfile takes the 1980 DOS tuple, so the assignment bought nothing in exchange for that reach.
The generated bytes are unchanged, confirmed by hash before and after: fe6927b5, 0c327818,
7516530a.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.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