fix(security): pin HF model revision, cap JSONL line size, confine adapter reads to source root#110
Open
jugrajsingh wants to merge 3 commits into
Open
fix(security): pin HF model revision, cap JSONL line size, confine adapter reads to source root#110jugrajsingh wants to merge 3 commits into
jugrajsingh wants to merge 3 commits into
Conversation
hf_hub::Repo::with_revision downloaded intfloat/multilingual-e5-small off the mutable "main" branch, so a compromised upstream push could silently swap the weights we load. Pin to the current main HEAD commit (614241f622f53c4eeff9890bdc4f31cfecc418b3, verified to still serve config.json/tokenizer.json/model.safetensors) via a named MODEL_REVISION const.
Add paths::confined_path(root, candidate), which canonicalizes both the source root and a discovered/derived candidate path and rejects any candidate that escapes the root after following symlinks. Apply it as a skip-with-warn guard at every site where an adapter opens a file for indexing: the collect_* entry builders for claude_code, copilot, cline, grok, antigravity, codex, and pi, plus the direct walk+parse paths in cursor (agent transcripts) and gemini. A symlinked *.jsonl/*.json planted inside a tool's session directory, or a session dir whose transcript points outside the root, previously had its contents read verbatim into the searchable index. Such files are now skipped with a tracing::warn! while the rest of the scan continues, per the adapter contract. Sibling metadata reads that yield only directory strings are unchanged.
jugrajsingh
force-pushed
the
fix/security-hardening
branch
from
July 21, 2026 07:30
17ff1a1 to
f2c446d
Compare
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.
Summary
Three independent supply-chain / hostile-input hardening fixes, bundled because they touch the same adapter surface and are small individually:
hf_hub::Repo::with_revisiondownloadedintfloat/multilingual-e5-smalloff the mutablemainbranch, so a compromised upstream push could silently swap the weights we load and embed. Pinned to the currentmainHEAD commit (614241f622f53c4eeff9890bdc4f31cfecc418b3, verified to still serveconfig.json/tokenizer.json/model.safetensors) via a namedMODEL_REVISIONconst.json_util.paths::confined_path(root, candidate)canonicalizes both the source root and a discovered/derived candidate path and rejects anything that escapes the root after following symlinks. Applied at every adapter file-open site (claude_code,copilot,cline,grok,antigravity,codex,pi, plus the direct walk+parse paths incursorandgemini). A symlinked*.jsonl/*.jsonplanted inside a tool's session directory, or a session dir whose transcript points outside the root, is now skipped withtracing::warn!rather than read verbatim into the searchable index; the rest of the scan continues. Root canonicalization is applied to both sides of the check so a symlinked dotfile root (e.g.~/.claude-> elsewhere) still resolves correctly instead of false-rejecting everything under it.All three are warn-and-skip, not hard failures — a single bad file degrades gracefully rather than aborting the sync.
Verification
cargo build,cargo fmt -- --check,cargo test --workspace— green.Test plan
main