From f2cb8bfacbaabdd8720e2daa3d75cfdf7fc18402 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 8 Jul 2026 10:49:03 +0200 Subject: [PATCH] feat(web-app-dashboard): accept onion mirror origin in iframe allowlist The client-side iframe.js postMessage handler validated message origins and redirect targets against a single .DOMAIN_PRIMARY suffix, which rejected the onion mirror domain and broke iframe sync over Tor. Allow the svc-net-tor node suffix alongside clearnet when tor is deployed; both the origin and redirect checks stay restrictive. Co-Authored-By: Claude Opus 4.8 --- .../templates/javascript/iframe.js.j2 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/roles/web-app-dashboard/templates/javascript/iframe.js.j2 b/roles/web-app-dashboard/templates/javascript/iframe.js.j2 index c28fc00e15..341e9b1d6c 100644 --- a/roles/web-app-dashboard/templates/javascript/iframe.js.j2 +++ b/roles/web-app-dashboard/templates/javascript/iframe.js.j2 @@ -1,9 +1,10 @@ +{% set _tor_node = lookup('config', 'svc-net-tor', 'services.tor.node', '') %} window.addEventListener("message", function(event) { - const allowedSuffix = ".{{ DOMAIN_PRIMARY }}"; + const allowedSuffixes = [".{{ DOMAIN_PRIMARY }}"{% if _tor_node %}, ".{{ _tor_node }}"{% endif %}]; const origin = event.origin; - // 1. Only allow messages from *.{{ DOMAIN_PRIMARY }} - if (!origin.endsWith(allowedSuffix)) return; + // 1. Only allow messages from an allowed domain suffix (clearnet or onion mirror) + if (!allowedSuffixes.some(function (suffix) { return origin.endsWith(suffix); })) return; const data = event.data; @@ -12,8 +13,8 @@ window.addEventListener("message", function(event) { try { const hrefUrl = new URL(data.href); - // 3. Only allow redirects to *.{{ DOMAIN_PRIMARY }} - if (!hrefUrl.hostname.endsWith(allowedSuffix)) return; + // 3. Only allow redirects to an allowed domain suffix + if (!allowedSuffixes.some(function (suffix) { return hrefUrl.hostname.endsWith(suffix); })) return; // 4. Update the ?iframe= parameter in the browser URL const newUrl = new URL(window.location);