# GHSA-46fp-8f5p-pf2m: Improper detection of disallowed URIs by Loofah `allowed_uri?`

> Attackers can bypass URI validation to inject JavaScript, causing XSS in applications directly using the allowed_uri? helper.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 18 Mar 2026

## What is GHSA-46fp-8f5p-pf2m?

GHSA-46fp-8f5p-pf2m is a cross-site scripting vulnerability in loofah, published on 18 Mar 2026. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

## 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 `&#13;` (carriage return), `&#10;` (line feed), or `&#9;` (tab).

## Details

The `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)`.

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

## Which versions are affected by GHSA-46fp-8f5p-pf2m?

2 open source packages ship an affected version, including loofah.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `loofah` | RubyGems | From 2.25.0 | 2.25.1 |
| `loofah` | RubyGems | From 2.25.0 | 2.25.1 |

## How do I fix GHSA-46fp-8f5p-pf2m?

Upgrade loofah to 2.25.1 or later.

## Is GHSA-46fp-8f5p-pf2m being exploited?

There is no known exploitation of GHSA-46fp-8f5p-pf2m in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-46fp-8f5p-pf2m and fix it if it is affected.

What it is: GHSA-46fp-8f5p-pf2m is a cross-site scripting vulnerability in loofah, published on 18 Mar 2026. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-46fp-8f5p-pf2m in the wild and no public exploit code.

Affected packages and fixed versions:
- loofah (RubyGems): affected from 2.25.0; fixed in 2.25.1
- loofah (RubyGems): affected from 2.25.0; fixed in 2.25.1

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-46fp-8f5p-pf2m/ (Markdown: https://insights.sbomify.com/GHSA-46fp-8f5p-pf2m/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-46fp-8f5p-pf2m

---
From sbomify Insights: https://insights.sbomify.com/GHSA-46fp-8f5p-pf2m/
Summaries are generated and may contain mistakes; the official description above is the record.
