{"id":"CVE-2026-126205","aliases":["CVE-2026-126205","GHSA-mf2j-8f84-cc9q"],"related":[],"kind":"vulnerability","state":"published","title":"Loofah: Regular expression denial of service in the SVG local-reference check","summary":"Loofah is a general library for manipulating and transforming HTML/XML documents and fragments, built on top of Nokogiri. Prior to 2.25.3, the Loofah HTML5 sanitizer checks href and xlink:href on elements in SVG_ALLOW_LOCAL_HREF with a regular expression whose line anchor and newline-matching whitespace cause an all-whitespace value to be rescanned from every line start. An attacker can submit an SVG reference element with a long multiline-whitespace attribute and consume CPU quadratically during sanitization. CRuby 3.1 and earlier and JRuby are affected, while CRuby 3.2 and later uses linear-time regular-expression matching. The default safelist reaches the vulnerable check without a configuration change. This issue is fixed in version 2.25.3.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Loofah is a general library for manipulating and transforming HTML/XML documents and fragments, built on top of Nokogiri. Prior to 2.25.3, the Loofah HTML5 sanitizer checks href and xlink:href on elements in SVG_ALLOW_LOCAL_HREF with a regular expression whose line anchor and newline-matching whitespace cause an all-whitespace value to be rescanned from every line start. An attacker can submit an SVG reference element with a long multiline-whitespace attribute and consume CPU quadratically during sanitization. CRuby 3.1 and earlier and JRuby are affected, while CRuby 3.2 and later uses linear-time regular-expression matching. The default safelist reaches the vulnerable check without a configuration change. This issue is fixed in version 2.25.3.","source":"cvelist"},{"lang":"en","text":"## Summary\n\nLoofah's HTML5 sanitizer restricts the `href` and `xlink:href` attributes of SVG reference elements to local references. That check matched the attribute value against `/^\\s*[^#\\s].*/m`. In Ruby `^` anchors to every line start and `\\s` matches newlines, so an all-whitespace value made the engine rescan the value from each of its line starts, taking time quadratic in its length.\n\nOnly Ruby 3.1 and earlier are affected. Ruby 3.2 added linear-time regexp matching, which makes the pattern linear.\n\n## Impact\n\nAn attacker who supplies HTML to be sanitized can consume CPU out of proportion to the input size, by sending an SVG reference element whose `href` or `xlink:href` is a long run of whitespace.\n\nThe default safelist allows the elements in `SVG_ALLOW_LOCAL_HREF`, so no configuration change is required.\n\n## Mitigation\n\nUpgrade to Loofah >= 2.25.3. Applications that cannot upgrade should run Ruby 3.2 or later, which matches the pattern in linear time.\n\n## Credit\n\nReported by scyoon through the Rails HackerOne program.","format":"markdown","source":"ghsa"}],"published":"2026-11-12T20:41:25.574Z","modified":"2026-11-16T20:18:59.413Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L","score":5.3,"rating":"MEDIUM"}],"cwes":["CWE-400","CWE-1333"],"affected":[{"ranges":[{"version":"< 2.25.3","status":"affected"}],"vendor":"flavorjones","product":"loofah","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"2.25.3"}],"ecosystem":"RubyGems","package":"loofah","purl":"pkg:gem/loofah","source":"ghsa"}],"references":[{"url":"https://github.com/flavorjones/loofah/security/advisories/GHSA-mf2j-8f84-cc9q","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/flavorjones/loofah/pull/324","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/flavorjones/loofah/commit/2f31e7fae36036c9882d3d0fae720e1014c57cd1","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/flavorjones/loofah/releases/tag/v2.25.3","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/flavorjones/loofah","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/rubysec/ruby-advisory-db/blob/master/gems/loofah/GHSA-mf2j-8f84-cc9q.yml","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"partial","date":"2026-11-16T19:26:27.279Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-126205","url":"https://www.cve.org/CVERecord?id=CVE-2026-126205","licence":"CVE Terms of Use","modified":"2026-11-16T19:26:46.967Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-mf2j-8f84-cc9q","url":"https://github.com/advisories/GHSA-mf2j-8f84-cc9q","licence":"CC-BY-4.0","modified":"2026-11-12T21:15:10.377Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-126205","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-126205","licence":"Public domain","modified":"2026-11-16T20:18:59.413Z"}],"updatedAt":"2026-11-25T22:59:50.564Z","epss":{"score":0.00405,"percentile":0.36867,"date":"2026-12-01T12:00:22.000Z"}}