fix(security): Check ownership of the HuggingFace hub cache before reuse
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 45/100
調査の方向性
Start with src/downloader/store.rs functions hf_hub_cache_dir() and hf_cache_snapshot(), then read the PTX cache trust rules in src/lib/mlxcelverse/overlays/cuda/mlx/backend/cuda/ptx_cache_trust.h. Trace the cache lookup through src/downloader/resolver.rs and src/downloader/mod.rs; add tests in resolver_tests.rs and store.rs for unsafe and user-owned caches. Done means unsafe snapshots fall through to the store, trusted caches still resolve, and both Docker documentation files are updated.
索引モデルが issue の本文から書いたものです。
説明
Problem
The model resolver trusts any complete HuggingFace hub snapshot without checking who owns it. In the CUDA image HOME=/cache (docker/Dockerfile.cuda:298, :320), so the hub cache is /cache/.cache/huggingface/hub, which is also the PTX kernel cache trusted root (MLXCEL_CACHE_TRUSTED_ROOT=/cache, :303). Anyone who can write /cache (another host account in gid 65532 on a 2775 bind mount, or any account on a 0777 one) can plant a snapshot that mlxcel-server -m owner/name loads instead of the model in /models. Plain docker run is affected; the Helm chart is not, since it sets HF_HOME=/models/.huggingface (charts/mlxcel/templates/_helpers.tpl:126-140). docs/docker.md:123 documents the risk and workaround.
Current Behavior
hf_hub_cache_dir()(src/downloader/store.rs:210-217) resolvesHF_HUB_CACHE, thenHF_HOME/hub, then$HOME/.cache/huggingface/hub;hf_cache_snapshot()(:249) returns the snapshot after a completeness check only.locate_cached_snapshotprobes it at step 2b (src/downloader/resolver.rs:487), before the store at 2c (:497); alsolocate_landed_snapshot(:532) and the download short-circuit (src/downloader/mod.rs:1571).
Proposed Solution
Gate hf_cache_snapshot() itself on an ownership check of the hub path, so every caller inherits it. Port the walk rules of the PTX cache trust (#3509, #3530) from src/lib/mlxcelverse/overlays/cuda/mlx/backend/cuda/ptx_cache_trust.h:24-40 to Rust: every canonical component of the snapshot path and of the repo blobs/ dir its files link into is owned by euid or root and not group/other writable, except root-owned sticky dirs. Do not apply the private-egid exception (src/lib/mlxcel-core/src/private_group.rs:210): inside the container /etc/group cannot see host members of gid 65532, so it would accept the 2775 mount; a umask-002 Linux home therefore skips HF reuse with the warning. An untrusted cache is skipped with one warning naming the offending component, and resolution falls through to the store. Optionally also move the image's default HF_HOME under /models/.huggingface. Unix only; Windows unchanged.
Acceptance Criteria
- Test written first, failing on current code: a complete snapshot in a group- or other-writable hub cache is not returned by
locate_cached_snapshot, and a store copy is used instead - A user-owned
0755hub cache (macOS default~/.cache/huggingface/hub) still resolves; existingresolver_tests.rsandstore.rsHF tests pass -
docs/docker.mdanddocs/docker.ko.mdsection at line 123 updated, warning dropped - Integrated into the real resolution path, not a standalone helper
Verification
cargo test --release downloader::
cargo clippy --all-targets -- -D warnings
cargo fmt --check
- 主要言語
- Rust
- スター
- 505
- フォーク
- 81
- 平均マージ
- 14時間 2分
- マージ済み PR(30日)
- 448
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
lablup/mlxcel のほかの issue
-
area:core priority:high status:ready type:security
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
area:models modeltype:text priority:medium status:in-progress type:bug
難易度 4/5 3〜5日 初心者へのやさしさ 57/100
メンテナーはふだん 1 日以内に返信
-
area:models priority:low status:ready type:test
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
area:models modeltype:omni priority:medium status:ready type:bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 1 日以内に返信
-
area:models platform:linux priority:medium status:ready type:bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
メンテナーはふだん 1 日以内に返信
似ている issue
-
psmux-resurrect: restoring a session with a numeric name puts its windows into the wrong session (`new-window -t 4` is read as window 4)対応中かも @ealwanlee が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
psmux/psmux-plugins#47 ·
-
Link Checker Reportオープンautomated issue report
難易度 1/5 1時間未満 初心者へのやさしさ 76/100
ratatui/awesome-ratatui#598 ·
メンテナーはふだん 1 日以内に返信
-
release
難易度 1/5 1時間未満 初心者へのやさしさ 75/100
github/gh-aw-mcpg#17603 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
C-Bug S-Needs-Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
bevyengine/bevy#26718 ·
メンテナーはふだん 2 日以内に返信