The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2024-53985

CVE-2024-53985: Rails HTML Sanitizer XSS Vulnerability

CVE-2024-53985 is an XSS vulnerability in Rails HTML Sanitizer affecting specific configurations with Rails 7.1.0+ and certain Nokogiri versions. This article covers the technical details, affected versions, and mitigation.

Updated: January 22, 2026

CVE-2024-53985 Overview

CVE-2024-53985 is a Cross-Site Scripting (XSS) vulnerability affecting rails-html-sanitizer, the component responsible for sanitizing HTML fragments in Ruby on Rails applications. The vulnerability exists in specific configurations of Rails::HTML::Sanitizer version 1.6.0 when used with Rails >= 7.1.0 and Nokogiri versions prior to 1.15.7, or Nokogiri 1.16.x before 1.16.8.

The flaw allows an attacker to inject malicious content when HTML5 sanitization is enabled and the application developer has overridden the sanitizer's allowed tags to include both "math" and "style" elements, or both "svg" and "style" elements. This vulnerability has been addressed in version 1.6.1.

Critical Impact

Applications using custom sanitizer configurations with specific element combinations may be vulnerable to XSS attacks, potentially allowing attackers to execute arbitrary JavaScript in users' browsers.

Affected Products

  • rubyonrails rails_html_sanitizers version 1.6.0
  • Rails applications >= 7.1.0 using vulnerable sanitizer configurations
  • Nokogiri versions < 1.15.7 or 1.16.x < 1.16.8

Discovery Timeline

  • 2024-12-02 - CVE CVE-2024-53985 published to NVD
  • 2025-08-15 - Last updated in NVD database

Technical Details for CVE-2024-53985

Vulnerability Analysis

This vulnerability represents a Cross-Site Scripting (XSS) flaw within the Rails HTML sanitizer library. The issue arises from improper handling of certain element combinations during the HTML5 sanitization process. Specifically, when application developers customize the sanitizer's allowed tags to permit both mathematical or vector graphics elements alongside style elements, the sanitizer fails to adequately prevent malicious content injection.

The attack requires a network-accessible vector where user interaction is necessary for exploitation. While the vulnerability has limited direct impact on the vulnerable system itself, it can affect the confidentiality and integrity of the downstream user's session or data.

Root Cause

The root cause stems from insufficient input validation when the Rails HTML sanitizer processes HTML5 content with specific tag combinations. When both "math" and "style" elements or both "svg" and "style" elements are allowed in the sanitizer configuration, an attacker can craft malicious HTML that bypasses sanitization controls. The issue specifically affects the interplay between these special-purpose elements that have unique parsing behaviors in HTML5 contexts.

Attack Vector

The attack is executed over the network and requires specific application configurations to be vulnerable. An attacker must target a Rails application where:

  1. HTML5 sanitization is explicitly enabled
  2. The developer has customized the allowed tags to include the specific vulnerable combinations
  3. User-supplied HTML content is processed through the sanitizer and rendered

The attacker crafts malicious HTML content containing specially structured "math" or "svg" elements combined with "style" elements that exploit the sanitizer's parsing behavior to inject executable JavaScript.

When the sanitizer processes this input under the vulnerable configuration, the malicious content passes through and is rendered in the victim's browser, leading to XSS execution.

Detection Methods for CVE-2024-53985

Indicators of Compromise

  • Unusual HTML content in user submissions containing nested "math", "svg", or "style" elements
  • Web application logs showing attempts to submit crafted HTML with mathematical notation or SVG markup combined with style tags
  • Client-side JavaScript errors or unexpected script execution in browser developer consoles
  • Reports of suspicious user session behavior or unauthorized actions

Detection Strategies

  • Review application code for custom sanitizer configurations that allow both "math" and "style" or "svg" and "style" elements
  • Implement web application firewall (WAF) rules to detect and block HTML submissions with suspicious element combinations
  • Monitor application logs for patterns indicative of XSS attempts targeting sanitizer bypass
  • Conduct regular security audits of Rails applications using rails-html-sanitizer

Monitoring Recommendations

  • Enable verbose logging for HTML sanitization operations to capture input and output content
  • Implement Content Security Policy (CSP) headers to mitigate XSS impact and generate violation reports
  • Set up alerts for anomalous user-generated content submissions containing SVG or math elements
  • Monitor gem dependencies for version changes and security advisories

How to Mitigate CVE-2024-53985

Immediate Actions Required

  • Upgrade rails-html-sanitizer to version 1.6.1 or later immediately
  • Upgrade Nokogiri to version 1.15.7 or later, or 1.16.8 or later for the 1.16.x branch
  • Review and audit custom sanitizer configurations for vulnerable element combinations
  • Remove "math" and "style" or "svg" and "style" from allowed tags if not strictly required

Patch Information

The vulnerability has been fixed in rails-html-sanitizer version 1.6.1. Security patches have been committed to the repository:

  • Security patch commit b0220b8
  • Security patch commit cd18b0e

For detailed information, refer to the GitHub Security Advisory GHSA-w8gc-x259-rc7x.

Workarounds

  • If upgrading is not immediately possible, remove "style" from allowed tags in custom sanitizer configurations
  • Avoid using both "math" and "style" or "svg" and "style" elements together in allowed tag lists
  • Implement additional server-side input validation for HTML content before sanitization
  • Use Content Security Policy headers to restrict inline script execution as a defense-in-depth measure
bash
# Update rails-html-sanitizer in your Gemfile
bundle update rails-html-sanitizer

# Verify the installed version
bundle info rails-html-sanitizer

# Update Nokogiri to a patched version
bundle update nokogiri

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeXSS

  • Vendor/TechRubyonrails

  • SeverityLOW

  • CVSS Score2.3

  • EPSS Probability1.20%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityNone
  • CWE References
  • CWE-79
  • Vendor Resources
  • GitHub Commit Update

  • GitHub Commit Update

  • GitHub Security Advisory
  • Related CVEs
  • CVE-2026-33170: Ruby on Rails Active Support XSS Vulnerability

  • CVE-2022-32209: Rails Html Sanitizers XSS Vulnerability

  • CVE-2024-53986: Rails HTML Sanitizer XSS Vulnerability

  • CVE-2024-26143: Ruby on Rails Translation Helper XSS Flaw
Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English