Skip to content

fix(web): do not attach ambient HF token on public generate - #134

Open
drk-ram wants to merge 1 commit into
GenAI-Security-Project:mainfrom
drk-ram:fix/web-disable-implicit-hub-token
Open

drk-ram wants to merge 1 commit into
GenAI-Security-Project:mainfrom
drk-ram:fix/web-disable-implicit-hub-token

Conversation

@drk-ram

@drk-ram drk-ram commented Nov 6, 2026

Copy link
Copy Markdown

Fixes #133

Summary

Public /generate constructed HfApi() and AIBOMService() with the default token. huggingface_hub treats token=None as "send the ambient HF_TOKEN or cached login". The web process uses that token for usage logging, so a visitor could cause private-model reads and then download the resulting BOM from /output.

Generation now passes token=False through the existence check, model-card load, hf_hub_download, and file extractors. The CLI still uses the implicit operator token.

Tests

.\.venv\Scripts\python.exe -m pytest tests/test_hub_token_isolation.py tests/test_web_controller.py -q --tb=short -p no:cacheprovider --no-cov

Result: 5 passed.

.\.venv\Scripts\python.exe -m pytest -q --tb=line -p no:cacheprovider --no-cov

Result: passed (full suite, no failures).

Visitor generation now calls the Hub with token=False so an operator HF_TOKEN cannot be used to read private models. Fixes GenAI-Security-Project#133.

Signed-off-by: Raghuvar Karthik Durga <177662415+drk-ram@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.

Public /generate attaches the operator HF_TOKEN and can publish private-model BOMs

1 participant