CVE-2026-126205: Loofah: Regular expression denial of service in the SVG local-reference check

Published Nov 12, 2026
·
Updated

Summary

Loofah'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.

Only Ruby 3.1 and earlier are affected. Ruby 3.2 added linear-time regexp matching, which makes the pattern linear.

Impact

An 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.

The default safelist allows the elements in SVGALLOWLOCALHREF, so no configuration change is required.

Mitigation

Upgrade to Loofah >= 2.25.3. Applications that cannot upgrade should run Ruby 3.2 or later, which matches the pattern in linear time.

Credit

Reported by scyoon through the Rails HackerOne program.

Other sources

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 SVGALLOWLOCALHREF 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.

— MITRE

Affected Software

1 affected componentFixes available
rubygems/loofah<2.25.3
2.25.3

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade rubygems/loofah to a version that resolves this vulnerability.

    Fixed in 2.25.3
  2. Upgrade

    Upgrade Loofah to a version that resolves this vulnerability.

    Fixed in 2.25.3
  3. Upgrade

    Upgrade Ruby to a version that resolves this vulnerability.

    Fixed in 3.2

Event History

Nov 12, 2026
CVE Published
via MITRE·08:41 PM
Data Sourced
via MITRE·08:41 PM
DescriptionSeverityWeakness
Advisory Published
via GitHub·09:00 PM
Data Sourced
via GitHub·09:00 PM
DescriptionSeverityWeaknessAffected Software
Data Sourced
via OSV·09:00 PM
Affected Software
Data Sourced
via NVD·09:17 PM
DescriptionSeverityWeakness

Frequently Asked Questions

1

Which deployments are exposed?

Deployments using Loofah's HTML5 sanitizer on Ruby 3.1 or earlier are affected when they sanitize attacker-supplied HTML. The default safelist permits the relevant SVG elements, so a configuration change is not required for exposure.

2

What does an attacker need to send to trigger the issue?

An attacker must be able to supply HTML that the application passes to Loofah's sanitizer. The triggering input is an SVG reference element with an href or xlink:href attribute containing a long run of whitespace.

3

What is the impact of successful exploitation?

The attacker can cause CPU consumption disproportionate to the input size, potentially degrading availability. The affected regular-expression behavior takes quadratic time on all-whitespace attribute values.

4

What can be done if Loofah cannot be upgraded immediately?

Run the application on Ruby 3.2 or later, where the regular-expression matching behavior is linear for this pattern. The primary remediation is upgrading Loofah to version 2.25.3 or later.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203