Skip to content

Stop the zoo digest pin living in two places - #10206

Merged
danielhanchen merged 4 commits into
mainfrom
security/sync-zoo-digest-pin
Sep 3, 2026
Merged

danielhanchen merged 4 commits into
mainfrom
security/sync-zoo-digest-pin

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Sep 2, 2026 •

Copy link
Copy Markdown
Member

The compiler.py obfuscation digest was written in two places: scripts/scan_packages_baseline.json, and again as a hardcoded expectation in tests/security/test_scan_packages.py::test_context_dependent_unsloth_zoo_findings_are_digest_pinned.

#10187 re-approved unsloth-zoo 2026.8.17 and moved the baseline copy from 58f43e3b... to f1f6751f.... The copy in the test was left behind, so the pin and the guard that checks it have disagreed ever since.

That fails on main, not just on PRs: the same assertion is red at dddd2d654, 4792f9bb2 and 28a6c36a2, and it takes two checks down with it wherever it runs.

  • Repo tests (CPU) -> 1 failed, 15826 passed
  • workflow-trigger lint (pull_request_target / cache-poisoning) -> same single assertion

Roughly 50 open PRs are red on those two checks for this reason and nothing in their own branches.

What this changes

The first version of this PR just moved the literal to match. That fixes today and schedules the next one, so instead the duplicate copy is gone and the test asserts the property it is named for.

The security value here is file_sha256: _partition_baseline only suppresses a pinned entry while the file still hashes to a reviewed value, so any edit to unsloth_zoo/compiler.py or unsloth_zoo/vision_utils.py reopens the finding and asks for a fresh review. That mechanism lives in the baseline and is covered by test_context_dependent_unsloth_zoo_pins_reopen_on_other_file_changes. Repeating the digest in the test pinned nothing extra, because whoever edits the baseline can edit the test in the same commit. It only added a second copy to forget.

So the test now checks that each of the three (file, check) pairs still carries a well-formed reviewed digest, and says what to do when one does not:

unsloth_zoo/compiler.py is baselined for 'Advanced obfuscation (marshal/compile/zlib) + exec/eval'
with no reviewed file digest, so it is approved on evidence that a later payload can leave
unchanged. Re-approve it with --write-baseline and keep the file_sha256 pin.

Verified the guard still fires: dropping file_sha256 from the compiler.py entry in the baseline fails the test, restoring it passes.

A (file, check) pair can hold several entries, one per revision of the matched lines a release has shipped, and only the live one carries a pin. compiler.py already has four such entries. The old dict comprehension only ever checked whichever came last in the file, which is a property nobody chose.

Second copy, same file

test_context_dependent_unsloth_zoo_pins_reopen_on_other_file_changes asserted len(targets) == 3 on the pinned entries. That holds only while re-approvals replace a pin in place. The torch and huggingface-hub entries in this same baseline are maintained by appending a revision, and the first zoo re-approval done that way would have turned this red for everyone too. It now asserts the three (file, check) pairs are covered, which is the thing it means.

Result

tests/security/test_scan_packages.py goes from 1 failed / 132 passed on origin/main to 133 passed. Nothing here approves anything new: the human review the pin exists to force already happened in #10187.

Note this is not the only thing red on main right now. Repo tests (CPU) runs unsloth_cli/tests after tests/, so #10231 is what it fails on next. Frontend build + bundle sanity, GGUF inference smoke and pip scan-packages are red on main for three unrelated reasons, tracked separately.

… baseline

#10187 re-approved unsloth-zoo 2026.8.17 and moved the compiler.py obfuscation
finding's pinned digest in scan_packages_baseline.json, but the same digest is
written a second time in the test that guards the pin, and that copy was left
on the old value. The pin and its guard have disagreed since, so
test_context_dependent_unsloth_zoo_findings_are_digest_pinned fails on main and
on every open PR, taking Repo tests (CPU) and workflow-trigger lint with it.

This is the follow-up write only. The review the pin exists to force already
happened in #10187; nothing here re-approves anything.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 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-03T08:48:47.489722Z d26e5c5 Manual request
🔒 Security Review ✅ Completed 2026-09-03T08:51:01.202277Z d26e5c5 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 danielhanchen changed the title Security audit: sync the zoo compiler.py digest pin with the approved baseline Stop the zoo digest pin living in two places Sep 3, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c591ba320e

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

continue
digest = entry.get("file_sha256")
if isinstance(digest, str) and re.fullmatch(r"[0-9a-f]{64}", digest):
pinned.add(key)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Check the live evidence variant rather than any old pin

When a later zoo release is appended as a new evidence variant without file_sha256 while an older variant remains pinned, this aggregation still adds the pair and both tests pass: the reopen test only exercises entries that already have a digest. However, _load_baseline keys each variant by evidence_hash, so the new unpinned variant maps to None and suppresses that finding for any file contents. Since compiler.py already has multiple variants, the test must identify and require a pin on the live/current variant rather than accepting any historical pin for the same (file, check) pair.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correct, and this is the version I should have written. _load_baseline maps an unpinned variant to None, so appending one for a pair that already has a pinned variant would suppress the finding for any file contents while this test stayed green on the old pin.

Tightened in d26e5c5: every entry for these three pairs must carry a file_sha256, except the three superseded compiler.py variants that are already in the baseline unpinned, which are grandfathered by evidence_hash. Those are frozen by construction (an evidence hash is over code a past release shipped), so listing them brings back no drift, unlike the live digest this PR removed.

Verified by doing what you describe: appending a fourth unpinned compiler.py variant now fails with

unsloth_zoo/compiler.py has a new unpinned entry for 'Advanced obfuscation (marshal/compile/zlib) + exec/eval'
(evidence_hash '000...'). An unpinned variant suppresses that finding whatever the file contains, so a
re-approval has to carry file_sha256 rather than ride the evidence alone.

133 passed with the baseline as committed.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: c591ba320e

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

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: d26e5c5986

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

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

Reviewed commit: d26e5c5986

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
danielhanchen merged commit a508d06 into main Sep 3, 2026
17 of 21 checks passed
@danielhanchen
danielhanchen deleted the security/sync-zoo-digest-pin branch September 3, 2026 08:54
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