GHSA-46fp-8f5p-pf2m: Loofah Improper Detection Of Disallowed URIs Vulnerability

LOW
CWE-79
Published
Advisory Summary

GHSA-46fp-8f5p-pf2m is a LOW improper detection of disallowed uris vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Loofah libraries in the RubyGems ecosystem. The issue involves improper detection of disallowed uris by loofah `allowed_uri?`. Remediation is available by upgrading affected packages to version 2.25.1.

GHSA-46fp-8f5p-pf2m at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-46fp-8f5p-pf2m
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Loofah
Package Ecosystem RubyGems
Published Date
Last Updated

How to Fix GHSA-46fp-8f5p-pf2m

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-46fp-8f5p-pf2m, 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-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. 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-46fp-8f5p-pf2m 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-46fp-8f5p-pf2m?
GHSA-46fp-8f5p-pf2m is a security vulnerability in Loofah involving Improper detection of disallowed URIs by Loofah `allowed_uri?` under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Loofah versions are affected?
Affected versions include releases prior to 2.25.1 across affected packages: loofah.
What version fixes GHSA-46fp-8f5p-pf2m?
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-46fp-8f5p-pf2m?
GHSA-46fp-8f5p-pf2m is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check RubyGems dependencies for GHSA-46fp-8f5p-pf2m?
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-46fp-8f5p-pf2m",
  "modified" : "2026-03-18T17:26:48Z",
  "published" : "2026-03-18T17:26:48Z",
  "aliases" : [ ],
  "summary" : "Improper detection of disallowed URIs by Loofah `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:N/PR:N/UI:N/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N/E:U"
  } ],
  "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" : "PACKAGE",
    "url" : "https://github.com/flavorjones/loofah"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-18T17:26:48Z",
    "nvd_published_at" : null
  }
}