MEDIUM · CVSS 4.0 EPSS 0.5% · 39th percentile CWE-184CWE-79

CVE-2026-126206: Loofah allowed_uri? treats data:text/html as safe text/plain

Published 2026-11-12 · Updated 2026-11-12 · Also known as GHSA-jcff-cj73-4w4f

Summary

Loofah's `allowed_uri?` helper incorrectly treats `data:` URIs containing HTML5 named character references like `/` as safe text/plain because it fails to fully normalize entities, while browsers decode them as `text/html`. Applications that directly call `allowed_uri?` on HTML-encoded strings should upgrade to secure their validation logic.

Who is affected

Applications that validate user-controlled URLs using the public `Loofah::HTML5::Scrub.allowed_uri?` helper (or its re-export in `Rails::HTML::Sanitizer.allowed_uri?`) and render the approved values into URI attributes are vulnerable to cross-site scripting. The issue specifically requires callers to pass HTML-encoded strings directly to the helper function. Loofah's default `sanitize()` path is not affected because Nokogiri decodes the entity during parsing beforehand.

Exploitability

The vulnerability has a CVSS 4.0 base vector indicating network attack vector, low attack complexity, no required privileges, and user interaction, potentially leading to low confidentiality and integrity impact on the scope. The EPSS score is 0.004, and CISA KEV lists active exploitation as no.

Remediation

How to check your project

Automated analysis of the published advisory data, generated 2026-11-18. Not human-reviewed; verify against the official advisory. How this works.

Affected packages

EcosystemPackageAffected versionsFixed inUpgrade
RubyGems loofah >= 2.25.2, < 2.25.3 2.25.3 bundle update loofah

CVSS 4.0 vector

CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N

Attack vectorNetwork
Attack complexityLow
Attack requirementsNone
Privileges requiredNone
User interactionPassive
Confidentiality (vulnerable system)None
Integrity (vulnerable system)None
Availability (vulnerable system)None
Confidentiality (subsequent systems)Low
Integrity (subsequent systems)Low
Availability (subsequent systems)None

Base score is not computed for CVSS 4.0 vectors; severity is taken from the advisory.

FAQ

Is Loofah's default sanitize() method affected?

No, the default sanitize() path is not affected because Nokogiri decodes entities during parsing before Loofah evaluates the URI.

Which specific components are vulnerable?

Callers of the public `Loofah::HTML5::Scrub.allowed_uri?` string-level helper and `Rails::HTML::Sanitizer.allowed_uri?` that pass HTML-encoded strings are affected.

What is the fixed version for Loofah?

The vulnerability is fixed in Loofah version 2.25.3.

Original advisory description
## Summary `Loofah::HTML5::Scrub.allowed_uri?` returns `true` for a `data:` URI whose mediatype is written with the HTML5 named character reference `&sol;` in place of the solidus. Loofah reads that mediatype as malformed and falls back to the allowed `text/plain`, while a browser decodes the reference and reads the same URI as `text/html`. ## Details `allowed_uri?` decodes HTML entities with `CGI.unescapeHTML`, which handles numeric character references but not HTML5 named character references. `&sol;` therefore survives normalization, so the mediatype carries no `/`, fails the MIME grammar, and falls back to the allowed `text/plain` under the WHATWG rule for a malformed mediatype. `&colon;`, `&sol;`, `&Tab;` and `&NewLine;` are the only named character references in the HTML5 table that decode to characters that change how a URI parses (U+003A, U+002F, U+0009 and U+000A; there is no named reference for U+000D), so this closes the set. Loofah's default `sanitize()` path is **not** affected, because Nokogiri decodes the entity during parsing before Loofah evaluates the URI. This issue affects only callers of the public `allowed_uri?` string-level helper that pass it HTML-encoded strings. ## Impact Applications that validate a user-controlled URL with `Loofah::HTML5::Scrub.allowed_uri?` and then render the approved value into an `href` or another browser-interpreted URI attribute may be vulnerable to cross-site scripting. `Rails::HTML::Sanitizer.allowed_uri?` re-exports the same helper. ## Mitigation Upgrade to Loofah >= 2.25.3. ## Credit Responsibly reported by GitHub user @ngpestelos.

References

Source records: GHSA-jcff-cj73-4w4f (OSV.dev) · EPSS by FIRST, 2026-11-26.