Skip to content

Commit 69b7890

Browse files
authored
Merge pull request #294 from Latitudes-Dev/shuvcode-dev
fix: remove XSS vulnerability (CVE-2026-22813) and duplicate variant tooltip
2 parents de5ccb8 + 3ec0301 commit 69b7890

File tree

4 files changed

+30
-14
lines changed

4 files changed

+30
-14
lines changed

packages/app/src/app.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,26 +39,25 @@ declare global {
3939
}
4040

4141
const defaultServerUrl = iife(() => {
42-
// 1. Query parameter (highest priority)
43-
const param = new URLSearchParams(document.location.search).get("url")
44-
if (param) return param
42+
// NOTE: The ?url= query parameter was intentionally removed due to CVE-2026-22813 (GHSA-c83v-7274-4vgp)
43+
// Allowing arbitrary server URLs via query params enables XSS attacks on localhost:4096
4544

46-
// 2. Configured server URL (from desktop settings)
45+
// 1. Configured server URL (from desktop settings)
4746
if (window.__OPENCODE__?.serverUrl) return window.__OPENCODE__.serverUrl
4847

49-
// 3. Known production hosts -> localhost (same as upstream + shuv.ai)
48+
// 2. Known production hosts -> localhost (same as upstream + shuv.ai)
5049
if (location.hostname.includes("opencode.ai") || location.hostname.includes("shuv.ai")) return "http://localhost:4096"
5150

52-
// 4. Desktop app (Tauri) with injected port
51+
// 3. Desktop app (Tauri) with injected port
5352
if (window.__SHUVCODE__?.port) return `http://127.0.0.1:${window.__SHUVCODE__.port}`
5453
if (window.__OPENCODE__?.port) return `http://127.0.0.1:${window.__OPENCODE__.port}`
5554

56-
// 5. Dev mode -> same-origin so Vite proxy handles LAN access + CORS
55+
// 4. Dev mode -> same-origin so Vite proxy handles LAN access + CORS
5756
if (import.meta.env.DEV) {
5857
return `http://${import.meta.env.VITE_OPENCODE_SERVER_HOST ?? "localhost"}:${import.meta.env.VITE_OPENCODE_SERVER_PORT ?? "4096"}`
5958
}
6059

61-
// 6. Default -> same origin (production web command)
60+
// 5. Default -> same origin (production web command)
6261
return window.location.origin
6362
})
6463

packages/app/src/utils/hosted.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ export function isHostedEnvironment(): boolean {
99

1010
/**
1111
* Checks if a ?url= query parameter was provided in the URL.
12-
* This indicates the user is trying to connect to a specific server.
12+
*
13+
* SECURITY WARNING: This function exists ONLY for display purposes (e.g., showing
14+
* "Could not connect to X" in welcome-screen.tsx). The ?url= parameter must NEVER
15+
* be used to determine actual server connections due to CVE-2026-22813 (XSS vulnerability).
16+
* Server URL is determined exclusively by app.tsx defaultServerUrl logic.
1317
*/
1418
export function hasUrlQueryParam(): boolean {
1519
if (typeof window === "undefined") return false
@@ -18,6 +22,11 @@ export function hasUrlQueryParam(): boolean {
1822

1923
/**
2024
* Gets the ?url= query parameter value if present.
25+
*
26+
* SECURITY WARNING: This function exists ONLY for display purposes (e.g., showing
27+
* error messages with the attempted URL). The returned value must NEVER be used
28+
* for actual server connections due to CVE-2026-22813 (XSS vulnerability).
29+
* Server URL is determined exclusively by app.tsx defaultServerUrl logic.
2130
*/
2231
export function getUrlQueryParam(): string | null {
2332
if (typeof window === "undefined") return null

packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,11 +1122,6 @@ export function Prompt(props: PromptProps) {
11221122
<text fg={theme.text}>
11231123
{keybind.print("command_list")} <span style={{ fg: theme.textMuted }}>commands</span>
11241124
</text>
1125-
<Show when={hasVariants()}>
1126-
<text fg={theme.text}>
1127-
{keybind.print("variant_cycle")} <span style={{ fg: theme.textMuted }}>cycle variants</span>
1128-
</text>
1129-
</Show>
11301125
</Match>
11311126
<Match when={store.mode === "shell"}>
11321127
<text fg={theme.text}>

script/sync/fork-features.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,19 @@
120120
"Session migration for linked worktrees"
121121
],
122122
"note": "Upstream uses Project.sandboxes array to track worktrees. Main worktree is always Project.worktree."
123+
},
124+
{
125+
"pr": "CVE-2026-22813",
126+
"title": "Query parameter server URL override",
127+
"author": "fork",
128+
"removedDate": "2026-01-12",
129+
"reason": "Critical XSS vulnerability (GHSA-c83v-7274-4vgp, CVE-2026-22813) - malicious websites could execute commands via ?url= parameter. Upstream fixed in v1.1.10 by removing this feature.",
130+
"filesModified": ["packages/app/src/app.tsx"],
131+
"codeRemoved": [
132+
"const param = new URLSearchParams(document.location.search).get('url')",
133+
"if (param) return param"
134+
],
135+
"note": "The ?url= query parameter allowed arbitrary server URL override, enabling XSS on localhost:4096. Attackers could inject malicious server URLs that return XSS payloads, then use /pty/ API to execute arbitrary commands."
123136
}
124137
],
125138
"apiDependencies": [

0 commit comments

Comments
 (0)