Ruby on Rails ActiveSupport SafeBuffer Cross-Site Scripting Vulnerability

Vulnerability

A cross-site scripting (XSS) vulnerability has been identified in the ActiveSupport component of Ruby on Rails. This issue arises in all versions prior to 7.0.4.3 and 6.1.7.3, when the new 'bytesplice' method is used on a SafeBuffer object containing untrusted user input. The vulnerability exists because ActiveSupport's SafeBuffer subclass, which is designed to handle HTML-safe strings, does not properly recognize the 'bytesplice' method as a mutation, leading to potential XSS risks.

Impact

Exploitation of this vulnerability could result in cross-site scripting, allowing an attacker to inject malicious scripts that could be executed in the context of the user's browser.

Reproduction

To reproduce this vulnerability, create a SafeBuffer string marked as HTML-safe. Then, call the 'bytesplice' method on this string, inserting untrusted user input. This will demonstrate how the vulnerability can be exploited by manipulating the SafeBuffer's HTML-safe status without proper sanitization.

Remediation

Users can upgrade to Ruby on Rails versions 7.0.4.3 or 6.1.7.3 to address this vulnerability. For those unable to upgrade immediately, a patch is available for both the 6.1 and 7.0 series.

Added: Jun 9, 2025, 7:46 PM
Updated: Jun 9, 2025, 7:46 PM

Vulnerability Rating

Custom Algorithm
spread
7.6
impact
1.7
exploitability
7.6
remediation
8.3
relevance
0.0
threat
4.8
urgency
2.9
incentive
1.7

Our algorithm analyzes dozens of metrics to generate these 8 key vulnerability categories, which are then combined to calculate the overall risk score.