Skip to content

Security audit: re-approve the unsloth-zoo compiler.py finding after 2026.8.14 - #9674

Merged
danielhanchen merged 1 commit into
mainfrom
security-audit-rebaseline-zoo-2026-8-14
Aug 25, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
security-audit-rebaseline-zoo-2026-8-14

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

pip scan-packages :: hf-stack has been failing on main, on the nightly schedule and on every open pull request since 04:10Z today. It is not any one PR's doing.

What happened

unsloth-zoo 2026.8.14 went to PyPI at 2026-08-25T04:00:39Z. The last green run of that job started at 04:00:07Z, 32 seconds earlier, and resolved 2026.8.13. The next run started at 04:10:05Z, resolved 2026.8.14, and went red. Every run since has been red.

The scanner's baseline keys each approved finding on a hash of the code it matched, so that a version bump does not silently re-approve changed code. 2026.8.14 changed unsloth_zoo/compiler.py, so the entry stopped matching and the finding reopened as 1 HIGH. With SCAN_ENFORCE=1 that fails the job.

What actually changed in the flagged code

Diffing the approved evidence against the new evidence, 85 matched lines against 84, the entire delta is:

-        exec(f"import {model_location}", globals())
-    modeling_file = eval(model_location)
+    exec("import transformers", globals())

In context, 2026.8.14 now does:

    model_location = f"transformers.models.{model_type}.modeling_{model_type}"
    try:
        modeling_file = importlib.import_module(model_location)
    except ModuleNotFoundError:
        return
    # Later `eval(model_location)` calls need `transformers` bound in globals
    exec("import transformers", globals())

An interpolated exec import and an eval of an interpolated name became an importlib.import_module call plus one exec of a constant string. That is strictly less dynamic-code surface than the body already approved, so this re-approves it rather than treating it as a new finding.

Verification

Against unsloth-zoo==2026.8.14, offline, no CI needed:

baseline result
main today exit 1, 1 HIGH, 7 MEDIUM, 5 HIGH suppressed
this PR exit 0, 7 MEDIUM, 6 HIGH suppressed
this PR, entry re-pinned to a body carrying an extra exec(base64.b64decode(...)) exit 1, 1 HIGH again

The last row is the one that matters: the entry suppresses exactly one reviewed body of code. It is not a waiver on unsloth_zoo/compiler.py or on the obfuscation check, and the next release that touches these lines will reopen it, which is the intended behaviour.

Note

This is the third entry for this same finding, after 2026.8.12 and 2026.8.13. The hash covers indentation and line wrapping, so a reformat of benign code reopens it and hard-fails main until someone re-approves. Worth deciding separately whether that tradeoff is right; this PR only unblocks the queue.

…2026.8.14

unsloth-zoo 2026.8.14 (PyPI, 2026-08-25T04:00:39Z) replaced

    exec(f"import {model_location}", globals())
    modeling_file = eval(model_location)

in unsloth_zoo/compiler.py with

    modeling_file = importlib.import_module(model_location)
    exec("import transformers", globals())

That is the only change to the code the scanner matches on, and it is a
reduction in dynamic-code surface: an interpolated import and an eval of an
interpolated name become an importlib call plus one constant-string exec.

The baseline keys each approved finding on a hash of the matched code, so a
changed body correctly reopens it. It reopened as 1 HIGH and, with
SCAN_ENFORCE=1, has failed 'pip scan-packages :: hf-stack' on every run since
04:10Z: main pushes, the nightly schedule and unrelated pull requests alike.
The last green run started at 04:00:07Z, 32 seconds before the release.

Re-approves the new body only. Verified against unsloth-zoo 2026.8.14: exit 1
with 1 HIGH before, exit 0 with it suppressed after. Pinning the entry to any
other body puts the HIGH straight back, so this is not a blanket waiver on the
file or the check.
@danielhanchen
danielhanchen merged commit a584eda into main Aug 25, 2026
17 checks passed
@danielhanchen
danielhanchen deleted the security-audit-rebaseline-zoo-2026-8-14 branch August 25, 2026 09:29
danielhanchen added a commit that referenced this pull request Aug 25, 2026
…2026.8.14 (#9674)

unsloth-zoo 2026.8.14 (PyPI, 2026-08-25T04:00:39Z) replaced

    exec(f"import {model_location}", globals())
    modeling_file = eval(model_location)

in unsloth_zoo/compiler.py with

    modeling_file = importlib.import_module(model_location)
    exec("import transformers", globals())

That is the only change to the code the scanner matches on, and it is a
reduction in dynamic-code surface: an interpolated import and an eval of an
interpolated name become an importlib call plus one constant-string exec.

The baseline keys each approved finding on a hash of the matched code, so a
changed body correctly reopens it. It reopened as 1 HIGH and, with
SCAN_ENFORCE=1, has failed 'pip scan-packages :: hf-stack' on every run since
04:10Z: main pushes, the nightly schedule and unrelated pull requests alike.
The last green run started at 04:00:07Z, 32 seconds before the release.

Re-approves the new body only. Verified against unsloth-zoo 2026.8.14: exit 1
with 1 HIGH before, exit 0 with it suppressed after. Pinning the entry to any
other body puts the HIGH straight back, so this is not a blanket waiver on the
file or the check.
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.

1 participant