From f0b1bc7120794a93a6c1b6313a02064a8fafe00c Mon Sep 17 00:00:00 2001 From: sec-check Date: Sun, 4 Oct 2026 03:33:47 -0400 Subject: [PATCH] fix(security): scan findRemoteReferences() is an error-level gate in validate-architecture-assets.mjs: an SVG that fetches from a third-party host is refused, because the fetch discloses the visitor's IP, User-Agent and Referer from the site's own origin. Its inside a CDATA section is character data and does not close the element -- but the lazy match stops there, so every declaration after the decoy went unscanned in a file that is well-formed and renders. A rule such as rect{fill:url(https://host/x.svg#g)} placed after it passed both gates. Read the CSS with a scan that consumes CDATA sections whole before '<' is given any meaning. An unclosed ` regex cannot express this. In + * XML -- which is how a browser parses a standalone `.svg` -- a `` + * inside a CDATA section is ordinary character data, so it does not close the + * element; the lazy match stops there anyway and every declaration after it + * goes unscanned, in a file that is well-formed and renders. That hid a live + * `url(https://host/...)` fetch from findRemoteReferences, which is the gate + * that keeps a visitor's IP, User-Agent and Referer from reaching a host the + * diagram's author chose. + * + * CDATA sections are therefore consumed whole before `<` is given any + * meaning. A `'; assert.deepEqual(findRemoteReferences(svg), [ @@ -548,6 +548,58 @@ test('an empty inside a CDATA section does not end the ` inside a + // CDATA section is character data and does not close the element. A lazy + // `` match stops there anyway, so every + // declaration after it went unscanned in a file that is well-formed and + // renders -- a live remote fetch hidden from the gate that keeps a + // visitor's IP, User-Agent and Referer off a host the diagram chose. + const svg = + ''; + assert.deepEqual(findRemoteReferences(svg), [ + 'references a remote resource in a ` in the first. + const svg = + '' + + '' + + ''; + assert.deepEqual(findRemoteReferences(svg), [ + 'references a remote resource in a