VYPR
Moderate severityNVD Advisory· Published Dec 14, 2022· Updated Nov 3, 2025

Improper neutralization of data URIs allows XSS in rails-html-sanitizer

CVE-2022-23518

Description

rails-html-sanitizer is responsible for sanitizing HTML fragments in Rails applications. Versions >= 1.0.3, < 1.4.4 are vulnerable to cross-site scripting via data URIs when used in combination with Loofah >= 2.1.0. This issue is patched in version 1.4.4.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

rails-html-sanitizer fails to properly sanitize data URIs, allowing XSS via base64 encoded scripts when used with Loofah >=2.1.0.

rails-html-sanitizer is responsible for sanitizing HTML fragments in Rails applications. Versions >=1.0.3, <1.4.4 are vulnerable to cross-site scripting (XSS) via data URIs when used in combination with Loofah >=2.1.0 [1][4]. The root cause is a divergence in the PermitScrubber class, which does not properly validate data URIs, unlike Loofah's scrubber that includes a safe data URI check [4].

An attacker can exploit this by crafting an HTML fragment containing an ` with a src attribute set to a data URI, such as data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4=` [4]. The sanitizer fails to remove or escape the data URI, allowing the base64-encoded JavaScript to execute in the victim's browser. This attack does not require authentication and can be triggered by submitting unsanitized user input [4].

Successful exploitation leads to arbitrary JavaScript execution in the context of the user's session, potentially allowing theft of cookies, session tokens, or other sensitive information, or performing actions on behalf of the victim [1].

The issue is patched in rails-html-sanitizer version 1.4.4 [1]. Users are advised to upgrade immediately. No workaround is available for older versions.

AI Insight generated on May 20, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
rails-html-sanitizerRubyGems
>= 1.0.3, < 1.4.41.4.4

Affected products

12

Patches

0

No patches discovered yet.

Vulnerability mechanics

AI mechanics synthesis has not run for this CVE yet.

References

9

News mentions

0

No linked articles in our index yet.