fix: dicht drie gaten in de SVG-sanitizer (SMIL, CSS, puntkomma-lijsten) #547
No reviewers
Labels
No labels
accepted
bug
declined
docs
duplicate
enhancement
good first issue
in-progress
needs-info
privacy
security
triage
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
LibreKAT/Ocideck!547
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/svg-allowlist"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fourth item from #516: the SVG sanitiser's deny-list. Three holes closed; the allow-list deliberately not attempted yet, with the reason recorded in the file.
The three holes, and what they have in common
Each one is the same shape: the list was complete for the attack somebody had in mind, and blind to the mechanism next door.
SMIL could install an event handler that did not exist at parse time.
<set attributeName="onload" to="alert(1)"/>writes the attribute when the animation runs, so thename.startsWith('on')check on the parent never saw anything — at parse time the parent carries noon…attribute at all. All four animation elements now go. Mermaid animates with CSS, not SMIL, so they earn nothing here; filtering onattributeNamewould have left a narrower version of the same trust.<style>carried CSS, and CSS carries URLs. Nothing in this file parses that dialect, so aurl(javascript:…)or an@importinside a stylesheet travelled straight past a check that only ever looked at attributes.The URL check read only the start of the whole value. SMIL and CSS both use semicolon-separated lists, so
values="a;javascript:alert(1)"was read as safe because its first entry was.Why this is still a deny-list
An allow-list is the right shape — it refuses what it does not recognise instead of hoping the list of dangers is complete, and these three holes are the argument for it.
What it needs first is the actual element and attribute vocabulary Mermaid emits, per diagram type. That is not available here: the tests use hand-written SVG, not real Mermaid output. An allow-list built on intuition renders the first sequence diagram half-way with no error at all — and silent loss is a worse trade than a known gap.
The route is written into the file: collect real output per diagram type through the actual renderer, derive the lists from that, and make a rejected element log a warning rather than vanish quietly.
Verification
Four new tests, one per hole plus the animation family. Mutation-checked: reverting the three fixes makes three of the twelve fail.
make checkgreen.Part of #516; five items left there, of which
audienceBoundaryand the signing questions are design work rather than fixes.