CVE-2024-53988
Nonerails-html-sanitizer has XSS vulnerability with certain configurations
CVSS
—
EPSS
0.4%
Published
Dec 2, 2024
CISA due date
—
Cloudanix analysis
Some Rails applications may fail to fully clean unsafe user-submitted web content, allowing an attacker to run code in another user's browser when that content is viewed.
- Exploitation
- Requires User Interaction
- Attacker needs
- User Interaction
- Complexity
- Moderate
- Impact
- Data Exposure
- Component
- Library
- Class
- XSS
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
CVE-2024-53988 is a cross-site scripting vulnerability in Rails::HTML::Sanitizer 1.6.0 when used with Rails 7.1.0 or later under certain sanitizer configurations. The flaw can allow attacker-supplied HTML that is expected to be sanitized to retain or produce executable browser content, such as scriptable attributes, unsafe URLs, or markup that executes in a victim's browser. Successful exploitation affects the client side of applications that render sanitized user-controlled HTML, potentially enabling session theft, account actions performed as the victim, credential capture, or malicious content injection. Rails::HTML::Sanitizer versions earlier than 1.6.0 are not affected by this specific issue, and version 1.6.1 contains the fix.
Why it matters to the business
Applications that allow users to submit rich text, comments, profile content, messages, CMS content, support tickets, or other HTML-like input may expose end users and administrators to browser-based compromise if they run Rails::HTML::Sanitizer 1.6.0 with Rails 7.1 or later. The operational risk is highest for applications where privileged users review untrusted user content, because exploitation may let an attacker act as those users in the application. EPSS is low and the vulnerability is not listed in CISA KEV, so broad active exploitation is not currently indicated, but the fix is a narrow dependency upgrade and should be prioritized for internet-facing Rails applications and administrative workflows that render user-generated HTML.
How an attack unfolds
An attacker first identifies a Rails application that accepts user-controlled HTML or rich text and later renders it after processing through Rails::HTML::Sanitizer 1.6.0 on Rails 7.1 or newer. The attacker submits crafted markup designed to bypass the sanitizer configuration, such as HTML using event-handler attributes, scriptable URL schemes, malformed tags, SVG/MathML-style constructs, encoded characters, or nested markup that may be interpreted differently by the sanitizer and the browser. If the vulnerable sanitizer fails to remove or neutralize the dangerous content, the stored or reflected output is delivered to another user's browser. When the victim views the affected page, the browser executes the attacker's JavaScript in the security context of the vulnerable application. The script can then read accessible page data, perform application actions using the victim's authenticated session, exfiltrate CSRF tokens where exposed, alter displayed content, or redirect the victim to phishing or malware delivery pages. No public exploit maturity is reported in the provided data, but the exploitation pattern is straightforward wherever untrusted sanitized HTML is rendered.
How to fix it
Upgrade the Rails::HTML::Sanitizer gem from 1.6.0 to 1.6.1 or later. In Ruby applications, update the dependency declaration if it pins 1.6.0, run the package manager to refresh the lockfile, and redeploy all application instances that render sanitized HTML. For Bundler-managed applications, verify that Gemfile.lock no longer contains rails-html-sanitizer 1.6.0. If immediate upgrade is not possible, temporarily reduce exposure by disabling rich HTML input from untrusted users, rendering untrusted content as escaped plain text, restricting allowed tags and attributes to a minimal known-safe set, blocking scriptable URL schemes such as javascript: and data: where inappropriate, and applying a strict Content Security Policy that disallows inline script. Do not treat the Ubuntu kernel package fixed versions in the provided product metadata as the primary remediation for this Rails sanitizer vulnerability; the relevant application dependency fix is Rails::HTML::Sanitizer 1.6.1.
How to confirm the fix worked
Confirm exposure by inventorying Ruby applications that use Rails 7.1.0 or later and have rails-html-sanitizer exactly at version 1.6.0. Check Gemfile.lock, software composition analysis results, container image SBOMs, and deployed application dependency manifests. Validate remediation by confirming the resolved gem version is 1.6.1 or newer in build artifacts and running instances. Exercise application features that render user-supplied HTML with representative XSS test payloads and confirm the output is safely escaped or stripped and does not execute in a browser. Review Content Security Policy headers to ensure they provide defense in depth, but do not use CSP as a substitute for upgrading the gem.
Typical attack path
- Find or guess a Rails application feature that accepts rich text or HTML-like user input, such as comments, messages, profile fields, CMS pages, or ticket descriptions.
- Craft an HTML payload intended to survive sanitization in Rails::HTML::Sanitizer 1.6.0 under the application's sanitizer configuration.
- Submit the payload to a stored content field or a reflected input that is rendered back to users.
- Wait for a victim, moderator, support agent, or administrator to view the affected content in an authenticated browser session.
- Execute JavaScript in the victim's browser under the vulnerable application's origin.
- Use the victim's privileges to read data visible in the page, perform unauthorized actions, modify content, or exfiltrate session-adjacent tokens and sensitive page data.
How to detect it
To determine whether this vulnerability was already exploited, focus on application-layer evidence rather than host compromise indicators. Review web access logs, application request logs, WAF logs, database/content audit logs, and moderation/admin activity logs for submitted content containing suspicious HTML, encoded script fragments, event-handler attributes, scriptable URL schemes, SVG/MathML markup, iframe/srcdoc constructs, or unusual nested/obfuscated tags. Correlate suspicious content submissions with subsequent views by privileged users and with unusual actions from those users' sessions, such as account changes, new API tokens, permission updates, unexpected content edits, mass data access, or outbound requests to unfamiliar domains. Search stored user-generated content repositories for payloads that appear inert in logs but may execute after browser parsing. If browser telemetry, CSP violation reports, or reverse-proxy logs are available, look for blocked inline-script executions, unexpected connections to attacker-controlled domains, or JavaScript errors associated with pages rendering user-submitted content. Because no specific public exploit artifact is provided, detection should use behavioral and payload-pattern searches rather than relying on a single signature.
- rails-html-sanitizer (1.6.0)
- rails-html-sanitizer-1.6.0
- Rails::HTML::Sanitizer
- <script
- </script
- javascript:
- data:text/html
- onerror=
- onload=
- onclick=
- onmouseover=
- onfocus=
- onanimationstart=
- <svg
- </svg
- <math
- </math
- <iframe
- srcdoc=
- <img
- xlink:href=
- javascript
- \u006a\u0061\u0076\u0061\u0073\u0063\u0072\u0069\u0070\u0074
What your security team should do
- Prioritize upgrading Rails::HTML::Sanitizer to 1.6.1 or later in all Rails 7.1+ applications, especially internet-facing systems and applications with administrator review workflows.
- Search source repositories, lockfiles, container images, and SBOMs for rails-html-sanitizer version 1.6.0 and create remediation tickets for confirmed findings.
- Identify features that render user-generated HTML, including rich text editors, Markdown/HTML converters, CMS modules, comments, messaging, support tickets, and profile fields.
- Temporarily disable or plain-text render untrusted HTML in high-risk workflows until the dependency is upgraded and deployed.
- Add regression tests with XSS payloads around sanitizer behavior for application-specific allowed tags, attributes, and URL schemes.
- Deploy or tighten Content Security Policy to reduce impact from any future sanitizer bypass, favoring nonces or hashes and avoiding unsafe-inline.
- Review recent user-generated content submissions and web logs for suspicious HTML payloads targeting sanitizer bypasses.
- Monitor authentication, account-change, administrative-action, and content-modification logs for unusual activity following suspicious content views.
The record
There is a possible XSS vulnerability with certain configurations of Rails::HTML::Sanitizer 1.6.0 when used with Rails >= 7.1.0. * Versions affected: 1.6.0 * Not affected: < 1.6.0 * Fixed versions: 1.6.1
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| RubyGems | rails-html-sanitizer | 1.6.0 | 1.6.1 |
| Ubuntu:16.04:LTS | ruby-rails-html-sanitizer | 0 | No fix |
| Ubuntu:18.04:LTS | ruby-rails-html-sanitizer | 0 | No fix |
| Ubuntu:20.04:LTS | ruby-rails-html-sanitizer | 0 | No fix |
| Ubuntu:22.04:LTS | ruby-rails-html-sanitizer | 0 | No fix |
| Ubuntu:24.04:LTS | ruby-rails-html-sanitizer | 0 | No fix |
| Ubuntu:24.10 | ruby-rails-html-sanitizer | 0 | No fix |
| Ubuntu:25.04 | ruby-rails-html-sanitizer | 0 | No fix |
| Ubuntu:25.10 | ruby-rails-html-sanitizer | 0 | No fix |
| Ubuntu:Pro:16.04:LTS | ruby-rails-html-sanitizer | 0 | No fix |
| Ubuntu:Pro:18.04:LTS | ruby-rails-html-sanitizer | 0 | No fix |
| Ubuntu:Pro:20.04:LTS | ruby-rails-html-sanitizer | 0 | No fix |
| gem | rails-html-sanitizer | 1.6.0 | No fix |
| gem | rails-html-sanitizer | 1.6.0 | 1.6.1 |
| openSUSE:Tumbleweed | rubygem-rails-html-sanitizer | 0 | 1.7.0-1.1 |
Related vulnerabilities
- CVE-2024-53986 rails-html-sanitizer has XSS vulnerability with certain configurations Also affects rails-html-sanitizer
- CVE-2024-53989 rails-html-sanitizer has XSS vulnerability with certain configurations Also affects rails-html-sanitizer
- CVE-2024-53987 rails-html-sanitizer has XSS vulnerability with certain configurations Also affects rails-html-sanitizer
- CVE-2024-53985 rails-html-sanitize has XSS vulnerability with certain configurations Also affects rails-html-sanitizer
- CVE-2026-96379 Improper Neutralization of Input During Web Page Generation ("Cross-site Scripting")… CWE-79
- CVE-2026-96382 Improper Neutralization of Input During Web Page Generation ("Cross-site Scripting")… CWE-79
- CVE-2026-96368 Improper Neutralization of Input During Web Page Generation ("Cross-site Scripting")… CWE-79
- CVE-2026-96361 Improper Neutralization of Input During Web Page Generation ("Cross-site Scripting")… CWE-79