The best way to control Claude Code, Codex and more from any computer or phone
fix(desktop): compare custom renderer scheme and authority explicitly (#21445)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
Victor Vogel committed
Oct 30, 2026 at 20:22 UTC
2a180c7b6ada736187dc4957639a915563779fca
2 files changed
+59
-2
apps/desktop/src/window/DesktopWindow.test.ts
+50
@@ -472,6 +472,45 @@ describe("DesktopWindow", () => {
472
);
473
});
474
475
+ it("rejects renderer navigations whose origin only serializes as null", () => {
476
+ for (const applicationUrl of ["t3code://app/", "t3code-dev://app/"]) {
477
+ assert.isTrue(
478
+ DesktopWindow.isSameOriginRendererNavigation({
479
+ applicationUrl,
480
+ navigationUrl: `${applicationUrl}threads?id=1#latest`,
481
+ }),
482
+ applicationUrl,
483
+ );
484
+ }
485
+ for (const navigationUrl of [
486
+ "t3code://other/",
487
+ "t3code://app.example/",
488
+ "t3code://app:8080/",
489
+ "t3code://user@other/",
490
+ "t3code:app",
491
+ "t3code-dev://app/",
492
+ "file:///etc/passwd",
493
+ "data:text/html,<p>hi</p>",
494
+ "javascript:alert(1)",
495
+ "about:blank",
496
+ "blob:t3code://app/0b5e2c4a",
497
+ ]) {
498
+ assert.isFalse(
499
+ DesktopWindow.isSameOriginRendererNavigation({
500
+ applicationUrl: "t3code://app/",
501
+ navigationUrl,
502
+ }),
503
+ navigationUrl,
504
+ );
505
+ }
506
+ assert.isFalse(
507
+ DesktopWindow.isSameOriginRendererNavigation({
508
+ applicationUrl: "data:text/html,app",
509
+ navigationUrl: "data:text/html,other",
510
+ }),
511
+ );
512
+ });
513
+
514
it.effect(
515
"opens and reopens the window without backend readiness when local execution is disabled",
516
() =>
@@ -973,6 +1012,17 @@ describe("DesktopWindow", () => {
1012
if (!willNavigate) {
1013
return yield* Effect.die("will-navigate listener was not registered");
1014
}
1015
+ for (const [url, expectedPrevented] of [
1016
+ ["t3code-dev://app/threads?id=1#latest", false],
1017
+ ["t3code-dev://other/", true],
1018
+ ["t3code://app/", true],
1019
+ ] as const) {
1020
+ const preventDefault = vi.fn();
1021
+ willNavigate({ preventDefault }, url);
1022
+ assert.equal(preventDefault.mock.calls.length, expectedPrevented ? 1 : 0, url);
1023
+ }
1024
+ assert.deepEqual(openedExternalUrls, []);
1025
+
1026
let prevented = false;
1027
willNavigate(
1028
{
apps/desktop/src/window/DesktopWindow.ts
+9
-2
@@ -183,12 +183,19 @@ function buildConnectingSplashDataUrl(shouldUseDarkColors: boolean): string {
183
return `data:text/html;charset=utf-8,${encodeURIComponent(html)}`;
184
}
185
186
-function isSameOriginRendererNavigation(input: {
186
+export function isSameOriginRendererNavigation(input: {
187
readonly applicationUrl: string;
188
readonly navigationUrl: string;
189
}): boolean {
190
try {
191
- return new URL(input.applicationUrl).origin === new URL(input.navigationUrl).origin;
191
+ const applicationUrl = new URL(input.applicationUrl);
192
+ const navigationUrl = new URL(input.navigationUrl);
193
+ // Node serializes custom-scheme origins as "null", even for different hosts and schemes.
194
+ return (
195
+ applicationUrl.host !== "" &&
196
+ navigationUrl.protocol === applicationUrl.protocol &&
197
+ navigationUrl.host === applicationUrl.host
198
+ );
199
} catch {
200
return false;
201
}