Repository navigation
Studio: managed dataset media decodes stay on readable files, and Arrow data files are validated - #14430
Conversation
…date Arrow data files Dataset Image/Audio/Video/Pdf/Nifti cells that carry only a path are decoded in the backend and training workers. For a managed account, a local path must now be one the account may read (its own roots, a Hub snapshot it can see, its training dataset's snapshot, or an archive datasets extracted), a Hub URL is fetched only with the caller's token for that repo or anonymously, and other URLs are refused. String image paths in the VLM converters get the same check. The owner is unchanged. The arrow builder now validates each table in full before casting, so a malformed .arrow data file is a 400 instead of a read past its buffers. The guard installs once next to the Hub card guard (API process, training, token preview and recipe workers) and composes with the soundfile audio decoder.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
@codex review |
|
@codex security review |
|
@codex review |
🛡️ Codex Security ReviewSecurity review completed. No security issues were found in this pull request. Reviewed commit: Only the user who started this review can view the report in Codex. ℹ️ About Codex security reviews in GitHubThis is an experimental Codex feature. Security reviews are triggered when:
Once complete, Codex will leave suggestions, or a comment if no findings are found. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0dd2179bbf
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| root = os.path.realpath(str(config.EXTRACTED_DATASETS_PATH)) | ||
| return os.path.realpath(path).startswith(root.rstrip(os.sep) + os.sep) |
There was a problem hiding this comment.
Restrict extracted media to the current account
In a multi-user installation, datasets.config.EXTRACTED_DATASETS_PATH is an installation-wide cache, so this condition trusts every extracted file regardless of which account or dataset produced it. A managed user who submits a media cell naming a path in another user's extracted archive bypasses visible_cached_path and can have that file decoded and returned; associate extracted paths with an authorized dataset/account rather than blanket-allowing the entire shared extraction root.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not reachable in practice: datasets names each extraction folder hash_url_to_filename(), so naming another account's extracted file needs that account's exact archive path and the member name, and the extraction root cannot be listed by a managed account. Allowing the root keeps zip-packed image datasets trainable; scoping it per account would need the extraction map plumbed through datasets.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
… archive (unslothai#14529) Follow-up to unslothai#14430. **Problem.** For a managed account, the dataset media guard checks the location a media cell reads from. For a chained fsspec URL it took the last `::` hop as that location (right for `zip://inner::<outer>`). But only archive, compression and cache filesystems read through to the next hop: for `file://<path>::hf://datasets/a/b@main/c.png`, fsspec opens `<path>` and ignores the Hub URL. A Parquet dataset with such an image cell therefore passed the check on the Hub URL, and its preview returned an image from outside the account (a relative `file://` path to another account's folder). **Change.** `_permitted_tokens` refuses a chained path when any hop before the last is not one of `zip`, `tar`, `gzip`, `bz2`, `xz`, `lz4`, `zstd`, `simplecache`, `filecache`, `blockcache`. The last hop is checked exactly as before. Owner accounts never reach this guard, so their datasets are unchanged, and ordinary managed-account datasets (embedded bytes, files in their own workspace, Hub files, zip members) preview as before. **Testing.** - `test_dataset_media_decode_guard.py`: 16 passed. The new chained-path test returns the other account's image on main and is refused here; a zip member of the account's own archive previews on both. - Neighbouring dataset suites (`test_arrow_validation.py`, `test_training_worker_import_discipline.py`, `test_audio_decode_load_order.py`, `test_dataset_image_lists.py`, `test_vlm_repo_relative_image_paths.py`, `test_vlm_text_only_rows.py`, `test_data_recipe_preview_image_paths.py`): 54 passed, 8 skipped. - fsspec 2025.3.0 directly: `file://<x>::hf://...` reads `<x>`; `zip://in.txt::<zip>` reads the member. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Hardening from a security review of dataset preview, check-format and training on multi-account installs. Nothing changes for the owner, Desktop or notebooks, apart from malformed
.arrowfiles (all accounts), which now get a 400 instead of being read.Problem.
datasetsdecodes media columns lazily. An Image / Audio / Video cell that carries apathand no bytes is opened when previewed, checked or trained on, in the backend or the training worker, as the Studio user:hf://or<endpoint>/datasets/<repo>/resolve/...path for a repo other than the dataset's own is fetched with the server's ambientHF_TOKEN, sincetoken_per_repo_idhas no entry for it;So a managed account could upload a small parquet file whose cells name host images or another account's private Hub files and read them back through the preview. The VLM converters in
format_conversion.pylikewiseImage.openplain string paths without an account check. Separately,.arrowfiles a user supplies are streamed throughdatasets' Arrow loader without validation, so a crafted IPC file can make pyarrow read past its buffers.Change.
utils/security/dataset_media.py, an install-once guard (same pattern and idempotent mark ashub_data_files.py), installed in the backend, training worker, token preview worker and recipe worker. For a managed account, a media cell with a path and no bytes is decoded only when:visible_cached_path), its training job's own dataset snapshot, or underdatasets' own extraction folder (zip-packed image datasets keep working);PermissionError, which check-format reports as a 400).The owner gets exactly the original call.
audio_decode.py's soundfile fallback is installed with the guard around it.format_conversion.py: the three VLM converters check local image path strings withaccount_pathfor managed accounts (the account is captured when the converter starts, since URL loading runs in a thread pool).datasets' Arrow loader runsTable.validate(full=True)on user Arrow files before casting. Datasets' own cache files do not go through that loader.Tests. New
test_dataset_media_decode_guard.pyandtest_arrow_validation.py: 10 fail on main (a managed Image cell pointing outside the workspace previews the file; another repo'shf://cell is fetched with the server token;http://127.0.0.1, revision-lesshf://ands3://cells are fetched; VLM string paths outside the account open; a crafted Arrow file returns over-read memory), all 18 pass here, including the controls (embedded image, own-workspace image, owner unchanged, own repo keeps its token, intact Arrow file, install twice). 154 related backend modules show the same failing IDs on both sides.Left open on purpose: the unsloth-zoo vision collator, which opens string image paths in rows already in
messagesform.