Improper detection of disallowed URIs by Loofah `allowed_uri?`
Published 18 Mar 2026 · Updated 10 Sept 2026
Is your project on an affected loofah?
Look after several Rails or Ruby apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie
Affected package
- Affected
- >=2.25.0 <2.25.1
- Fixed in
- 2.25.1
bundle update --conservative loofah # Gemfile: '>= 2.25.1'Details
Summary
Loofah::HTML5::Scrub.allowed_uri? does not correctly reject javascript: URIs when the scheme is split by HTML entity-encoded control characters such as (carriage return), (line feed), or 	 (tab).
Details
The allowed_uri? method strips literal control characters before decoding HTML entities. Payloads like java script:alert(1) survive the control character strip, then is decoded to a carriage return, producing java\rscript:alert(1).
Note that the Loofah sanitizer's default sanitize() path is not affected because Nokogiri decodes HTML entities during parsing before Loofah evaluates the URI protocol. This issue only affects direct callers of the allowed_uri? string-level helper when passing HTML-encoded strings.
Impact
Applications that call Loofah::HTML5::Scrub.allowed_uri? to validate user-controlled URLs and then render approved URLs into href or other browser-interpreted URI attributes may be vulnerable to cross-site scripting (XSS).
This only affects Loofah 2.25.0.
Mitigation
Upgrade to Loofah >= 2.25.1.
Credit
Responsibly reported by HackOne user @smlee.
Is GHSA-46fp-8f5p-pf2m in any of your client repos?
Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected loofah, and gives you the command that fixes it.
More advisories for loofah
- MediumCVE-2026-126208Loofah: SVG `<textPath>` and `<mpath>` bypass local-reference restriction · 12 Nov 2026
- MediumCVE-2026-126209Loofah allowed_uri? treats javascript: alert(1) as safe · 12 Nov 2026
- MediumCVE-2026-126207Loofah: CSS url() sanitization bypass via escaped parentheses · 12 Nov 2026
- MediumCVE-2026-126205Loofah: Regular expression denial of service in the SVG local-reference check · 12 Nov 2026
- MediumCVE-2026-126206Loofah allowed_uri? treats data:text/html as safe text/plain · 12 Nov 2026
- MediumCVE-2026-126203Loofah: Mutation XSS in the HTML5 scrubbers through unescaped attribute values · 12 Nov 2026
References
Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.