Skip to content

Studio: managed accounts use the server's own HF endpoint for recipe seeds - #14187

Merged
danielhanchen merged 2 commits into
mainfrom
sec/recipe-seed-endpoint-public
Oct 19, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
sec/recipe-seed-endpoint-public

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

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 #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).

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 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-19T04:58:39.012148Z 4309f3e Manual request
🔒 Security Review ⚠️ Failed 2026-10-19T04:19:28.848753Z 857907d PR opened
ℹ️ 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 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: 857907deff

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

Comment on lines +545 to +546
from core.data_recipe.service import _require_public_provider_endpoint
_require_public_provider_endpoint(typed)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Validate redirect targets before fetching the seed

A managed user can supply an attacker-controlled public HTTPS endpoint, which passes this check, and have it redirect the subsequent /validate request to a loopback, LAN, or cloud-metadata URL. The seed reader uses HfFileSystem, whose huggingface_hub HTTP client follows redirects, while validation runs in the API process without install_public_egress_guard; therefore the new check does not prevent the SSRF it is intended to close. Apply the public-address policy to every redirect/connection or use a guarded transport for the API-side seed fetch.

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.

Confirmed: HfFileSystem follows a 302 from the typed endpoint to an internal one, so checking the typed address is not enough. Fixed in 4309f3e: a managed account may only use this server's own HF endpoint (blank, the UI default, or the same URL); any other typed endpoint is refused with 403 before anything is fetched. The owner is unchanged. Tests cover private, metadata and public HTTPS endpoints with the private-URL setting on and off; end to end through the validate route, a public endpoint that redirects to loopback now gets 403 and neither server is contacted.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen danielhanchen changed the title Studio: a managed account's HF seed endpoint must be a public HTTPS address Studio: managed accounts use the server's own HF endpoint for recipe seeds Oct 19, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 4309f3ef75

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

danielhanchen added a commit to Etherll/unsloth that referenced this pull request Oct 19, 2026
@danielhanchen
danielhanchen merged commit e42df82 into main Oct 19, 2026
@danielhanchen
danielhanchen deleted the sec/recipe-seed-endpoint-public branch October 19, 2026 05:33
danielhanchen added a commit that referenced this pull request Oct 19, 2026
## Summary

Main is over the startup bundle budget again, by 17 B raw, so `Frontend
build + bundle sanity` fails on every PR based on it:

```
over the startup budget: raw 6665.9 KB > 6665.9 KB      (main at 551dc28)
```

#14168 reset both limits to the measured build plus a 160 B raw / 189 B
transfer margin. #14190 (open //host links as web links) then added 177
B raw / 52 B transfer to the eager startup chunks. It merged while its
own bundle check was still queued, so the raise never happened.

## Cause

`studio/frontend/src/lib/open-link.ts` is the shared link opener, and
the eager shell imports it. #14190 adds leading/trailing
control-character trimming and `//host` (scheme-relative) link handling
there (+16 lines). That is real growth with no lazy home: the opener is
needed from the first screen. #14187, the other commit since the reset,
changes no frontend code.

## Change

- **`check-bundle-budget.ts`:** a BUDGET comment entry for #14190, and
both limits moved to the measured build plus the same margin:
  - `rawBytes`: 6,825,885 -> 6,826,062.
  - `transferBytes`: 2,054,261 -> 2,054,313.

## Testing

One machine and build, Node 24, exact byte totals from the budget
script, 95 chunks throughout. CI has matched this machine to the byte on
every earlier budget change.

| tree | raw B | transfer B |
|---|---|---|
| `4dc8bf0bd2` (after #14168, no frontend change since) | 6,825,725 |
2,054,072 |
| main `551dc28123` (+ #14190, #14187) | 6,825,902 | 2,054,124 |

- **Main against the old limits:** `over the startup budget: raw 6665.9
KB > 6665.9 KB`.
- **With this change:** `within budget (0.2 KB transfer, 0.2 KB raw to
spare)`.
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