Repository navigation
Studio: dataset image guard keeps owner flows working (opt-in, WSL paths, unencoded spaces) - #14966
Conversation
…ths, unencoded spaces) UNSLOTH_ALLOW_PRIVATE_URL_FETCH=1, the opt-in unsloth_zoo already honours, lets an owner load images from their own LAN host, share or non-Hub archive the way datasets loads them; refusals name it. WSL paths and non-Windows // paths are no longer treated as network shares, and a raw space in an image URL is percent-encoded before the guard.
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. |
…ly path and query The opt-in is ignored once managed accounts exist, so their rows cannot reach the LAN. With it on, columns are still probed so a broken column loses to a working one; fsspec no longer expands URL globs; the host is left unencoded so IDNA still applies; and only a private-destination refusal suggests the opt-in. [skip ci]
|
@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: 3b777e8fc9
ℹ️ 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".
| if not p.upper().startswith("UNC/"): | ||
| return False | ||
| p = "//" + p[4:] | ||
| return p.startswith("//") and p[2:].split("/", 1)[0].lower() not in _LOCAL_SHARE_HOSTS |
There was a problem hiding this comment.
Keep WSL UNC paths guarded for managed accounts
On Windows multi-user installations, this excludes wsl$ and wsl.localhost for every caller, including managed accounts. The non-HTTP candidate probe in format_detection.py then calls os.path.exists(sample_value) before require_readable_media runs, so a managed user can submit multiple image-like columns containing \\wsl$\Distro\... paths and make Studio probe files in the owner's WSL filesystem. Make the WSL exemption owner-sensitive or apply the account media check before probing.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
The probe only answers whether a path exists, and it already does that for any local path a managed account names, such as C:\Users\owner\... or /home/owner/...; that is unchanged by this PR. A \\wsl$\Distro\... path is the owner's local WSL filesystem, not a remote host, so it is treated like any other local path. Reading it still goes through require_readable_media, which refuses a managed account a path outside its own roots, so no file contents are exposed. Keeping this as is.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6f4566bd09
ℹ️ 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".
| ): | ||
| path = value.get("path") if isinstance(value, dict) else None | ||
| if isinstance(path, str) and value.get("bytes") is None: | ||
| if isinstance(path, str) and value.get("bytes") is None and not private_sources_allowed(): |
There was a problem hiding this comment.
Preserve the size cap for typed image cells
When UNSLOTH_ALLOW_PRIVATE_URL_FETCH=1, a bytes-less datasets.Image cell skips this block entirely, so the original datasets/fsspec decoder can fetch and decode a remote image larger than _MAX_IMAGE_BYTES. The new bounded fetch_opted_in_image_bytes path only fixes plain string rows; typed, nested, and streaming image features still bypass the 64 MB limit and can exhaust memory on a large endpoint.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
With the opt-in on, a typed datasets.Image cell is decoded by datasets itself, exactly as it is for every stock datasets user and as Studio did before #14701; that path also carries the Hub token handling and archive chains, which a Studio reimplementation would have to duplicate. The opt-in exists to give the owner that stock behaviour back for sources they trust, so I am keeping it. String rows are Studio's own fetch, so they keep Studio's cap and timeout.
…image timeout and deadline
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d3c7654b89
ℹ️ 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".
|
|
||
| deadline = time.monotonic() + _IMAGE_TIMEOUT_S * 2 | ||
| chunks, total = [], 0 | ||
| with open_opted_in_url(url) as response: |
There was a problem hiding this comment.
Apply the deadline while opening opted-in URLs
When the opt-in is enabled and a row points to a slow or malicious HTTP server, the deadline is not checked until open_opted_in_url has completed connection setup, redirects, and response-header reads. Its 30-second urllib timeout is a per-blocking-operation timeout rather than a total request budget, so a server that drip-feeds headers or a redirect chain can occupy each conversion/probe worker far beyond the intended 60-second deadline. Pass the remaining deadline through the opening and redirect path, rather than enforcing it only once body reads begin.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Keeping this as is. The opt-in is only for hosts the owner has chosen to trust on a single-user install, and every blocking step there (connect, each header read, each redirect hop, each body read) is still bounded by the 30 s timeout, while the overall deadline stops a slow body. A trusted server deliberately drip-feeding headers is outside what the opt-in is for; untrusted rows never take this path and keep the guarded fetch with its full deadline.
Summary
#14701 routes dataset image URLs through the SSRF guard, so an untrusted dataset cannot make Studio fetch loopback, LAN or metadata addresses. A recheck of the user flows found that it also blocked things owners do on purpose, with no way back:
zip://img.png::https://images.example.org/images.zip\\wsl$\...and\\wsl.localhost\...paths (the user's own WSL distro), and//-prefixed paths on Linux and macOS, which are ordinary local paths therehttps://host/my images/a b.png), which the web tool's URL check rejects but fsspec used to quoteChanges
utils/datasets/remote_images.py:UNSLOTH_ALLOW_PRIVATE_URL_FETCH=1, the opt-inunsloth_zooalready honours for media URLs, turns the image guard off on a single-user install: image cells and string URLs load the waydatasetsand fsspec loaded them before Studio: fetch VLM dataset row image URLs through the SSRF-guarded fetch #14701. Once managed accounts exist it is ignored, so a row a managed account supplies cannot reach the owner's LAN; an unreadable account store keeps the guard on. It is read on every call, so it takes effect without a restart.is_network_shareonly applies on Windows, and treatswsl$andwsl.localhostas localguard_urlpercent-encodes a raw space (and other characters a browser would) in the path, query and fragment before the guard; the host is left alone so an internationalized name still goes through IDNA, and an already-encoded URL is unchangedformat_conversion.pyandformat_detection.pyuse the same opt-in, share rule and quoting for string rows and the column probe. With the opt-in on, a URL column is still probed (a plain HEAD request), so a broken column loses to a working one. The probe and the string-row fetch share one smallurllibhelper that quotes the URL and IDNA-encodes an internationalized host, and the row fetch keeps the guarded fetch's limits: the 64 MB image cap (a declared size over it is refused, and the read stops at the cap when no size is sent), the 30 s timeout and the 60 s overall deadline. TypedImage()cells are decoded bydatasetsitself, as they are without Studio.The default for everyone else is unchanged: public addresses only, every redirect re-checked, size capped.
Tests
tests/test_vlm_conversion_row_urls.py:\\?\C:\paths reachdatasetson Windows, and//data/...reaches it off WindowsImage()cells, and a non-Hub archive chain reachesdatasetsThe new cases fail on
mainand pass here. The VLM conversion and probe suites give 55 passed (52 on the windows-latest, ubuntu-latest and macos-15 runners before the size-cap commit), and the 14 test files that import the changed modules give 1275 passed. The one failure there,test_csv_cells_as_written.py::test_csv_files_missing_a_column_still_load_together, also fails onmain.