Skip to content

Studio: Use file-scoped links for chat downloads - #19846

Merged
Lyxot merged 6 commits into
unslothai:mainfrom
NilayYadav:studio-scope-sandbox-download-links
Nov 27, 2026
Merged

Lyxot merged 6 commits into
unslothai:mainfrom
NilayYadav:studio-scope-sandbox-download-links

Conversation

@NilayYadav

Copy link
Copy Markdown
Collaborator

Downloading a generated chat file puts the session credential in the download URL. Browsers can retain that URL in download history, so saving an individual file also leaves a copy of the sign-in credential behind.

Generate a short-lived link for the requested file and use it for the download. In the desktop app, request the link after the user chooses where to save. Both download paths continue to use Studio’s existing file access checks.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-27T09:11:37.599744Z 0d80c48 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 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: 5ad49c816d

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

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 0259e07a5e

ℹ️ 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 danielhanchen added affects UI# codex-converged# important# security# Moves a security boundary: sandbox, allowlist, permission or network guard labels Nov 27, 2026
@Lyxot Lyxot self-assigned this Nov 27, 2026
Assert at the route that a download link is refused for another file, another session, an expired or tampered expiry, and a forged signature; that minting a missing file is a 404 and the mint route requires a session; that each account's link serves only its own sandbox file; and that a cancelled native save chooser mints no link.
@Lyxot

Lyxot commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Pushed a test-only follow-up (dc1c391) after a local security review. No production behavior changed.

  • The route itself now refuses a download link that targets another file or another session, has expired, has a tampered expiry, or has a forged signature.
  • Minting a link for a missing file is a 404, and the mint route requires a session.
  • A link minted by one account serves only that account's sandbox file (a regression that dropped run_as would now fail).
  • A cancelled native save chooser mints no link.
  • One banner comment in serve_sandbox_file now mentions download links.

@Lyxot

Lyxot commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

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

ℹ️ 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 thread studio/backend/routes/inference.py Resolved
Match the gallery and library link mints: a caller admitted by keyless API access gets a 403 instead of a file link that would stay valid after keyless access is turned off.
@Lyxot

Lyxot commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 59a52206ab

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

@Lyxot

Lyxot commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Merged latest main (69 commits behind, no conflicts) as bbed571.

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

ℹ️ 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 thread studio/backend/routes/inference.py Resolved
A link redeems as the bare account, so a link minted with an API key lost the key's sandbox restrictions and could resolve a project's linked working folder the key may not read. Refuse API-key and keyless callers with a 403; they can download with their bearer header.
@Lyxot

Lyxot commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: 0d80c48a72

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

@Lyxot

Lyxot commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Review wrap-up for 0d80c48.

Codex: Didn't find any major issues on 0d80c48a72.

CI (staging run on the same head in a fork, because the upstream queue was backed up): every check this PR touches passed: Studio repo tests, Studio install, Backend (Python 3.13), frontend unit tests (Windows), source lint, the Tauri Linux build, and Rust unit tests on macOS and Windows. None of the remaining failures come from this PR:

What changed during review:

  • Tests: the route refuses a link for another file, another session, an expired or tampered expiry, and a forged signature. Minting a missing file is a 404. Each account's link serves only its own sandbox file. A cancelled native chooser mints no link.
  • POST /sandbox-download-link now mints only for UI sessions. API-key and keyless callers get a 403. A link redeems as the bare account, so a key's link dropped its sandbox restrictions and could resolve a project's linked working folder. Those callers still download with their bearer header.
  • Merged latest main (no conflicts).

Checked end to end through the real auth dependencies:

  • A session JWT mints a link (200), and the link downloads its file with no bearer (200).
  • The same link on another file gets a 401.
  • An sk-unsloth key gets a 403 on mint, and a 200 downloading directly with its header.

@Lyxot Lyxot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. The download link is scoped to one session, file and account, expires after 5 minutes, and is minted only for UI sessions. The existing containment checks still run when it is redeemed.

@Lyxot
Lyxot merged commit 7d74ffd into unslothai:main Nov 27, 2026
68 of 70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

affects UI# codex-converged# important# security# Moves a security boundary: sandbox, allowlist, permission or network guard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants