fix: pass HF token via git credential helper instead of embedding in remote URLs
#1
by GuillaumeSalouHF HF Staff - opened
worker.py embedded the user HF token directly in the clone/push remote URLs (https://hf_user:@huggingface.co/...), exposing it in the Job process command line, the temp .git/config, and any git output echoed into the Job logs (which the Space tails and shows in the UI).
Replace URL-embedded credentials with a git credential helper that reads the token from HF_TOKEN in the environment at request time. The token never appears on a command line or in a config file; only the helper script (referencing $HF_TOKEN) is stored. The helper is set globally before any git op so it covers ls-remote, fetch, LFS and push. The Job container is single-tenant and ephemeral.
No functional change to what gets copied or how.
Test plan:
- Copy a model repo with LFS objects: confirm branches, tags, LFS land at destination
- Copy a xet-backed repo: confirm xet push path still authenticates (this is the path to verify before merging)
- Inspect the running Job: confirm token no longer in ps / proc cmdline / Job logs
- Bucket copy still works (unchanged path)
Thanks Guillaume
alexpouliquen changed pull request status to merged