Skip to content

Commit 65a5fad

Browse files
fix: gate allow-same-origin on the terminal file-preview iframe to prevent same-origin XSS (open-webui#26907)
The system-terminal HTML file preview (FilePreview.svelte, serveUrl branch) rendered served HTML in an iframe that hardcoded allow-same-origin. The terminal proxy serves the file root-relative (same origin as the app) and injects no CSP, and there is no default global CSP, so script in a previewed HTML file executed in the application's own origin and could read localStorage (the session token), enabling account takeover and, for admin or workspace.functions victims, server-side RCE via Functions. The sibling srcdoc branch already gates allow-same-origin behind the iframeSandboxAllowSameOrigin setting (off by default) and injects a CSP; the serveUrl branch never received that defense. Gate allow-same-origin on the serveUrl branch identically, so by default the preview runs at an opaque origin and its scripts cannot reach the parent context. Legitimate HTML preview rendering is unaffected. Co-authored-by: manus-use <manus-use@users.noreply.github.com>
1 parent f4a6ea9 commit 65a5fad

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/lib/components/chat/FileNav/FilePreview.svelte

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,9 @@
400400
{/if}
401401
<iframe
402402
src={serveUrl}
403-
sandbox="allow-scripts allow-same-origin allow-downloads{($settings?.iframeSandboxAllowForms ??
404-
false)
403+
sandbox="allow-scripts allow-downloads{($settings?.iframeSandboxAllowForms ?? false)
405404
? ' allow-forms'
406-
: ''}"
405+
: ''}{($settings?.iframeSandboxAllowSameOrigin ?? false) ? ' allow-same-origin' : ''}"
407406
class="w-full h-full border-none bg-white"
408407
title="HTML Preview"
409408
/>

0 commit comments

Comments
 (0)