Skip to content

Studio: dataset image guard keeps owner flows working (opt-in, WSL paths, unencoded spaces) - #14966

Merged
danielhanchen merged 6 commits into
mainfrom
studio-image-guard-owner-flows
Oct 23, 2026
Merged

danielhanchen merged 6 commits into
mainfrom
studio-image-guard-owner-flows

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

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:

  • images served from the owner's own LAN or loopback server (a NAS, MinIO, a local file server)
  • images on a Windows share the owner uses
  • chained cells into a public non-Hub archive, such as 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 there
  • image URLs with a raw space (https://host/my images/a b.png), which the web tool's URL check rejects but fsspec used to quote

Changes

utils/datasets/remote_images.py:

  • UNSLOTH_ALLOW_PRIVATE_URL_FETCH=1, the opt-in unsloth_zoo already honours for media URLs, turns the image guard off on a single-user install: image cells and string URLs load the way datasets and 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.
  • a refusal of a private or local destination, a share or a non-Hub archive names that variable; a 404, timeout or size refusal is reported as is
  • is_network_share only applies on Windows, and treats wsl$ and wsl.localhost as local
  • guard_url percent-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 unchanged

format_conversion.py and format_detection.py use 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 small urllib helper 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. Typed Image() cells are decoded by datasets itself, 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:

  • WSL and \\?\C:\ paths reach datasets on Windows, and //data/... reaches it off Windows
  • refusals name the opt-in
  • with the opt-in on a single-user install, a loopback image server works for string rows and typed Image() cells, and a non-Hub archive chain reaches datasets
  • with managed accounts the opt-in is ignored and a loopback image is refused
  • only a private-destination refusal suggests the opt-in
  • with the opt-in, a 404 column loses to a working column
  • an internationalized host is not percent-encoded
  • a raw space in an image URL reaches the guard percent-encoded
  • with the opt-in, an image over the size cap is refused, with and without a declared size
  • opted-in requests are quoted, IDNA-encoded and carry the image timeout
  • the existing share-refusal tests pin Windows mode, so they still check the Windows rule on Linux CI

The new cases fail on main and 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 on main.

…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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 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-23T11:57:42.254974Z d3c7654 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[bot]

This comment was marked as resolved.

…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]
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@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: 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

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 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 👍 / 👎.

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.

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.

@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: 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():

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 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 👍 / 👎.

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.

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.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 23, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 23, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 23, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 23, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 23, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 23, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 23, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 23, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 23, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Oct 23, 2026

@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: 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:

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 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 👍 / 👎.

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.

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.

@danielhanchen
danielhanchen merged commit fb104d2 into main Oct 23, 2026
2 of 36 checks passed
@danielhanchen
danielhanchen deleted the studio-image-guard-owner-flows branch October 23, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant