-
Notifications
You must be signed in to change notification settings - Fork 4.2k
fix(desktop): trust the per-worktree Vite dev port for WebKitGTK mic capture - #7407
Open
BonesGit wants to merge 1 commit into
Open
fix(desktop): trust the per-worktree Vite dev port for WebKitGTK mic capture #7407BonesGit wants to merge 1 commit into
BonesGit wants to merge 1 commit into
Conversation
...capture The Linux WebKitGTK permission-request handler (from block#3607, fixing block#3495) hardcoded the trusted dev origin as http://localhost:1420, Vite's default port. But every just-based entrypoint (dev, desktop-standalone, staging, production) sources scripts/instance-env.sh, which derives a stable per-worktree dev port in 10000-64999 and points devUrl at http://localhost:<port>. The webview therefore loads from an origin the handler never trusts, so getUserMedia is denied with NotAllowedError and huddles tear down immediately on every Linux dev build. Derive the trusted dev origin from VITE_PORT at webview startup instead, falling back to 1420 when the variable is missing or invalid (raw pnpm tauri dev without instance-env). The port must be 1-5 digits parsing to a nonzero u16; scheme and host stay hardcoded to http://localhost. Debug-gated so packaged builds keep trusting only tauri://localhost. Fixes block#7406 (regression of block#3495, introduced by block#3607). Signed-off-by: BonesGit <BonesGit@local>
🔐 Codex Security Review
Status: review required for the current range.
The current range is
3c7f288c60d67df78577b237e27c3dfc8831aaa1...c86d059da1f5a8a3ca60ed357fb3643ebb8e8a4f.
A new review must complete for this exact range. When manual authorization
is required, a Block organization member must comment exactly
@buzz-security-review c86d059da1f5a8a3ca60ed357fb3643ebb8e8a4fto authorize a new review.
Any previous review applies only to its recorded range.
BonesGit
commented
Sep 6, 2026
Author
Verified on Linux (Arch, WebKitGTK, native non-AppImage debug build): with this change, just desktop-standalone → start huddle → mic capture succeeds and the companion window stays open. Previously the window tore down immediately with the NotAllowedError from #7406.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
Summary
Fixes #7406 — huddles on Linux dev builds still fail with
NotAllowedErrorimmediately after the mic is grabbed, because the WebKitGTK
permission-requesthandler added in #3607 (the fix for #3495) hardcodes thetrusted dev origin as
http://localhost:1420, Vite's default port.Every just-based entrypoint (
just dev,just desktop-standalone,just staging,just production) sourcesscripts/instance-env.sh, whichderives a stable per-worktree dev port in the range 10000–64999
(
10000 + sha256(worktree) % 55000) and pointsdevUrlathttp://localhost:<port>. The webview therefore loads from an origin thehandler never matches, so
getUserMediais denied withNotAllowedErrorandthe huddle tears down. The
1420check is dead in practice; #3607 wasapparently validated against the raw default-port path (or a non-Linux
platform), so the regression slipped through the close of #3495.
Change
desktop/src-tauri/src/linux_media.rsonly:DEV_ORIGINconstant withdev_origin_for_port(),which builds
http://localhost:<port>from a validated 1–5 digit nonzeroport, falling back to
http://localhost:1420on missing/empty/non-numeric/zero/out-of-range input (so a raw
pnpm tauri devwithout instance-envbehaves exactly as before).
dev_media_origin()readsVITE_PORTfrom the process env — the exactvariable
instance-env.shexports before launchingtauri dev, inheritedby the app.
is_trusted_media_origin(uri, dev_origin: Option<&str>)stays pure andunit-testable; the production origin is always trusted, the dev origin only
when
Some(debug builds only).(
'staticrequirement).Security posture unchanged: scheme + host stay hardcoded to
http://localhost(only the port is env-derived, so no remote host can beinjected), exact-origin / path-prefix matching preserved (port look-alikes
like
:14200still rejected), deny-by-default preserved, and the whole devpath is
#[cfg(debug_assertions)]-gated so packaged builds keep trusting onlytauri://localhost.Test plan
cargo test --lib linux_media— 6/6 pass (production origin, dev origin+ look-alike rejection, port-validation fallback cases)
cargo clippy --lib— clean forlinux_media.rscargo fmtapplied (pre-commit desktop-tauri-fmt hook passed)just desktop-standaloneon Linux — huddle starts, mic iscaptured, and the companion window stays open (verified by reporter)
Regression tests
dev_origin_for_portis new, pure, and fully unit-tested (configured port,default fallback, and rejection of
"","not-a-port","0","-1","99999","142000").is_trusted_media_originkeeps its existinglook-alike tests, extended to the parameterized form.