Repository navigation
fix(security): re-baseline the huggingface-hub HTTP backoff loop for 1.x - #8135
Merged
Merged
Conversation
All three pip scan-packages shards fail on the same single unsuppressed
CRITICAL:
[1] CRITICAL C2 polling/beaconing loop detected
Package: huggingface-hub
File: huggingface_hub/utils/_http.py
Evidence: L461: while True: sha256:0c9641548adea74be4a8b0e86e8b75cc937a2b0f833b57dfa3d30d3e24d2537a
Each shard reports 1 CRITICAL and 0 HIGH, so this one finding is what turns
SCAN_ENFORCE=1 into exit 1 on studio, hf-stack and extras alike.
The finding is the retry-with-exponential-backoff loop RE_C2_POLLING is meant
to catch in malware, matching here on a legitimate library. It was already
reviewed and baselined twice, at L462 and L298, against huggingface-hub 0.x.
huggingface-hub has since released 1.x, which moved from requests to httpx and
refactored http_backoff into a shared _http_backoff_impl. The greedy DOTALL
span the check records therefore covers different code, its digest changed, and
the baseline correctly reopened the finding for review rather than suppressing
changed code under a coarse key.
Reviewed the new code in 1.27.0. huggingface_hub/utils/_http.py:461 is
_http_backoff_impl, "Internal implementation of HTTP backoff logic shared
between http_backoff and http_stream_backoff": it retries an httpx request on
configured exception types and status codes, sleeps with exponential backoff
bounded by max_wait_time, and honours a 429 rate-limit reset. No beaconing, no
remote-controlled interval, no payload execution. Benign, same as the two
entries it succeeds.
Adds the 1.x entry rather than replacing the 0.x ones, matching how this file
already carries several entries per file across versions (hf_api.py has three),
so a pinned older huggingface-hub stays covered.
Verified: scan_packages.py huggingface-hub goes from
"Summary: 1 CRITICAL, 6 MEDIUM" (3 suppressed) to
"Summary: 6 MEDIUM" (4 suppressed), exit 0.
danielhanchen
force-pushed
the
fix/scan-baseline-hf-hub-1x
branch
from
August 8, 2026 02:54
a31e633 to
22b9c82
Compare
danielhanchen
pushed a commit
to danielhanchen/unsloth-staging-2
that referenced
this pull request
Aug 8, 2026
unslothai#8135 re-baselined the huggingface_hub 1.x backoff loop, so that half of this branch is done upstream. What is left is a defect it did not touch: the shipped baseline carries five openai entries twice. openai/_base_client.py C2 polling/beaconing loop openai/auth/_workload.py IMDS + network calls openai/resources/beta/responses/responses.py C2 polling/beaconing loop openai/resources/realtime/realtime.py C2 polling/beaconing loop openai/resources/responses/responses.py C2 polling/beaconing loop 223 entries, 218 distinct. A duplicated suppression is not harmless: whoever removes one copy to un-suppress a finding still gets no finding, because the second copy is still matching. The 111 tests here cover the baseline's shape and matching semantics, including the duplicate check that caught this. Every one passes against main once the five copies are gone.
This was referenced Aug 8, 2026
danielhanchen
added a commit
that referenced
this pull request
Aug 8, 2026
#8135 re-baselined the huggingface_hub 1.x backoff loop, so that half of this branch is done upstream. What is left is a defect it did not touch: the shipped baseline carries five openai entries twice. openai/_base_client.py C2 polling/beaconing loop openai/auth/_workload.py IMDS + network calls openai/resources/beta/responses/responses.py C2 polling/beaconing loop openai/resources/realtime/realtime.py C2 polling/beaconing loop openai/resources/responses/responses.py C2 polling/beaconing loop 223 entries, 218 distinct. A duplicated suppression is not harmless: whoever removes one copy to un-suppress a finding still gets no finding, because the second copy is still matching. The 111 tests here cover the baseline's shape and matching semantics, including the duplicate check that caught this. Every one passes against main once the five copies are gone. Co-authored-by: danielhanchen <[email protected]>
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 are red onmain, and all three fail on the same single unsuppressed CRITICAL:Each shard reports 1 CRITICAL and 0 HIGH, so this one finding is the whole reason
SCAN_ENFORCE=1exits 1 onstudio,hf-stackandextrasalike.Why it reopened
RE_C2_POLLINGlooks for awhile Trueloop containing a sleep and an HTTP call. That is the right shape for malware beaconing and also the exact shape of any retry-with-backoff helper, sohuggingface_hub/utils/_http.pyhas been reviewed and baselined before, twice, at L462 and L298 against huggingface-hub 0.x.huggingface-hub has since released 1.x, which moves from
requeststohttpxand refactorshttp_backoffinto a shared_http_backoff_impl. The check uses a greedyDOTALLspan, so its recorded evidence digest covers a large region of the file; that region is now different code and the digest changed. The baseline did exactly what it is documented to do and reopened the finding for review instead of suppressing changed code under a coarse key. This is dependency drift, not a regression in this repo.Review of the new code
huggingface_hub/utils/_http.py:461in 1.27.0 is_http_backoff_impl, described upstream as "Internal implementation of HTTP backoff logic shared betweenhttp_backoffandhttp_stream_backoff". It retries anhttpxrequest on caller-configured exception types and status codes, sleeps with exponential backoff bounded bymax_wait_time, and honours a 429 rate-limit reset. There is no beaconing, no remote-controlled interval, and no payload execution. Benign, the same judgement as the two entries it succeeds.The change
One entry added. I added the 1.x entry rather than replacing the 0.x ones, matching how this file already carries several entries per file across versions (
hf_api.pyhas three), so a pinned older huggingface-hub stays covered.Verification
Locally,
python scripts/scan_packages.py huggingface-hubgoes fromSummary: 1 CRITICAL, 6 MEDIUM(3 suppressed) toSummary: 6 MEDIUM(4 suppressed), exit 0.I also ran the real
Security auditworkflow on a staging replica of this branch rather than queueing it here. All three shards pass, each with exactly one more finding suppressed and the CRITICAL gone:1 CRITICAL, 295 MEDIUM295 MEDIUM1 CRITICAL, 190 MEDIUM190 MEDIUM1 CRITICAL, 182 MEDIUM182 MEDIUMWorth considering separately
This will recur. The baseline pins a digest over a greedy
DOTALLspan of a third-party file, so any upstream release that edits anywhere in that span reopens the entry and turns the security gate red with no change on our side. That is a deliberate and defensible trade, precision over stability, but it does mean routine dependency bumps can block CI. Narrowing the recorded span for this check, or pinninghuggingface-hub, would both reduce the churn. Out of scope here.