[PR #22908] [MERGED] enh: allow iframe postMessage prompts without same-origin (with HITL confirmation) #26922

Closed
opened 2026-04-20 06:46:23 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/22908
Author: @Classic298
Created: 3/20/2026
Status: Merged
Merged: 3/21/2026
Merged by: @tjbck

Base: devHead: fix/iframe-postmessage-origin-check


📝 Commits (2)

📊 Changes

1 file changed (+29 additions, -7 deletions)

View changed files

📝 src/lib/components/chat/Chat.svelte (+29 -7)

📄 Description

allow iframe postMessage prompts without same-origin (with HITL confirmation)

Problem

The onMessageHandler in Chat.svelte checks event.origin against window.origin and silently drops messages from sandboxed iframes that don't have same-origin access. This means Rich UI tools that use the input:prompt:submit postMessage protocol (e.g. interactive buttons that send prompts back to the chat) only work when "iframe Sandbox Allow Same Origin" is enabled.

Requiring same-origin for this feature is a security tradeoff: it also exposes parent.document, parent.fetch, and parent.localStorage to iframe JavaScript — which is far more access than sendPrompt needs.

Solution

When same-origin is enabled, prompt messages go through immediately (unchanged behavior).

When same-origin is disabled, cross-origin input:prompt:submit messages now trigger the existing EventConfirmDialog instead of being silently dropped. The user sees the message text and can confirm or cancel before it is submitted. This prevents abuse (spam) while still enabling the feature without requiring same-origin access.

Other cross-origin message types (input:prompt, action:submit) are also allowed through to the handler — input:prompt only fills the input box without submitting, and action:submit uses the existing prompt text.

Changes

  • Chat.svelte: Restructured the origin check in onMessageHandler to allow prompt-related message types from opaque-origin iframes
  • For input:prompt:submit from cross-origin: shows a confirmation dialog before submitting
  • For input:prompt:submit from same-origin: submits immediately (no behavior change)

Contributor License Agreement

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/22908 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 3/20/2026 **Status:** ✅ Merged **Merged:** 3/21/2026 **Merged by:** [@tjbck](https://github.com/tjbck) **Base:** `dev` ← **Head:** `fix/iframe-postmessage-origin-check` --- ### 📝 Commits (2) - [`d2bf44a`](https://github.com/open-webui/open-webui/commit/d2bf44a142758d70d45e65a1d8a30ed76d778958) Update Chat.svelte - [`8a2578c`](https://github.com/open-webui/open-webui/commit/8a2578c7de4ba7ad36e09d86c8b0a544ee9eeec7) Update Chat.svelte ### 📊 Changes **1 file changed** (+29 additions, -7 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/components/chat/Chat.svelte` (+29 -7) </details> ### 📄 Description # allow iframe postMessage prompts without same-origin (with HITL confirmation) ## Problem The onMessageHandler in Chat.svelte checks event.origin against window.origin and silently drops messages from sandboxed iframes that don't have same-origin access. This means Rich UI tools that use the input:prompt:submit postMessage protocol (e.g. interactive buttons that send prompts back to the chat) only work when "iframe Sandbox Allow Same Origin" is enabled. Requiring same-origin for this feature is a security tradeoff: it also exposes parent.document, parent.fetch, and parent.localStorage to iframe JavaScript — which is far more access than sendPrompt needs. ## Solution When same-origin is enabled, prompt messages go through immediately (unchanged behavior). When same-origin is disabled, cross-origin input:prompt:submit messages now trigger the existing EventConfirmDialog instead of being silently dropped. The user sees the message text and can confirm or cancel before it is submitted. This prevents abuse (spam) while still enabling the feature without requiring same-origin access. Other cross-origin message types (input:prompt, action:submit) are also allowed through to the handler — input:prompt only fills the input box without submitting, and action:submit uses the existing prompt text. ## Changes - Chat.svelte: Restructured the origin check in onMessageHandler to allow prompt-related message types from opaque-origin iframes - For input:prompt:submit from cross-origin: shows a confirmation dialog before submitting - For input:prompt:submit from same-origin: submits immediately (no behavior change) ### Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. Your PR will NOT be reviewed or merged until you check the box below confirming that you have read and agree to the terms of the CLA. --> - [x] By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-20 06:46:23 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#26922