Repository navigation
fix(dashboard): open external links via validated host bridge in plugin views - #11613
Open
JosephTian876 wants to merge 1 commit into
Open
JosephTian876 wants to merge 1 commit into
JosephTian876 wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="dashboard/src/components/plugins/PluginViewFrame.vue" line_range="695" />
<code_context>
:style="{ colorScheme: themeParam }"
referrerpolicy="no-referrer"
- sandbox="allow-scripts allow-forms allow-downloads"
+ sandbox="allow-scripts allow-forms allow-downloads allow-popups allow-popups-to-escape-sandbox"
@load="handleIframeLoad"
></iframe>
</code_context>
<issue_to_address>
**Plugin popups escape dashboard isolation**
When a plugin view opens a popup from a user gesture, `allow-popups-to-escape-sandbox` lets the popup run without the iframe’s sandbox restrictions while retaining its opener. Same-origin plugin content can read Dashboard localStorage credentials, and hostile popup code can navigate the Dashboard tab, exposing credentials or redirecting users.
Remove `allow-popups-to-escape-sandbox` so opened windows remain sandboxed.
Also at `dashboard/src/components/chat/message_list_comps/PluginViewCard.vue:8`.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and a plugin view can now open a popup that escapes the iframe sandbox, so plugin content can present an unrestricted window to users and potentially exploit the trust that the sandbox was meant to limit. Reverting prevents future popups from getting that permission, but cannot undo a user interaction or data exposure that already occurred.
Blocking findings: dashboard/src/components/plugins/PluginViewFrame.vue:695
…in views Replace iframe allow-popups/allow-popups-to-escape-sandbox with a host-mediated external:open bridge capability (window.AstrBotPluginView.openExternal) and trusted external anchor click delegation, keeping plugin view iframe sandboxes strictly isolated while validating cross-origin http(s) URLs, user activation, and noopener/noreferrer.
JosephTian876
force-pushed
the
fix/plugin-view-iframe-allow-popups
branch
from
December 4, 2026 03:41
a6877cf to
a24df86
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces iframe
allow-popups/allow-popups-to-escape-sandboxwith a strictly validated, host-mediatedexternal:openbridge capability (window.AstrBotPluginView.openExternal(url)) and trusted external anchor click delegation across bothPluginViewFrame.vueandPluginViewCard.vue, addressing security review feedback while keeping plugin view iframe sandboxes completely unchanged.Problem
Dashboard plugin views execute inside sandboxed iframes without
allow-popups:dashboard/src/components/plugins/PluginViewFrame.vue(plugin_pageand launcher-openedchat_workbench_with_launcher):sandbox="allow-scripts allow-forms allow-downloads"dashboard/src/components/chat/message_list_comps/PluginViewCard.vue(chat_messageandevent.view_result()workbench views):sandbox="allow-scripts"Because popups are blocked by the iframe sandbox, user-initiated
<a target="_blank">links or programmatic requests to open documentation, help/OAuth pages, external references, or a plugin's standalone web UI fail silently. Relaxing the iframesandboxwithallow-popups-to-escape-sandbox, however, would allow an iframe to open unsandboxed same-origin tabs or bypass host URL checks.Security Rationale & Design
Rather than relaxing the iframe
sandbox, external navigation is mediated exclusively by the Dashboard host:sandboxremains completely unchanged: Neitherallow-popups,allow-popups-to-escape-sandbox,allow-same-origin, norallow-top-navigationis added toPluginViewFrame.vueorPluginViewCard.vue(andHtmlGenUiNode.vueremains untouched).dashboard/src/utils/pluginExternalUrl.ts):http:/https:URLs.user:pass@), control characters, and dangerous schemes (javascript:,data:,blob:,file:, etc.) withINVALID_EXTERNAL_URL.navigator.userActivation.isActive(rejecting non-gesture calls withUSER_ACTIVATION_REQUIRED).window.open(safeUrl, "_blank", "noopener,noreferrer")and defensively nullsopened.opener.astrbot/dashboard/plugin_page_bridge.js):window.AstrBotPluginView.openExternal(url)across all plugin view targets (plugin_page,chat_message,chat_workbench,chat_workbench_with_launcher).<a href="https://..." target="_blank">links to cross-originhttp(s)URLs (skippingdownload,#hash, same-origin, or non-trusted events) and forwards them throughexternal:open.Changes
dashboard/src/utils/pluginExternalUrl.ts: New host-side validation and safe window opener (validateExternalPluginUrl,openExternalPluginUrl, typedINVALID_EXTERNAL_URL/USER_ACTIVATION_REQUIREDerrors).astrbot/dashboard/plugin_page_bridge.js: Permitexternal:openacross all view targets, exposeopenExternal(url), and delegate trusted external<a target="_blank">clicks.dashboard/src/components/plugins/PluginViewFrame.vue&dashboard/src/components/chat/message_list_comps/PluginViewCard.vue: Handleexternal:openbridge requests viaopenExternalPluginUrlwithout changing iframesandboxattributes.docs/public/types/astrbot-plugin-view.d.ts,docs/en/dev/star/guides/plugin-views/bridge.md,docs/zh/dev/star/guides/plugin-views/bridge.md: DocumentopenExternal(url),OpenExternalResult, and anchor delegation in English and Chinese.dashboard/tests/pluginViewBridge.test.mjs&dashboard/tests/pluginViewCard.test.mjs: Extended existing test suites to cover host validation, error codes, anchor delegation, and strict sandbox preservation (0 new standalone test files per#11511).Files Changed (9 files, +828 / -4)
astrbot/dashboard/plugin_page_bridge.jsdashboard/src/components/chat/message_list_comps/PluginViewCard.vuedashboard/src/components/plugins/PluginViewFrame.vuedashboard/src/utils/pluginExternalUrl.tsdashboard/tests/pluginViewBridge.test.mjsdashboard/tests/pluginViewCard.test.mjsdocs/en/dev/star/guides/plugin-views/bridge.mddocs/public/types/astrbot-plugin-view.d.tsdocs/zh/dev/star/guides/plugin-views/bridge.mdVerification
node --test tests/*.test.mjs(indashboard/): 138 passed, 0 failed (including expandedpluginViewBridge.test.mjsandpluginViewCard.test.mjs).git diff --check 44447db3e..HEAD: PASS (0 whitespace/EOF warnings).#11511compliant); zero file overlap with all 9 siblingAstrBotPR branches.建议合并顺序 (Recommended Merge Order)
#11613— can be merged in any order alongside the siblingAstrBotPRs:#11609fix/plugin-service-closed-connector(31cd10cfe)#11610fix/t2i-local-skip-external-probe(fa03d8382)#11611fix/aiocqhttp-at-member-fallback(695686d2e)#11612fix/system-one-decision-float32-softmax-tol(ca095e44f)#11613fix/plugin-view-iframe-allow-popups(a24df86ec— this PR update)#11614fix/gemini-thinking-camelcase-and-safety(397ee6bc1)#11615fix/gemini-openai-extra-body-guard(b6c2b1554)#11616feat/provider-text-chat-structured-output(7a2f9fe93)#11617feat/gemini-decision-1-provider-adapter(0736069ad)perf/fail-fast-credential-500-and-fallback-cooldown(e3ba1699b— new standalone PR)Summary by Sourcery
Enable plugin views to open validated external links through the Dashboard host without loosening iframe sandbox restrictions.
New Features:
openExternal(url)capability for plugin views and automatically route eligible external-link clicks through the Dashboard host.Enhancements:
Documentation:
Tests: