Repository navigation
Studio: a managed account's Hub dataset card may not make the server dial an http(s) URL - #14091
Conversation
…dial an http(s) URL
|
@codex review |
|
@codex security review |
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. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
🛡️ 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. |
…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).
Fix from the latest security scan. Nothing changes for the owner, Desktop, the CLI or notebooks.
Problem. A Hub dataset card's
data_filesmay name an http(s) URL. Studio's card guard (utils/security/hub_data_files.py) allows that, anddatasetsthen 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 to127.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 existingFileNotFoundError. 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.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.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.csvto/internal-secret):The new test fails on main and passes here. The existing guard tests and 25 neighbouring dataset and account suites pass (382 passed).