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-2026-33170

CVE-2026-33170: Ruby on Rails Active Support XSS Vulnerability

CVE-2026-33170 is a cross-site scripting vulnerability in Ruby on Rails Active Support that bypasses ERB auto-escaping through SafeBuffer mishandling. This article covers technical details, affected versions, and patches.

Published: March 27, 2026

CVE-2026-33170 Overview

A Cross-Site Scripting (XSS) vulnerability exists in Ruby on Rails Active Support library where SafeBuffer#% does not properly propagate the @html_unsafe flag to newly created buffers. When a SafeBuffer is mutated in place (e.g., via gsub!) and then formatted with % using untrusted arguments, the result incorrectly reports html_safe? == true, bypassing ERB auto-escaping and potentially leading to XSS attacks.

Critical Impact

This vulnerability allows attackers to bypass Rails' built-in XSS protection mechanisms when applications use specific patterns of SafeBuffer manipulation, potentially enabling injection of malicious scripts into web pages rendered by affected Rails applications.

Affected Products

  • Ruby on Rails versions prior to 8.1.2.1
  • Ruby on Rails versions prior to 8.0.4.1
  • Ruby on Rails versions prior to 7.2.3.1

Discovery Timeline

  • 2026-03-24 - CVE CVE-2026-33170 published to NVD
  • 2026-03-24 - Last updated in NVD database

Technical Details for CVE-2026-33170

Vulnerability Analysis

This vulnerability stems from improper state management in the Active Support SafeBuffer class, which is a core component of Rails' XSS protection system. The SafeBuffer class is designed to track whether a string contains HTML-safe content that can be rendered directly without escaping, or potentially unsafe content that should be escaped before output.

The flaw occurs in the % (format) method implementation of SafeBuffer. When a SafeBuffer is first mutated in place using methods like gsub!, the buffer is correctly marked as unsafe via the @html_unsafe flag. However, when the % operator is subsequently used to format the buffer with arguments, the method creates a new SafeBuffer instance but fails to copy the @html_unsafe flag to this new instance.

This oversight causes the newly created buffer to incorrectly report html_safe? == true even when it should be considered unsafe. Since ERB templates in Rails rely on this flag to determine whether to auto-escape content, an attacker can exploit this behavior to inject malicious scripts that bypass the escaping mechanism.

Root Cause

The root cause is a missing state propagation in the SafeBuffer#% method. When creating a new SafeBuffer instance from the formatted string result, the method did not preserve the @html_unsafe (or @html_safe) instance variable from the original buffer. This caused the safety status to be reset to the default safe state, incorrectly marking mutated and potentially dangerous content as safe for rendering.

Attack Vector

An attacker can exploit this vulnerability through a network-based attack requiring user interaction. The attack requires:

  1. The Rails application must use a pattern where a SafeBuffer is mutated in place (using methods like gsub!)
  2. The mutated buffer is then formatted using the % operator with user-controlled arguments
  3. The resulting buffer is rendered in an ERB template without additional escaping

When these conditions are met, an attacker can inject malicious JavaScript or HTML through the user-controlled arguments, which will be rendered unescaped in the victim's browser.

ruby
# Security patch showing the fix for SafeBuffer#% method
# Source: https://github.com/rails/rails/commit/50d732af3b7c8aaf63cbcca0becbc00279b215b7

       new_string = super
       new_safe_buffer = new_string.is_a?(SafeBuffer) ? new_string : SafeBuffer.new(new_string)
       if @html_unsafe
-        new_safe_buffer.instance_variable_set(:@html_unsafe, true)
+        new_safe_buffer.mark_unsafe!
       end
       new_safe_buffer

The patch ensures that when a new SafeBuffer is created via the % operator, the unsafe status is properly propagated using the mark_unsafe! method, maintaining the security state across buffer operations.

Detection Methods for CVE-2026-33170

Indicators of Compromise

  • Unexpected JavaScript execution in Rails application pages that utilize SafeBuffer string formatting
  • XSS payloads appearing in rendered HTML output where ERB auto-escaping should have prevented them
  • Application logs showing unusual string patterns containing script tags or event handlers in formatted output

Detection Strategies

  • Review application code for patterns that combine gsub! or other in-place mutation methods with subsequent % formatting on SafeBuffer objects
  • Implement web application firewall (WAF) rules to detect common XSS payloads in request parameters
  • Conduct security audits of views and helpers that manipulate SafeBuffer objects before rendering

Monitoring Recommendations

  • Enable Content Security Policy (CSP) reporting to detect attempted XSS attacks
  • Monitor application error logs for unexpected HTML or JavaScript content in rendered responses
  • Implement runtime application security testing (RAST) to identify XSS attempts in production environments

How to Mitigate CVE-2026-33170

Immediate Actions Required

  • Upgrade Rails to patched versions 8.1.2.1, 8.0.4.1, or 7.2.3.1 immediately
  • Audit application code for vulnerable SafeBuffer manipulation patterns involving gsub! followed by % formatting
  • Review and test all custom helpers that work with SafeBuffer objects for proper escaping behavior

Patch Information

Ruby on Rails has released security patches for all supported version branches:

  • Rails v8.1.2.1 - For Rails 8.1.x users
  • Rails v8.0.4.1 - For Rails 8.0.x users
  • Rails v7.2.3.1 - For Rails 7.2.x users

For detailed information about this vulnerability, refer to the GitHub Security Advisory GHSA-89vf-4333-qx8v.

Workarounds

  • Explicitly call html_escape or h helper on any SafeBuffer content that has been mutated in place before using with % formatting
  • Avoid using in-place mutation methods like gsub! on SafeBuffer objects that will later be formatted with %
  • Use ERB::Util.html_escape explicitly when working with user-controlled content in SafeBuffer operations
bash
# Update Rails to patched version using Bundler
bundle update rails activesupport --conservative

# Verify the installed version
bundle show rails
# Should show: rails (8.1.2.1), (8.0.4.1), or (7.2.3.1)

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

  • Vulnerability Details
  • TypeXSS

  • Vendor/TechRubyonrails

  • SeverityMEDIUM

  • CVSS Score5.3

  • EPSS Probability0.01%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:L/VA:N/SC:N/SI:N/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
  • IntegrityLow
  • AvailabilityNone
  • CWE References
  • CWE-79
  • Technical References
  • GitHub Release v7.2.3.1

  • GitHub Release v8.0.4.1

  • GitHub Release v8.1.2.1
  • Vendor Resources
  • GitHub Commit Update

  • GitHub Commit Change

  • GitHub Commit Modification

  • GitHub Security Advisory GHSA-89vf-4333-qx8v
  • Related CVEs
  • CVE-2022-32209: Rails Html Sanitizers XSS Vulnerability

  • CVE-2024-53985: Rails HTML Sanitizer 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