CVE-2024-53986
Nonerails-html-sanitizer has XSS vulnerability with certain configurations
CVSS
—
EPSS
0.5%
Published
Dec 2, 2024
CISA due date
—
Cloudanix analysis
Some Rails applications may fail to clean unsafe user-submitted content, allowing an attacker to make malicious code run in another user’s browser.
- 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
This 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 should be neutralized to survive sanitization and execute in a victim browser. The server-side impact is usually not direct code execution on the application host; the primary technical impact is browser-side script execution in the security context of the affected web application.
Why it matters to the business
Applications that accept and render user-supplied HTML, Markdown, rich text, comments, profile fields, messages, or other formatted content may expose users and administrators to account takeover, data theft, fraudulent actions, defacement, or phishing within the trusted application. The vulnerability is not currently listed in CISA KEV, has no known mature public exploitation in the provided data, and has a low EPSS score, so urgency is lower than actively exploited flaws; however, internet-facing applications that render untrusted content should still prioritize remediation because successful XSS can compromise user sessions and business workflows.
How an attack unfolds
An attacker first identifies a Rails application that uses Rails::HTML::Sanitizer 1.6.0 with Rails 7.1.0 or later and permits user-controlled HTML or formatted text. The attacker submits crafted markup through a feature such as comments, posts, messages, profile fields, tickets, or CMS content. Because of the sanitizer flaw in affected configurations, dangerous content may not be fully removed or escaped. When another user views the stored or reflected content, the browser interprets the malicious markup in the context of the trusted application. The attacker can then perform actions available to the victim, steal exposed tokens or page data, redirect the user, alter displayed content, or chain the browser-side compromise with other weaknesses such as weak session protections or missing Content Security Policy.
How to fix it
Upgrade Rails::HTML::Sanitizer from version 1.6.0 to version 1.6.1 or later. For source-based remediation, use a version containing rails/rails-html-sanitizer commit 5e96b19bbb934284e675109851bd82429622bb6e or a later trusted release. If the listed Ubuntu package is in scope, ensure node-marked on Ubuntu 18.04 LTS is updated to 0.3.9+dfsg-1 or later as specified by the distributor. Regenerate and redeploy dependency lockfiles after updating. Review custom sanitizer allowlists, permitted tags, permitted attributes, and protocol handling, especially where user-supplied HTML is rendered. As defense in depth, apply a restrictive Content Security Policy, avoid inline script execution, mark session cookies HttpOnly and SameSite where feasible, and avoid rendering untrusted HTML unless strictly required.
How to confirm the fix worked
Confirm that dependency manifests and runtime environments no longer contain Rails::HTML::Sanitizer 1.6.0. For Ruby applications, inspect Gemfile.lock, bundle list, bundle info rails-html-sanitizer, and production container or host images to verify rails-html-sanitizer is 1.6.1 or later. Confirm Rails versions are assessed where Rails 7.1.0 or later is in use. Run application tests covering rich-text, Markdown, comments, and other user-content rendering paths to ensure sanitizer behavior remains correct after upgrade. Validate that rendered user content is escaped or sanitized as intended and that CSP headers are present and enforced. For packaged systems, confirm the vendor package version reports node-marked 0.3.9+dfsg-1 or later where applicable.
Typical attack path
- Find a Rails application that renders user-supplied rich text or HTML.
- Confirm the application is likely using Rails::HTML::Sanitizer 1.6.0 with Rails 7.1.0 or later.
- Submit crafted HTML through an input field that is later rendered to users.
- Rely on the vulnerable sanitizer behavior to allow unsafe markup to remain in the rendered output.
- Wait for a victim, moderator, administrator, or other privileged user to view the content.
- Execute JavaScript in the victim browser within the affected application’s origin.
- Use the browser context to steal accessible data, perform unauthorized actions, phish the user, or pivot to other application functionality.
How to detect it
Because no public mature exploit or CVE-specific indicators are provided, detection should focus on evidence of attempted or successful XSS against features that store or render user-supplied content. Review web access logs, application request logs, WAF events, reverse proxy logs, CSP violation reports, browser telemetry if available, and audit logs for content creation or editing. Look for submitted HTML containing script tags, event-handler attributes, unusual SVG or MathML markup, javascript: or data: URI schemes, encoded HTML entities, mixed-case tag evasion, and repeated sanitizer probing. Examine database-backed or file-backed user content for suspicious markup that was created while rails-html-sanitizer 1.6.0 was deployed. Correlate suspicious content with views by privileged users, anomalous account actions, session reuse, unexpected profile or email changes, API token creation, or administrative changes shortly after content was viewed. Also review dependency and deployment history to determine the exposure window for systems that ran rails-html-sanitizer 1.6.0 with Rails 7.1.0 or later.
What your security team should do
- Inventory applications using Rails 7.1.0 or later with rails-html-sanitizer and identify any pinned to version 1.6.0.
- Prioritize internet-facing or multi-user applications that render user-submitted HTML, Markdown, rich text, comments, messages, tickets, or CMS content.
- Upgrade rails-html-sanitizer to 1.6.1 or later and redeploy affected applications after lockfile updates.
- Review sanitizer customization for overly broad allowed tags, attributes, URI schemes, or HTML fragments.
- Add or tighten Content Security Policy to reduce the impact of any residual XSS exposure.
- Search historical logs and stored user-generated content for suspicious HTML, script-like markup, event-handler attributes, javascript: URIs, and unusual CSP violation reports.
- If suspicious content is found, remove it, invalidate affected sessions where appropriate, and investigate victim accounts that viewed the content.
- Track this as lower urgency than known-exploited vulnerabilities, but do not defer remediation for applications with privileged users or externally supplied content.
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-53988 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