CVE-2026-33170: CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in rails activesupport
CVE-2026-33170 is a cross-site scripting (XSS) vulnerability in the Rails framework's ActiveSupport library, specifically in the SafeBuffer class used for HTML-safe string handling. The flaw arises because the @html_unsafe flag is not correctly propagated when the SafeBuffer is mutated in place and then formatted with the % operator using untrusted input. This causes the resulting string to be incorrectly marked as HTML safe, bypassing ERB auto-escaping and enabling potential XSS attacks. The vulnerability affects ActiveSupport versions prior to 8. 1. 2. 1, 8. 0. 4. 1, and 7.
AI Analysis
Technical Summary
This vulnerability, identified as CVE-2026-33170, affects the ActiveSupport component of the Ruby on Rails framework, which provides core extensions and support libraries. The issue lies in the SafeBuffer class, which is designed to handle HTML-safe strings to prevent cross-site scripting (XSS) by marking strings as safe or unsafe for HTML rendering. Prior to the patched versions (8.1.2.1, 8.0.4.1, and 7.2.3.1), when a SafeBuffer instance is mutated in place using methods like gsub! and then formatted with the % operator using untrusted input, the internal @html_unsafe flag is not correctly propagated to the new buffer. Consequently, the resulting string incorrectly reports html_safe? as true, causing ERB templates to skip auto-escaping. This flaw allows attackers to inject malicious scripts into web pages, leading to XSS attacks. The vulnerability does not require authentication but does require user interaction (e.g., a victim visiting a crafted URL or submitting malicious input). The flaw is rooted in improper neutralization of input during web page generation, classified under CWE-79. Although no known exploits are currently reported in the wild, the risk remains significant due to the widespread use of Rails in web applications. The CVSS 4.0 vector indicates network attack vector, low attack complexity, no privileges required, user interaction required, and low impact on integrity, with no impact on confidentiality or availability. The patch fixes the propagation of the @html_unsafe flag to ensure that mutated SafeBuffer instances are correctly marked unsafe when appropriate, restoring proper auto-escaping behavior.
Potential Impact
The primary impact of this vulnerability is the potential for cross-site scripting (XSS) attacks, which can lead to the execution of arbitrary JavaScript in the context of a vulnerable web application. This can result in session hijacking, credential theft, defacement, or redirection to malicious sites. Since Rails is widely used for web application development globally, many organizations could be affected if they use vulnerable versions of ActiveSupport. The vulnerability can be exploited remotely without authentication but requires user interaction, such as clicking a malicious link or submitting crafted input. The impact on confidentiality and availability is minimal, but the integrity of the web content and user trust can be significantly compromised. Exploitation could also facilitate further attacks such as phishing or malware distribution. Organizations relying on vulnerable Rails versions for customer-facing applications or internal tools are at risk of reputational damage and potential regulatory consequences if user data is compromised.
Mitigation Recommendations
Organizations should immediately upgrade to the patched versions of ActiveSupport: 8.1.2.1, 8.0.4.1, or 7.2.3.1 or later. In addition to upgrading, developers should audit their codebases for any in-place mutations of SafeBuffer objects followed by formatting with the % operator, especially when untrusted input is involved. Avoid mutating SafeBuffer instances in place or ensure that any such mutations do not bypass HTML escaping mechanisms. Implement strict input validation and sanitization on all user-supplied data before it reaches the rendering layer. Employ Content Security Policy (CSP) headers to mitigate the impact of potential XSS attacks by restricting script execution sources. Conduct thorough security testing, including automated scanning and manual code reviews focused on template rendering and string handling. Monitor application logs for unusual input patterns or errors related to string formatting. Finally, educate developers about safe handling of HTML-safe strings and the risks of bypassing Rails' built-in escaping.
Affected Countries
United States, United Kingdom, Germany, France, Japan, India, Australia, Canada, Netherlands, Brazil, South Korea, Singapore
CVE-2026-33170: CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') in rails activesupport
Description
CVE-2026-33170 is a cross-site scripting (XSS) vulnerability in the Rails framework's ActiveSupport library, specifically in the SafeBuffer class used for HTML-safe string handling. The flaw arises because the @html_unsafe flag is not correctly propagated when the SafeBuffer is mutated in place and then formatted with the % operator using untrusted input. This causes the resulting string to be incorrectly marked as HTML safe, bypassing ERB auto-escaping and enabling potential XSS attacks. The vulnerability affects ActiveSupport versions prior to 8. 1. 2. 1, 8. 0. 4. 1, and 7.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
This vulnerability, identified as CVE-2026-33170, affects the ActiveSupport component of the Ruby on Rails framework, which provides core extensions and support libraries. The issue lies in the SafeBuffer class, which is designed to handle HTML-safe strings to prevent cross-site scripting (XSS) by marking strings as safe or unsafe for HTML rendering. Prior to the patched versions (8.1.2.1, 8.0.4.1, and 7.2.3.1), when a SafeBuffer instance is mutated in place using methods like gsub! and then formatted with the % operator using untrusted input, the internal @html_unsafe flag is not correctly propagated to the new buffer. Consequently, the resulting string incorrectly reports html_safe? as true, causing ERB templates to skip auto-escaping. This flaw allows attackers to inject malicious scripts into web pages, leading to XSS attacks. The vulnerability does not require authentication but does require user interaction (e.g., a victim visiting a crafted URL or submitting malicious input). The flaw is rooted in improper neutralization of input during web page generation, classified under CWE-79. Although no known exploits are currently reported in the wild, the risk remains significant due to the widespread use of Rails in web applications. The CVSS 4.0 vector indicates network attack vector, low attack complexity, no privileges required, user interaction required, and low impact on integrity, with no impact on confidentiality or availability. The patch fixes the propagation of the @html_unsafe flag to ensure that mutated SafeBuffer instances are correctly marked unsafe when appropriate, restoring proper auto-escaping behavior.
Potential Impact
The primary impact of this vulnerability is the potential for cross-site scripting (XSS) attacks, which can lead to the execution of arbitrary JavaScript in the context of a vulnerable web application. This can result in session hijacking, credential theft, defacement, or redirection to malicious sites. Since Rails is widely used for web application development globally, many organizations could be affected if they use vulnerable versions of ActiveSupport. The vulnerability can be exploited remotely without authentication but requires user interaction, such as clicking a malicious link or submitting crafted input. The impact on confidentiality and availability is minimal, but the integrity of the web content and user trust can be significantly compromised. Exploitation could also facilitate further attacks such as phishing or malware distribution. Organizations relying on vulnerable Rails versions for customer-facing applications or internal tools are at risk of reputational damage and potential regulatory consequences if user data is compromised.
Mitigation Recommendations
Organizations should immediately upgrade to the patched versions of ActiveSupport: 8.1.2.1, 8.0.4.1, or 7.2.3.1 or later. In addition to upgrading, developers should audit their codebases for any in-place mutations of SafeBuffer objects followed by formatting with the % operator, especially when untrusted input is involved. Avoid mutating SafeBuffer instances in place or ensure that any such mutations do not bypass HTML escaping mechanisms. Implement strict input validation and sanitization on all user-supplied data before it reaches the rendering layer. Employ Content Security Policy (CSP) headers to mitigate the impact of potential XSS attacks by restricting script execution sources. Conduct thorough security testing, including automated scanning and manual code reviews focused on template rendering and string handling. Monitor application logs for unusual input patterns or errors related to string formatting. Finally, educate developers about safe handling of HTML-safe strings and the risks of bypassing Rails' built-in escaping.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2026-03-17T21:17:08.888Z
- Cvss Version
- 4.0
- State
- PUBLISHED
Threat ID: 69c1d4a9f4197a8e3ba0b46f
Added to database: 3/24/2026, 12:02:49 AM
Last enriched: 3/24/2026, 12:05:50 AM
Last updated: 3/24/2026, 5:19:14 AM
Views: 4
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.