huggingface_hub v2.5.0 revokes leaked tokens and locks sandboxes offline

1 day ago

huggingface_hub v2.5.0 adds hf auth revoke for leaked tokens, sandboxes with no internet or an allowlist, SQL over Hub datasets by name, fsspec transactions for buckets, secretless OAuth for Spaces, and chat calls through the Hub router.

Ask about this presentation

Chapters

  1. 0:00Revoke a leaked token
  2. 0:10Only the token is needed
  3. 0:20Your own token stays safe
  4. 0:3002 Sandboxes
  5. 0:31No internet, or an allowlist
  6. 0:41Root can't lift it
  7. 0:49Pools mix both
  8. 1:0003 Datasets and buckets
  9. 1:01SQL by dataset name
  10. 1:12Write back to the Hub
  11. 1:22Checkpoints to buckets
  12. 1:34Best effort, buckets only
  13. 1:4404 Spaces and inference
  14. 1:45OAuth without a secret
  15. 1:55Users sign in again
  16. 2:07Chat through the router
  17. 2:18Fixes
  18. 2:28Should you upgrade?
Show transcript
  1. Version 2.5 of huggingface_hub adds a command for the moment a token leaks into a repo, a log or a shared snippet. hf auth revoke cancels it from your terminal right away.

    Slide text
    01 02 03 04 Tokens
    huggingface/huggingface_hub · GitHub release v2.5.0 · #5389
    Hugging Face

    huggingface_hub v2.5.0 revokes a leaked token in one command

    $ hf auth revoke hf_xxx hf_yyy
    ✓ Revocation requested for 2 token(s)
  2. You don't have to be logged in. Anyone who holds the raw token can revoke it, and its owner is told by email. The Hub answers revocation requested, whether that token existed or not.

    Slide text
    huggingface_hub v2.5.0
    01 02 03 04 Tokens
    huggingface/huggingface_hub · GitHub release v2.5.0 · #5389

    Revoking a token needs only the token

    The owner gets an email anyone holding the raw value can revoke it
    One reply for every request “revocation requested”, whether the token existed or not
  3. The revoke request goes out without your own authorization header, so the token you're working with can't be revoked by mistake. In Python, the new revoke_tokens helper does the same, a thousand tokens per batch.

    Slide text
    huggingface_hub v2.5.0
    01 02 03 04 Tokens
    huggingface/huggingface_hub · GitHub release v2.5.0 · #5389

    The token you are signed in with is never sent

    In Python, revoke_tokens() sends 1,000 tokens per batch

  4. Sandboxes.

    Slide text
    02
    Sandboxes
  5. A Hugging Face sandbox can now be cut off from the internet, or held to a list of IP ranges and hostnames. An agent inside can reach your vLLM server and the Hub, and nothing beyond them.

    Slide text
    huggingface_hub v2.5.0
    01 02 03 04 Sandboxes
    huggingface/huggingface_hub · GitHub release v2.5.0 · #5303

    Sandboxes can run with no internet, or reach only an allowlist

    $ hf sandbox create --network none
    $ hf sandbox create --network 10.0.0.0/8,huggingface.co:443
  6. The sandbox server enforces the policy with seccomp and Landlock. It covers every process the sandbox starts, and it stays in place for root inside the sandbox too.

    Slide text
    huggingface_hub v2.5.0
    01 02 03 04 Sandboxes
    huggingface/huggingface_hub · GitHub release v2.5.0 · #5303

    Even root inside the sandbox can’t lift the policy

    seccomp Landlock every process the sandbox starts
  7. Pools set the policy per sandbox, so one host can mix isolated and connected ones. On a pool host started by an older huggingface_hub, creation fails with an error instead of quietly connecting.

    Slide text
    huggingface_hub v2.5.0
    01 02 03 04 Sandboxes
    huggingface/huggingface_hub · GitHub release v2.5.0 · #5303

    One pool host runs isolated and connected sandboxes side by side

    An older pool host can’t apply the policy, so creation fails with SandboxError

  8. Datasets and buckets.

    Slide text
    03
    Datasets and buckets
  9. The hf datasets sql command now installs and loads the Hugging Face DuckDB extension by itself. You name the dataset with hf_dataset, instead of building read_parquet URLs by hand.

    Slide text
    huggingface_hub v2.5.0
    01 02 03 04 Datasets and buckets
    huggingface/huggingface_hub · GitHub release v2.5.0 · #5371

    Query a Hub dataset in SQL by its name

    $ hf datasets sql "SELECT * FROM
        hf_dataset('stanfordnlp/imdb') LIMIT 3"
  10. That extension can also copy query results into a dataset on the Hub. It needs DuckDB 2.0 or newer. Where it can't install, you get a warning and your existing parquet queries keep working.

    Slide text
    huggingface_hub v2.5.0
    01 02 03 04 Datasets and buckets
    huggingface/huggingface_hub · GitHub release v2.5.0 · #5371

    The same extension writes results back to the Hub

    Needs DuckDB 2.0 or newer. Without it you get a warning, and read_parquet queries keep working.

  11. HfFileSystem now supports fsspec transactions on buckets. Files upload when the block ends, and a block that raises skips the upload. PyTorch Lightning wraps every save in one, so its checkpoints can now land in a bucket.

    Slide text
    huggingface_hub v2.5.0
    01 02 03 04 Datasets and buckets
    huggingface/huggingface_hub · GitHub release v2.5.0 · #5272

    PyTorch Lightning checkpoints can now save straight to a bucket

    with hffs.transaction:
        with hffs.open("buckets/my-username/my-bucket/
                       checkpoints/last.ckpt", "wb") as f:
            f.write(data)   # uploaded when the block ends
  12. Each file uploads separately at commit time, so a failure partway through can leave the earlier files uploaded. Repo writes, deletes and copies inside a transaction raise an error before anything is touched.

    Slide text
    huggingface_hub v2.5.0
    01 02 03 04 Datasets and buckets
    huggingface/huggingface_hub · GitHub release v2.5.0 · #5272

    Transactions are best effort, and only for buckets

    Each file uploads on its own a failure partway can leave earlier files uploaded
    Repo writes, rm and cp_file raise NotImplementedError before anything is touched
  13. Spaces and inference.

    Slide text
    04
    Spaces and inference
  14. A Space that signs people in with Hugging Face can now run as a public OAuth client. PKCE is always on, and Spaces that still get a client secret keep working as before.

    Slide text
    huggingface_hub v2.5.0
    01 02 03 04 Spaces and inference
    huggingface/huggingface_hub · GitHub release v2.5.0 · #4578

    Hugging Face sign-in on a Space works without a client secret

    PKCE always on Spaces with a secret keep working
  15. Session cookies are now signed with a key the Hub sets for each Space. That key changed in this release, so everyone signs in once more when the Space upgrades. From then on, sessions survive restarts and carry across replicas.

    Slide text
    huggingface_hub v2.5.0
    01 02 03 04 Spaces and inference
    huggingface/huggingface_hub · GitHub release v2.5.0 · #4578

    Users of an OAuth Space will sign in again after it upgrades

    After that, sessions survive restarts and carry across replicas

  16. Chat completion with a Hugging Face token and a named provider now takes the same path as auto calls. If that provider is down or rate limited, the router fails over to another one. Calls made with the provider's own key are unchanged.

    Slide text
    huggingface_hub v2.5.0
    01 02 03 04 Spaces and inference
    huggingface/huggingface_hub · GitHub release v2.5.0 · #5333

    Chat calls to a named provider now go through the Hub router

    Down or rate limited? The router fails over. Calls with a provider’s own key are unchanged.

  17. Downloads running in parallel into the same local folder now work. Reaching your egress limit raises a dedicated egress limit error. And uv jobs with long script arguments stop crashing.

    Slide text
    huggingface_hub v2.5.0
    01 02 03 04 Spaces and inference
    huggingface/huggingface_hub · GitHub release v2.5.0 · #5353 · #5434 · #5424

    Three fixes you may have hit

    Parallel downloads into one local_dir now work
    Hitting your egress limit raises its own EgressLimitError
    run_uv_job with long script arguments no longer crashes
  18. I would say yes, upgrade, if you share tokens, run agents in sandboxes, or write checkpoints to buckets. Locked-down pools need this version on every pool host. Every fix is listed in the release notes on GitHub.

    Slide text
    huggingface_hub v2.5.0
    01 02 03 04 Spaces and inference
    huggingface/huggingface_hub · GitHub release v2.5.0

    Upgrade if you hand out tokens, run agents in sandboxes, or save to buckets

    Every change and fix, in the v2.5.0 release notes:
    https://github.com/huggingface/huggingface_hub/releases/tag/v2.5.0

What happened in AI today, in your inbox

One short email each evening. Read it and you’re caught up.

Built with ❤️ in New York