Skip to content

Studio: open //host links as web links; run apt-get by absolute path; ignore the dev Studio home - #14190

Merged
danielhanchen merged 2 commits into
mainfrom
sec/desktop-link-apt-hardening
Oct 19, 2026
Merged

danielhanchen merged 2 commits into
mainfrom
sec/desktop-link-apt-hardening

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Three small hardenings from a re-check of the security scan backlog. Each was approved in an earlier triage round and had not landed. No visible change for normal use.

  1. //host links open as web links (studio/frontend/src/lib/open-link.ts). openLink treated a protocol-relative href (//evil.example/x, or the backslash forms browsers read the same way) as a path inside Studio and let native navigation run, which replaced Studio's page, and in Desktop the main window, with another site. Studio: open http(s): source links without slashes as web links; flag Windows theme downloads #13195 covered https:host without slashes; this covers //host. It is rewritten to https://host/... and opened like any other web link (browser panel or a new tab). Relative paths, anchors and ordinary links are unchanged.
  2. The Desktop elevated Linux install runs /usr/bin/apt-get by absolute path (studio/src-tauri/src/install.rs). The code already checks that /usr/bin/apt-get exists, then ran apt-get update and apt-get install by bare name under elevation. Both now use the checked path, as debian_update.rs already does.
  3. /.studio/ is ignored by git (.gitignore). The README's dev install keeps the Studio home in the checkout (UNSLOTH_STUDIO_HOME="$PWD/.studio"). Only auth.db was ignored, so git add . would stage studio.db (chats, saved connections), auth/, accounts/, the venv and caches.

Tests:

  • studio/frontend/tests/open-link-scheme-without-slashes.test.ts: //host and the backslash forms open as https://host/... (fails on main); the existing cases still pass. Related link tests pass (32), tsc and eslint clean.
  • tests/test_installer_elevation_report.py: no bare apt-get command in install.rs, and the README's dev Studio home is ignored. cargo check --locked for Desktop passes on Linux.

Before / after

A web-search source chip whose stored URL is //host/landing (a local landing page), clicked in a chat. Markdown links are already normalised by the renderer, so a source chip is where a //host href reaches openLink. Before: Studio's page is replaced by the landing page. After: Studio stays on the chat and the link opens as a web link in a new tab.

Clicking a //host source chip, before and after

@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-19T05:03:14.000566Z 8148fb5 Manual request
🔒 Security Review ✅ Completed 2026-10-19T04:38:21.200603Z ad94cfc 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.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

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

Reviewed commit: ad94cfcb3a

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.

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

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


// `//host/path` (or with backslashes, which browsers read the same way) is another site, not a path in Studio:
// native navigation would replace Studio's page (the Desktop main window) with it.
if (/^[\\/]{2}/.test(url)) {

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 Normalize leading URL whitespace before classifying links

When untrusted Markdown uses a destination such as [x](< //evil.example/x>), Streamdown preserves the leading space, but the browser's URL parser strips it during native <a> navigation. This check therefore misses the protocol-relative URL, the later relative-URL branch returns false, and the Markdown click handler does not prevent the navigation, so the external site can still replace the Studio page. Normalize leading/trailing C0 controls and spaces before applying this test.

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.

Fixed in 8148fb5: leading and trailing C0 controls and spaces are trimmed (as the URL parser does) before any classification, so //host and \u0001\t//host open as web links too. Covered in the test.

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 19, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 8148fb5295

ℹ️ 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 merged commit 551dc28 into main Oct 19, 2026
@danielhanchen
danielhanchen deleted the sec/desktop-link-apt-hardening 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