Repository navigation
Studio: refuse a chained dataset media path whose first hop is not an archive - #14529
Conversation
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. |
|
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. |
…s drives [skip ci]
|
@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: 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".
| _READ_THROUGH_PROTOCOLS = frozenset( | ||
| {"zip", "tar", "gzip", "bz2", "xz", "lz4", "zstd", "simplecache", "filecache", "blockcache"} | ||
| ) |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
@codex review |
3 similar comments
|
@codex review |
|
@codex review |
|
@codex review |
There was a problem hiding this comment.
💡 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".
| _READ_THROUGH_PROTOCOLS = frozenset( | ||
| {"zip", "tar", "gzip", "bz2", "xz", "lz4", "zstd", "simplecache", "filecache", "blockcache"} | ||
| ) |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
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.
|
pre-commit.ci run |
… 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>
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 forzip://inner::<outer>). But only archive, compression and cache filesystems read through to the next hop: forfile://<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 relativefile://path to another account's folder).Change.
_permitted_tokensrefuses a chained path when any hop before the last is not one ofzip,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.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.file://<x>::hf://...reads<x>;zip://in.txt::<zip>reads the member.