Repository navigation
fix: keep HF_TOKEN out of vllm argv and mask secret flags in launch log - #350
Conversation
The generic env scan turned HF_TOKEN into --hf-token <value>, and main.py logged the full argv at INFO, printing the token into worker logs and exposing it in process listings. - Reserve HF_TOKEN in the generic scan; vLLM's --hf-token default falls back to huggingface_hub's HF_TOKEN lookup in the inherited environment. - Log redact_argv(argv): values of flags whose last word is token/key/secret/ password are masked, in both '--flag v' and '--flag=v' forms (the latter can still arrive via VLLM_EXTRA_ARGS). - Tests cover the redactor, look-alike flags (--tokenizer, --ssl-keyfile), and start_vllm's log line, argv, and child env. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kenlim-mops
left a comment
There was a problem hiding this comment.
Correct security fix. Adding HF_TOKEN to RESERVED_ENV_VARS is the right layer: vLLM's --hf-token already defaults to huggingface_hub's own env lookup, so the child process gets the token through the inherited env without it ever appearing on the command line or in ps output. redact_argv matching on the last dash-separated word of the flag name (not a substring) correctly excludes --tokenizer, --max-num-batched-tokens, and --ssl-keyfile while catching --hf-token, --api-key, and both space-separated and = forms. The test with Popen mocked verifies end-to-end: log line clean, argv has no --hf-token from env, child env carries HF_TOKEN. Note: 'dev' build workflow shows QUEUED (non-blocking); all test/CodeQL checks passed.
Problem
args_builder's generic env scan mapsHF_TOKENto--hf-token <value>, andmain.start_vllmlogs the full argv at INFO (Starting vLLM: vllm serve ... --hf-token hf_...). The Hugging Face token ends up in plain text in serverless worker logs, and it is visible to anything that can list processes in the container. vLLM's own "non-default args" line already masks it; only the wrapper's line leaks.Fix
HF_TOKENis now inRESERVED_ENV_VARS, so it is never emitted as--hf-token. vLLM's--hf-tokendefaults to huggingface_hub's own token lookup, which readsHF_TOKENfrom the environment the child already inherits (env = {**os.environ, ...}). Gated models keep working with no config change.redact_argv(argv), which masks the value of any flag whose last dash-separated word istoken,key,secretorpassword. It handles both--flag valueand--flag=value, sinceVLLM_EXTRA_ARGScan still pass either form. Matching the last word rather than a substring keeps--tokenizer,--max-num-batched-tokensand--ssl-keyfile(a path) readable in the log.HF_TOKENrow indocs/configuration.md, plus a runtime-secrets note indocs/conventions.md.Tests
tests/test_secret_redaction.pycovers the redactor, the look-alike flags, andstart_vllmend to end withPopenmocked: the log line contains neither secret, argv has no--hf-tokenfromHF_TOKEN, and the child env still carriesHF_TOKEN. Full suite: 122 passed locally.Follow-up for operators
Any token already printed by an affected image should be treated as exposed and rotated.
🤖 Generated with Claude Code