From 400703154ed051fc3880a8256433cd7dbdd5459c Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Mon, 18 May 2026 16:18:00 +0200 Subject: [PATCH] fix: ignore plugin-supplied target in ui.openExternalUrl to block host-frame hijack --- lib/plugin-sandbox/host-api.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/plugin-sandbox/host-api.ts b/lib/plugin-sandbox/host-api.ts index b1eb4fc4..29626bb1 100644 --- a/lib/plugin-sandbox/host-api.ts +++ b/lib/plugin-sandbox/host-api.ts @@ -296,8 +296,9 @@ export async function dispatchApiCall( if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') { throw new Error(`ui.openExternalUrl: ${parsed.protocol} not allowed`); } - const target = typeof args[1] === 'string' ? (args[1] as string) : '_blank'; - window.open(parsed.toString(), target, 'noopener,noreferrer'); + // Always open in a new tab; plugins must not be able to navigate the + // host window (_self/_top/_parent) to an attacker-controlled origin. + window.open(parsed.toString(), '_blank', 'noopener,noreferrer'); return undefined; }