security: replace hardcoded Hugging Face token with env var in moondream2 config#157
Closed
security: replace hardcoded Hugging Face token with env var in moondream2 config#157
Conversation
Agent-Logs-Url: https://github.com/Clarifai/examples/sessions/6bc7b815-d5ef-49cd-b102-f84224d19b4f Co-authored-by: sanjaychelliah <65780631+sanjaychelliah@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Remove hardcoded Hugging Face token for security compliance
security: replace hardcoded Hugging Face token with env var in moondream2 config
May 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plaintext Hugging Face token was committed in the moondream2-VLM
config.yaml. The exposed token should be considered compromised and revoked immediately.Changes
models/model_upload/multimodal_models/moondream2-VLM/config.yamlhf_tokenvalue with${HF_TOKEN}environment variable referenceRequired follow-up
HF_TOKENvia your runtime secret manager / CI environment — do not store it in the repogit filter-repo/ BFG to purge the token from commit history if this branch is ever merged to a shared refOriginal prompt
Remove the hardcoded Hugging Face token from
models/model_upload/multimodal_models/moondream2-VLM/config.yamlinClarifai/examples.Current issue:
checkpoints.hf_token.Required changes:
models/model_upload/multimodal_models/moondream2-VLM/config.yamlto replace the hardcoded token value with an environment variable reference:hf_token: "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"hf_token: "${HF_TOKEN}"Acceptance criteria:
${HF_TOKEN}for runtime secret injection.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: on which branch is this file is present
Assistant: That file snapshot is from a commit SHA (
d6e2a999ed6de61e0ec2268181cdaef69d7d0336), not directly from a branch name.To find which branch(es) contain it, I need to check the repo refs for that commit. Based on typical usage in
Clarifai/examples, this commit is most likely on the default branch (oftenmain), but the exact answer requires querying GitHub refs for that SHA.User: then how can I edit this file?
Assistant: You can’t edit a file at a commit SHA URL directly (that snapshot is immutable).
Do this instead:
main):https://github.com/Clarifai/examples/blob/main/models/model_upload/multimodal_models/moondream2-VLM/config.yamlIf you only have the SHA URL, switch
.../blob/d6e2a999.../to.../blob/main/(or another branch name).Also: that file currently shows a real Hugging Face token (
hf_...) in your snippet. You should treat it as compromised, rotate/revoke it, and replace it with a secret reference/env var.User: There is a security issue due to the hf token present here, how could I resolve it?
Assistant: Revoke/rotate the exposed token immediately, then remove it from code and history.
Immediate fix
main) and remove:hf_token: "hf_..."hf_token: "${HF_TOKEN}"(or remove the field if your loader injects auth automatically)..gitignore/ secret handling so tokens never enter git again.Strongly recommended follow-up
git filter-repoor BFG, then force-push.Safe replacement example
If you want, I can provide exact step-by-step commands for:
User: PR only remediation
Assistant: Great—PR-only remediation (no history rewrite) is:
Use this exact change in
Clarifai/examples:Git commands (PR flow)
Then open PR with:
security: remove hardcoded Hugging Face token from moondream2 confighf_tokenfrom tracked config${HF_TOKEN})After PR merges
HF_TOKENin your deployment/runtime secret manager (not in repo).This pull request was created from Copilot chat.