GHSA-mf2j-8f84-cc9q: 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.

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
Advisory Published
via GitHub·09:00 PM
Data Sourced
via GitHub·09:00 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Which deployments are exposed by default?

Applications using Loofah’s HTML5 sanitizer on Ruby 3.1 or earlier are exposed when they sanitize attacker-supplied HTML. No safelist customization is needed because the default safelist permits the relevant SVG elements.

2

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

The attacker needs to control HTML that is passed to the sanitizer. Affected input contains an SVG reference element with an href or xlink:href value made up of a long run of whitespace.

3

What can be done if Loofah cannot be upgraded immediately?

Run the application on Ruby 3.2 or later. Ruby 3.2 uses linear-time regular-expression matching for this pattern, preventing the quadratic CPU consumption described.

4

How can I determine whether this affects my application?

Check whether the application sanitizes untrusted HTML with Loofah’s HTML5 sanitizer and runs on Ruby 3.1 or earlier. Loofah versions before 2.25.3 should be upgraded; version 2.25.3 or later is the stated mitigation.

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