Skip to content

Security: Environment variable token fallback in request resolution#264

Open
tuanaiseo wants to merge 1 commit into
huggingface:mainfrom
tuanaiseo:contribai/fix/security/environment-variable-token-fallback-in-r
Open

Security: Environment variable token fallback in request resolution#264
tuanaiseo wants to merge 1 commit into
huggingface:mainfrom
tuanaiseo:contribai/fix/security/environment-variable-token-fallback-in-r

Conversation

@tuanaiseo
Copy link
Copy Markdown

Problem

In agent/core/hf_tokens.py, the resolve_hf_request_token function has include_env_fallback=True by default. This means server-side HF_TOKEN environment variable can be used as a fallback when no user token is provided. If HF_TOKEN is set to a production token, it could be inadvertently used in contexts where only user tokens should apply.

Severity: medium
File: agent/core/hf_tokens.py

Solution

Review the include_env_fallback usage and ensure production deployments don't have HF_TOKEN set when user-specific tokens are required. Consider making this opt-in rather than default behavior.

Changes

  • agent/core/hf_tokens.py (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

In agent/core/hf_tokens.py, the resolve_hf_request_token function has include_env_fallback=True by default. This means server-side HF_TOKEN environment variable can be used as a fallback when no user token is provided. If HF_TOKEN is set to a production token, it could be inadvertently used in contexts where only user tokens should apply.

Affected files: hf_tokens.py

Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant