GHSA-2j22-pr5w-6gq8: Loofah Loofah Has Improper Detection Of Vulnerability
LOWGHSA-2j22-pr5w-6gq8 is a LOW loofah has improper detection of vulnerability (CWE-116: Improper Encoding or Escaping of Output) affecting Loofah libraries in the RubyGems ecosystem. The issue involves loofah has improper detection of disallowed uris via `allowed_uri?`. Remediation is available by upgrading affected packages to version 2.25.1.
GHSA-2j22-pr5w-6gq8 at a Glance
How to Fix GHSA-2j22-pr5w-6gq8
To remediate this vulnerability, upgrade all affected Loofah dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade loofah to 2.25.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for loofah
How to Check if You Are Affected
To determine whether your application is affected by GHSA-2j22-pr5w-6gq8, inspect your project dependencies for Loofah:
inspect dependencies for loofah
Analyze the terminal output to locate any version of Loofah in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.25.1), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-116: Improper Encoding or Escaping of Output, where the product prepares a structured message for communication with another component, but encoding or escaping of the data is either missing or done incorrectly. as a result, the intended structure of the message is not preserved. In Loofah, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
GHSA-2j22-pr5w-6gq8 Affected Loofah Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
loofah
|
RubyGems |
≥ 2.25.0
< 2.25.1
All 1 versions
2.25.0
|
2.25.1
|
References
Frequently Asked Questions
What is GHSA-2j22-pr5w-6gq8?
Which Loofah versions are affected?
What version fixes GHSA-2j22-pr5w-6gq8?
Is loofah affected?
What CWE is associated with GHSA-2j22-pr5w-6gq8?
How can I check RubyGems dependencies for GHSA-2j22-pr5w-6gq8?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-2j22-pr5w-6gq8",
"modified" : "2026-03-26T22:19:02Z",
"published" : "2026-03-26T22:19:02Z",
"aliases" : [ ],
"summary" : "Loofah has improper detection of disallowed URIs via `allowed_uri?`",
"details" : "## Summary\n\n`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).\n\n## Details\n\nThe `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)`.\n\nNote 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.\n\n## Impact\n\nApplications 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).\n\nThis only affects Loofah `2.25.0`.\n\n## Mitigation\n\nUpgrade to Loofah >= `2.25.1`.\n\n## Credit\n\nResponsibly reported by HackOne user @smlee.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "RubyGems",
"name" : "loofah"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "2.25.0"
}, {
"fixed" : "2.25.1"
} ]
} ],
"versions" : [ "2.25.0" ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/flavorjones/loofah/security/advisories/GHSA-46fp-8f5p-pf2m"
}, {
"type" : "WEB",
"url" : "https://github.com/flavorjones/loofah/commit/f4ebc9c5193dde759a57541062e490e86fc7c068"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/flavorjones/loofah"
}, {
"type" : "WEB",
"url" : "https://github.com/flavorjones/loofah/releases/tag/v2.25.1"
}, {
"type" : "WEB",
"url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/loofah/GHSA-46fp-8f5p-pf2m.yml"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-116", "CWE-79" ],
"severity" : "LOW",
"github_reviewed" : true,
"github_reviewed_at" : "2026-03-26T22:19:02Z",
"nvd_published_at" : null
}
}