Repository navigation
Security audit: re-baseline the benign findings that reopened on main - #7741
Merged
Merged
Conversation
All three pip scan-packages shards fail on main. Every unsuppressed finding is
a pattern false positive in a mainstream library or in our own published test
files, and each one already has an entry in the allowlist under an older
evidence hash.
The baseline key is (package, package-relative file, check, evidence_hash),
and the hash is over the matched code. Line shifts and version bumps are
absorbed, but when an upstream release edits a flagged line the hash moves and
the entry reopens for re-review. That is what happened here.
Reviewed and appended the 11 reopened findings:
- fastapi/routing.py, huggingface_hub/hf_api.py, openai/_base_client.py:
flagged as C2 beaconing. All three are ordinary loops, hf_api and
_base_client being paginators that advance until there is no next page.
- huggingface_hub/_sandbox.py: flagged as a staged dropper. This is the
Sandbox feature bootstrap, fetching sbx-server from the endpoint configured
on the HfApi client.
- IPython/core/interactiveshell.py and traitlets/config/loader.py: flagged as
downloading and executing remote code. Both are exec(compile(...)) over a
local file, which is what an interactive shell and a config loader do.
- unsloth_zoo/mlx/loader.py: __import__ over a hardcoded tuple of mlx_lm
module names, paired with mx.eval() calls that evaluate MLX arrays rather
than Python source.
- unsloth-zoo tests: a literal temporary_location="/tmp/ignored" kwarg,
compile()/exec() over codegen the test itself produced, and
__import__("math").exp inside a pytest.approx assert.
Existing entries are untouched: the diff is a single append hunk with no
deletions, and the first 203 entries are byte identical.
Verified by reproducing all three shards locally on Python 3.12, matching the
workflow pin. Before the change the shards reproduce the exact CI counts. After
it, all three exit 0 with unchanged MEDIUM counts and suppressed counts up by
exactly the number of findings each shard was failing on.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All three
pip scan-packagesshards in Security audit are failing onmain, and have been for several commits (3f2fc5af,8c3c7511,bba8e395,c67410a7,f0d88d7b). This re-baselines the findings that reopened.Before
After
Why they reopened
The allowlist key is
(package, package-relative file, check, evidence_hash), and the hash is taken over the matched code with theL<NN>:markers stripped. Line shifts and version bumps are absorbed by design; a change to the flagged code itself moves the hash and reopens the entry for re-review.The scanner resolves unpinned dependencies fresh from PyPI on every run, so when an upstream release edits a flagged line, the entry reopens. Ten of these eleven
(package, file, check)tuples already had an entry in the baseline under an older hash.fastapi/routing.py,huggingface_hub/hf_api.py,openai/_base_client.pyandunsloth_zoo/mlx/loader.pyhave each been through this before, which is why the file already carries an appended block at the end from a previous round. So this is the mechanism behaving as intended rather than a new exposure.No dependency manifest changed, and nothing here is a new package or a new version pin.
The eleven findings
Each was read in the actual source rather than taken from the report line.
Loops flagged as C2 beaconing
fastapi/routing.py:594,huggingface_hub/hf_api.py:4811,openai/_base_client.py:276. The latter two are paginators: yield a page, advance whilehas_next_page(), return otherwise.huggingface_hub/_sandbox.py:84-88, flagged as a staged dropperThe one finding that genuinely downloads and executes, so I checked it against upstream rather than assuming. It is the bootstrap for the Sandboxes feature, Apache-2.0, authored by the huggingface_hub team, and it fetches
sbx-serverfrom the endpoint configured on theHfApiclient rather than a hardcoded third-party host. Documented at https://huggingface.co/docs/huggingface_hub/main/guides/sandbox.exec(compile(...))flagged as downloading and executing remote codeIPython/core/interactiveshell.py:2998andtraitlets/config/loader.py:646. Both compile and execute a local file: running user code is what an interactive shell does, and loading a Python config file is what the config loader does. The paired "network" evidence on the second IPython finding isurlopenin the%loadmagic, matched against aHistoryManagerimport for the filesystem half.Our own published package
unsloth_zoo/mlx/loader.py:4096:__import__(module_name, fromlist=["_"])wheremodule_nameiterates a hardcoded tuple ofmlx_lm.tuner.loraandmlx_lm.tuner.dora, not caller input. The paired exec evidence is a dozenmx.eval(model.parameters())calls, which evaluate MLX arrays and are unrelated to Pythoneval.tests/test_mlx_save_export_regressions.py:246: a literaltemporary_location="/tmp/ignored"kwarg in a call-forwarding assertion.tests/test_compiler_decorated_forward.py:compile()andexec()over source the test generated and asserted against a line earlier.tests/test_mlx_trainer_internals.py:2355:__import__("math").exp(2.5)inside apytest.approxassert.Shape of the change
One append hunk, 88 lines, no deletions. The existing 203 entries are byte identical and
_commentandversionare unchanged, so nothing was reordered or rewritten.Checked on the merged file: all 214 entries' stored
evidence_hashrecompute to themselves under the scanner's own_evidence_hash, so there are no hand-edited hashes. The file has 5 duplicate keys, allopenaipairs that predate this change; none of the new entries duplicates an existing key.Verification
Reproduced all three shards locally against the same inputs the workflow builds, on Python 3.12 to match the
setup-pythonpin. This matters: on 3.13 the studio shard reports two extramultiprocessfindings, becausemultiprocessships per-interpreter wheels that vendor the corresponding CPythonmultiprocessing. Those two are not in this change, since they do not occur under the pinned version.Before the change the local runs match CI exactly. hf-stack reproduces
3 CRITICAL, 3 HIGH, 184 MEDIUMwith117 suppressed (80 CRITICAL, 37 HIGH), the same numbers as the failing job, and every evidence hash matches.After the change:
Each shard's suppressed count rises by exactly the number of findings it was failing on, and no MEDIUM count moves, so the new entries match only their own keys and nothing broader.
Follow-up worth considering separately
This will recur on the next upstream release that touches any flagged line, which is the cost of the content-hash key. Options are to pin the scanned set, or to let an entry match on
(package, file, check)with the hash recorded but advisory. Both are policy changes to the scanner rather than a baseline refresh, so I have kept them out of this PR.