Skip to content

Studio: a managed account's Hub dataset card may not make the server dial an http(s) URL - #14091

Merged
danielhanchen merged 1 commit into
mainfrom
sec/s135-hub-card-urls
Oct 18, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
sec/s135-hub-card-urls

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Fix from the latest security scan. Nothing changes for the owner, Desktop, the CLI or notebooks.

Problem. A Hub dataset card's data_files may name an http(s) URL. Studio's card guard (utils/security/hub_data_files.py) allows that, and datasets then fetches the URL from the server, following redirects. On a multi-account install, a managed account can publish (or pick) a card that points at a public URL redirecting to 127.0.0.1, a LAN address or cloud metadata, and read the internal response back as rows in the dataset preview or token preview. Every other managed-account egress path (providers, MCP, recipes) is already limited to public addresses, so this was the one way around it.

Change. For a managed account, a Hub card may name relative paths and hf:// URLs only; an http(s) URL is refused with the guard's existing FileNotFoundError. The check reads the bound account context, which the API request threads and the managed training and token preview workers (run_account_child) already carry.

  • Owner: unchanged. The account context defaults to the owner, so single-user installs, Desktop, the CLI and notebooks behave as before.
  • Managed accounts: almost every real card names relative paths or hf:// files, which keep working. Only the rare card listing external http(s) data files can no longer be previewed or loaded by a managed account.
  • A host or IP allowlist would not hold, because the fetch follows a redirect from a public-looking URL to the internal target.
  • Idempotent: a pure check inside the existing once-only patch.

Test (tests/test_hub_data_files_guard.py::test_a_managed_account_cannot_make_a_hub_card_dial_a_url, a real subprocess with a loopback server that redirects /public.csv to /internal-secret):

main this PR
owner loads the card rows read rows read
managed account loads the card internal response returned as rows refused, 0 requests to the server

The new test fails on main and passes here. The existing guard tests and 25 neighbouring dataset and account suites pass (382 passed).

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 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-17T23:49:58.017445Z 902e48b Manual request
🔒 Security Review ✅ Completed 2026-10-17T23:51:04.680371Z 902e48b 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

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 902e48bcc9

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

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

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

Reviewed commit: 902e48bcc9

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.

@danielhanchen
danielhanchen merged commit ce3b7a5 into main Oct 18, 2026
@danielhanchen
danielhanchen deleted the sec/s135-hub-card-urls branch October 18, 2026 09:47
shimmyshimmer pushed a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Oct 19, 2026
…seeds (unslothai#14187)

Fix from a re-check of the security scan backlog. Nothing changes for
the owner, Desktop, the CLI or notebooks.

**Problem.** A data recipe's Hugging Face seed node accepts a typed
`endpoint`. `_resolve_seed_endpoint` (`routes/data_recipe/jobs.py`)
fills in the server's own endpoint when it is blank and otherwise leaves
the typed one alone, and `validate_recipe_access` checks the seed's
token and paths but not its endpoint. `POST /api/data-recipe/validate`
then runs Data Designer's validation in the API process, which reads the
seed from that endpoint. The public-only egress guard
(`install_public_egress_guard`) runs only in the recipe job worker, not
in the API process.

So on a multi-account install, a managed account could make the Studio
server send GET requests to loopback, LAN or cloud metadata addresses of
its choosing, and read back whether each host and port answered from the
validation error. Managed accounts are otherwise limited to public
addresses for providers, MCP, recipes and (since unslothai#14091) Hub dataset
cards.

**Change.** A managed account may only use this server's own Hugging
Face endpoint for an HF seed: blank (the UI default, resolved to
`HF_ENDPOINT` as before) or the same URL typed explicitly. Any other
typed endpoint is refused with 403 before anything is fetched. Both
callers (validate and job start) go through `_resolve_seed_endpoint`.

- An address check alone is not enough: the HF client follows redirects,
so a public HTTPS endpoint could bounce the request to loopback or
metadata (confirmed with a local 302).
- Owner: unchanged, any endpoint including a private mirror.
- Managed accounts: the UI default and the server's own (possibly
mirrored) endpoint keep working; only a custom typed endpoint is
refused.
- Idempotent: a pure check, nothing stored.

**Evidence.** End to end with data-designer 0.5.4 and a loopback server
recording requests, the real validate route called as a managed account:

| | main | this PR |
|---|---|---|
| managed account, endpoint `http://127.0.0.1:<port>/internal` | server
receives `GET /internal/api/datasets/...`; error returns the status and
URL | 403 refused, 0 requests |
| managed account, endpoint that 302s to loopback | request follows the
redirect to the internal server | 403 refused, neither server contacted
|

Tests (`tests/test_managed_provider_url_policy.py`): a managed account's
private, metadata and public HTTPS seed endpoints are refused, with the
owner's private-URL setting on and off (12 cases, all fail on main);
blank, the server's own endpoint, and any endpoint for the owner still
resolve as before. The data recipe and account suites pass (434 passed,
20 skipped).
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