Problem
freenet/freenet-core is removing allow-popups-to-escape-sandbox from the gateway iframe sandbox to fix a security vulnerability where a malicious web app can open a popup that escapes the sandbox and gains full localhost:7509 origin access -- enabling it to interact with other web apps, forge delegate operations, and bypass the new permission prompt system.
Without allow-popups-to-escape-sandbox, popups opened from the iframe inherit the sandbox (opaque origin). This breaks external links in River because the target website sees Origin: null in CORS requests, causing failures.
Solution
The gateway shell page now supports an open_url message via the existing postMessage bridge. Instead of <a target="_blank">, web apps send:
parent.postMessage({
__freenet_shell__: true,
type: 'open_url',
url: 'https://example.com'
}, '*');
The shell page validates the URL (must be https:, must not be localhost) and opens it with window.open(url, '_blank', 'noopener'), giving the popup proper origin without sandbox inheritance.
Changes Needed in River
In ui/src/components/conversation.rs, the add_target_blank_to_links function (around line 406) currently adds target="_blank" to all <a> tags in rendered messages. This needs to be changed so that link clicks are intercepted and routed through the shell bridge instead.
Options:
- Add an
onclick handler that calls parent.postMessage(...) and prevents default navigation
- Or use the freenet-stdlib helper (if one is added) for shell bridge URL opening
Blocked By
This is blocked by the freenet-core PR that removes allow-popups-to-escape-sandbox and adds the open_url shell bridge handler. External links will break in River once that PR is released until this change is made.
Priority
High -- must be done immediately after the freenet-core release that removes allow-popups-to-escape-sandbox.
[AI-assisted - Claude]
Problem
freenet/freenet-core is removing
allow-popups-to-escape-sandboxfrom the gateway iframe sandbox to fix a security vulnerability where a malicious web app can open a popup that escapes the sandbox and gains fulllocalhost:7509origin access -- enabling it to interact with other web apps, forge delegate operations, and bypass the new permission prompt system.Without
allow-popups-to-escape-sandbox, popups opened from the iframe inherit the sandbox (opaque origin). This breaks external links in River because the target website seesOrigin: nullin CORS requests, causing failures.Solution
The gateway shell page now supports an
open_urlmessage via the existing postMessage bridge. Instead of<a target="_blank">, web apps send:The shell page validates the URL (must be
https:, must not be localhost) and opens it withwindow.open(url, '_blank', 'noopener'), giving the popup proper origin without sandbox inheritance.Changes Needed in River
In
ui/src/components/conversation.rs, theadd_target_blank_to_linksfunction (around line 406) currently addstarget="_blank"to all<a>tags in rendered messages. This needs to be changed so that link clicks are intercepted and routed through the shell bridge instead.Options:
onclickhandler that callsparent.postMessage(...)and prevents default navigationBlocked By
This is blocked by the freenet-core PR that removes
allow-popups-to-escape-sandboxand adds theopen_urlshell bridge handler. External links will break in River once that PR is released until this change is made.Priority
High -- must be done immediately after the freenet-core release that removes
allow-popups-to-escape-sandbox.[AI-assisted - Claude]