GHSA-2j22-pr5w-6gq8: Loofah Loofah Has Improper Detection Of Vulnerability

LOW
CWE-116 CWE-79
Published
Advisory Summary

GHSA-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

CVE Identifier N/A
GHSA Identifier GHSA-2j22-pr5w-6gq8
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-116: Improper Encoding or Escaping of Output
Affected Product Loofah
Package Ecosystem RubyGems
Published Date
Last Updated

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.

loofah fixed: 2.25.1
Upgrade loofah to 2.25.1
Verify Direct and Transitive Dependencies

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

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

GHSA-2j22-pr5w-6gq8 Affected Loofah Versions

1 component(s)
Fixed Versions:
2.25.1
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?
GHSA-2j22-pr5w-6gq8 is a security vulnerability in Loofah involving Loofah has improper detection of disallowed URIs via `allowed_uri?` under CWE-116: Improper Encoding or Escaping of Output.
Which Loofah versions are affected?
Affected versions include releases prior to 2.25.1 across affected packages: loofah.
What version fixes GHSA-2j22-pr5w-6gq8?
Upgrading to 2.25.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is loofah affected?
Yes, loofah is affected in releases prior to 2.25.1. Upgrade your dependency to 2.25.1 or later.
What CWE is associated with GHSA-2j22-pr5w-6gq8?
GHSA-2j22-pr5w-6gq8 is classified under CWE-116: Improper Encoding or Escaping of Output (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.).
How can I check RubyGems dependencies for GHSA-2j22-pr5w-6gq8?
Run the dependency tree command: 'inspect dependencies for loofah'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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 `&#13;` (carriage return), `&#10;` (line feed), or `&#9;` (tab).\n\n## Details\n\nThe `allowed_uri?` method strips literal control characters before decoding HTML entities. Payloads like `java&#13;script:alert(1)` survive the control character strip, then `&#13;` 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
  }
}