From 908bd094e04fb7be07987b84e1e635f999e346fe Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Fri, 13 Nov 2026 20:41:18 +0000 Subject: [PATCH] fix(orchestrator): drop the 3D library's nonce-less injected styles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The vendored 3d-force-graph appends three empty style elements to head while it loads and fills them with its own CSS; the page CSP allows styles by nonce only, so it blocks them and Firefox logs six style-src-elem errors, which failed the W3 artifacts e2e once 594d185 opened the 3D view there. page-graph3d.js now intercepts head.appendChild only while that script runs (document.currentScript is its tag), skips style elements from it and removes the interception on load or error. The CSP and the pinned library stay unchanged; the page already styles the classes those blocks targeted. 🎯 Fix: 95 % 💥 Break: 3 % 💸 Cost: – ⏱️ Time: – 🛡️ Security: 100 % 🏆 Score: 92 🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 % Co-Authored-By: Claude Opus 5.5 --- orchestrator/templates/page-graph3d.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/orchestrator/templates/page-graph3d.js b/orchestrator/templates/page-graph3d.js index 819cd7f..b1310fa 100644 --- a/orchestrator/templates/page-graph3d.js +++ b/orchestrator/templates/page-graph3d.js @@ -29,14 +29,30 @@ } } + function refuseInjectedStyles(tag) { + const head = document.head; + const append = head.appendChild; + head.appendChild = function (node) { + return document.currentScript === tag && node instanceof HTMLStyleElement ? node : append.call(this, node); + }; + return () => delete head.appendChild; + } + function loadScript(src) { return new Promise((resolve, reject) => { const tag = document.createElement("script"); + const restore = refuseInjectedStyles(tag); tag.src = src; tag.nonce = NONCE; tag.async = true; - tag.addEventListener("load", resolve); - tag.addEventListener("error", () => reject(new Error(`${src} not loaded`))); + tag.addEventListener("load", () => { + restore(); + resolve(); + }); + tag.addEventListener("error", () => { + restore(); + reject(new Error(`${src} not loaded`)); + }); document.head.append(tag); }); }