From 0568026e7c16aacd35f6613cff1b72ac6b6cf4d0 Mon Sep 17 00:00:00 2001 From: mikael-lovqvists-claude-agent Date: Sat, 7 Mar 2026 20:36:26 +0000 Subject: [PATCH] Validate URL protocol in open-browser action Parse the URL and reject anything that isn't http/https before passing to xdg-open, blocking file://, javascript:// and other schemes. Co-Authored-By: Claude Sonnet 4.6 --- server/actions.mjs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/actions.mjs b/server/actions.mjs index 8b3428e..297a60a 100644 --- a/server/actions.mjs +++ b/server/actions.mjs @@ -48,8 +48,12 @@ export const actions = { params: [{ name: "url", required: true, type: "string" }], policy: "queue", handler: async ({ url }) => { - await exec("xdg-open", [url]); - return { opened: url }; + const parsed = new URL(url); + if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') { + throw new Error(`Disallowed protocol: ${parsed.protocol}`); + } + await exec('xdg-open', [parsed.href]); + return { opened: parsed.href }; }, },