Skip to content

Studio: refuse a chained dataset media path whose first hop is not an archive - #14529

Merged
danielhanchen merged 6 commits into
mainfrom
studio-dataset-media-chained-hops
Oct 23, 2026
Merged

danielhanchen merged 6 commits into
mainfrom
studio-dataset-media-chained-hops

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Follow-up to #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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T15:49:42.042082Z f92cb3e Manual request
🔒 Security Review ✅ Completed 2026-10-22T14:09:36.137776Z f92cb3e Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins.

@danielhanchen danielhanchen added important# security# Moves a security boundary: sandbox, allowlist, permission or network guard labels Oct 22, 2026
@danielhanchen danielhanchen self-assigned this Oct 22, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: f92cb3e7eb

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f92cb3e7eb

ℹ️ 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".

Comment on lines +105 to +107
_READ_THROUGH_PROTOCOLS = frozenset(
{"zip", "tar", "gzip", "bz2", "xz", "lz4", "zstd", "simplecache", "filecache", "blockcache"}
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include fsspec's cached read-through protocol

For managed accounts, a valid path such as cached::/account/dataset/image.png is now rejected even though fsspec registers cached as the same CachingFileSystem used by the allowlisted blockcache protocol and reads through to the final path. Since datasets.xopen supports this standard chained URL, omitting cached from this set breaks media decoding for datasets that use that cache alias; add it alongside the other cache wrappers.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing this. A cache hop over a local file does not decode in the dataset preview on either side: with simplecache::file://<own png> (already in the allowed set) and cached::file://<own png>, both main (acc10af) and this branch fail the same way, FileNotFoundError on the full chained string, before this guard is involved. Adding cached would not make any cell preview that fails today.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

3 similar comments
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f92cb3e7eb

ℹ️ 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".

Comment on lines +105 to +107
_READ_THROUGH_PROTOCOLS = frozenset(
{"zip", "tar", "gzip", "bz2", "xz", "lz4", "zstd", "simplecache", "filecache", "blockcache"}
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Permit libarchive read-through chains

When the optional libarchive-c backend is installed, fsspec supports libarchive://member::<archive> through LibArchiveFileSystem, which opens the final fo target just like the allowlisted zip and tar filesystems. Because libarchive is omitted here, managed accounts now reject members of even an archive inside their own workspace before the decoder runs; include this archive protocol in the read-through set.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not changing this. libarchive-c is not a Studio dependency and is absent from the Studio install environment (import libarchive raises ModuleNotFoundError), so a libarchive:// cell cannot decode for anyone today, owner included. If the backend is ever shipped, the protocol can be added alongside it.

@danielhanchen

Copy link
Copy Markdown
Member Author

pre-commit.ci run

@danielhanchen
danielhanchen merged commit 5914b64 into main Oct 23, 2026
2 of 36 checks passed
@danielhanchen
danielhanchen deleted the studio-dataset-media-chained-hops branch October 23, 2026 03:40
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Oct 23, 2026
… archive members (unslothai#14840)

The managed-account media guard in
`studio/backend/utils/security/dataset_media.py` had two gaps.

1. A media cell was treated as a Hub file when `datasets`'
`string_to_dict` matched it. That helper searches anywhere in the
string, so a URL on a different host that contains a Hub-style path was
accepted and then opened as written. The guard now matches the whole URL
against the `hf://datasets/...` or configured endpoint pattern, checks
the repo it derives is the one the decoder keys its token on, and, as on
main since unslothai#14529, only allows archive, compression and cache protocols
as chained hops.
2. Any file under the shared `datasets` extraction cache was readable by
every managed account, regardless of whose archive it came from.
Extractions now record their source archive (in process and in a small
file beside the extraction, both verified against the hash `datasets`
names the directory with), and a member is readable only when the
account may read the source archive. Extractions with no record are
refused for managed accounts.

The owner's decoding is unchanged. Tests cover both cases plus the
legitimate paths (own archive, Hub archive member with the caller's
token), on datasets 3.6.0, 4.8.5 and 5.1.0.

Archives extracted before this change have no record, so managed
accounts are refused for those members until the archive is extracted
again (owner unaffected). Not run: a full Studio training run and
Windows paths.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

important# security# Moves a security boundary: sandbox, allowlist, permission or network guard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant