Mar 24, 2026·5 min read·23 visits
A state-tracking failure in Rails Active Support's `SafeBuffer#%` method permits Cross-Site Scripting (XSS). Destructively mutated strings lose their unsafe flag upon formatting, bypassing ERB auto-escaping and rendering malicious payloads.
CVE-2026-33170 is a Cross-Site Scripting (XSS) vulnerability within the Active Support component of Ruby on Rails. The flaw resides in the `SafeBuffer#%` formatting operator, which fails to correctly propagate internal state regarding HTML safety when creating new string instances. This oversight allows maliciously crafted, destructively mutated strings to bypass Rails' ERB auto-escaping mechanisms, potentially leading to arbitrary JavaScript execution in the context of the user's session.
Ruby on Rails utilizes the ActiveSupport::SafeBuffer class to differentiate between raw strings and strings that have been sanitized for HTML output. When the Rails ERB templating engine encounters a SafeBuffer object marked as safe, it bypasses the standard HTML auto-escaping process to prevent double-encoding.
The SafeBuffer class achieves this by overriding standard Ruby String methods to track whether the contents have been altered by untrusted data. When an application renders templates, the framework calls html_safe? on the output variables. If the object returns true, the framework writes the bytes directly to the response stream without applying HTML entity encoding.
This mechanism relies on strict internal state tracking to ensure that any unsafe mutation to a previously safe string properly flags the object as unsafe. Destructive string methods, such as gsub! or sub!, explicitly toggle an internal @html_unsafe boolean to prevent tainted data from rendering without escaping.
CVE-2026-33170 emerges from a failure to maintain this state during string formatting operations. The SafeBuffer#% method creates a new buffer but fails to inherit the @html_unsafe flag from the parent receiver, permitting malicious input to bypass the auto-escaping design.
The vulnerability stems from the implementation of the string formatting operator (%) within the ActiveSupport::SafeBuffer class. When a developer applies formatting to a SafeBuffer instance, the method intercepts the call to properly escape the provided arguments before interpolation.
After escaping the arguments, the method invokes the parent String#% method to perform the actual interpolation. The result of this interpolation is then wrapped in a completely new SafeBuffer instance to maintain the specialized class type.
Because the new instance is generated via self.class.new(), it defaults to its initial safe state. The method logic explicitly overlooks the @html_unsafe instance variable of the original receiver, failing to propagate it to the newly instantiated object. Consequently, an explicitly unsafe buffer yields a purportedly safe buffer after formatting.
The vulnerable implementation of the % operator constructs the return value without assessing the receiver's state. Any existing mutation warning tracked by @html_unsafe is silently discarded during the instantiation of the new buffer. This logic oversight breaks the chain of trust established by the Active Support framework.
The patch introduced in commit 50d732af3b7c8aaf63cbcca0becbc00279b215b7 rectifies this by explicitly checking the receiver's state and propagating it. The developers added a mark_unsafe! protected helper method to allow internal state synchronization.
# Patched activesupport/lib/active_support/core_ext/string/output_safety.rb
def %(args)
# [..] escaping logic [..]
new_safe_buffer = self.class.new(super(escaped_args))
if @html_unsafe
new_safe_buffer.mark_unsafe!
end
new_safe_buffer
end
protected
def mark_unsafe!
@html_unsafe = true
endThis modification guarantees that if the original buffer was marked unsafe due to prior destructive mutation, the resulting formatted buffer correctly inherits this restriction. The Rails ERB engine will subsequently enforce HTML escaping on the output, neutralizing any embedded malicious scripts.
Exploiting this vulnerability requires a specific sequence of operations on user-controlled input within a Rails application. An attacker must locate an endpoint where a SafeBuffer object undergoes in-place mutation followed by string formatting.
The initial step involves supplying a malicious payload, such as <script>alert(document.cookie)</script>, to an input field. The application must then apply a destructive method, such as gsub!, to the buffer containing this input. This action correctly flags the buffer as @html_unsafe = true.
The exploitation succeeds when the application subsequently formats this buffer using the % operator. The operation strips the unsafe flag, returning a new buffer that reports html_safe? == true to the templating engine.
When the Rails view layer renders this resulting string, the ERB engine reads the erroneous safe status and skips auto-escaping. The raw JavaScript payload is embedded directly into the HTML document and executed by the victim's browser upon page load.
The successful exploitation of this vulnerability yields Cross-Site Scripting (XSS) within the context of the affected application. Because the ERB auto-escaping is fully bypassed, attackers can inject arbitrary HTML and JavaScript into the responses served to end users.
Code execution in the victim's browser enables comprehensive session hijacking, data exfiltration, and unauthorized actions performed on behalf of the user. This aligns with MITRE ATT&CK techniques T1189 (Drive-by Compromise) and T1185 (Browser Session Hijacking).
Attackers often leverage this class of vulnerability to target administrative users, executing actions with elevated privileges. Successful payload delivery requires bypassing any Web Application Firewall (WAF) rules that might detect the initial input string. Because the mutation happens server-side after ingestion, network-level inspection sees only the raw parameters, not the final rendered payload.
The severity is rated Medium (CVSS 5.3) due to the precise code prerequisites required for exploitation. The vulnerability is not a universal bypass; it strictly requires the sequence of destructive mutation followed by string formatting on a single SafeBuffer object.
The primary remediation for CVE-2026-33170 is upgrading the activesupport gem to a patched version. The Rails core team has released versions 7.2.3.1, 8.0.4.1, and 8.1.2.1 to address this vulnerability across all currently supported release branches.
For applications where immediate upgrading is technically unfeasible, developers should audit their codebases for destructive string operations. Searching for methods ending in an exclamation mark (e.g., gsub!, sub!, insert) called on user-controlled data is necessary to identify vulnerable code paths.
Replacing destructive methods with their non-destructive counterparts (e.g., gsub instead of gsub!) acts as an effective workaround. Non-destructive methods correctly handle SafeBuffer state by returning entirely new, properly sanitized string objects rather than mutating existing buffers in place, preventing the specific state desynchronization required for this attack.
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| Product | Affected Versions | Fixed Version |
|---|---|---|
activesupport Rails | < 7.2.3.1 | 7.2.3.1 |
activesupport Rails | >= 8.0.0.beta1, < 8.0.4.1 | 8.0.4.1 |
activesupport Rails | >= 8.1.0.beta1, < 8.1.2.1 | 8.1.2.1 |
| Attribute | Detail |
|---|---|
| CWE ID | CWE-79 |
| Attack Vector | Network |
| CVSS v4.0 | 5.3 (Medium) |
| EPSS Score | 0.0 |
| Exploit Status | None |
| CISA KEV | Not Listed |
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
A local encoding path traversal vulnerability exists in rclone versions from v1.51.0 up to v1.75.0. When non-default local encoding parameters (such as Slash, None, or Raw) are specified, rclone's standard decoder maps safely encoded fullwidth dot-dot characters back into native directory traversal components. Since the local backend historically lacked a post-resolution path containment check, these relative segments resolved outside the designated synchronization root, allowing arbitrary file creation and modification on the host system.
An security bypass vulnerability exists in Nuxt frameworks where route rules containing mixed-case characters are silently dropped during case-insensitive routing. This occurs because lookups are folded to lowercase, but keys are stored in their original casing in the route-matching trie. As a result, critical authorization middleware, such as appMiddleware, is bypassed, allowing unauthorized access to restricted pages.
CVE-2026-71316 is a high-severity vulnerability affecting the Nuxt web development framework in versions 4.4.0 up to (but excluding) 4.5.1. Due to the lack of runtime isolation in the shared server runtime storage driver, unauthenticated remote attackers can query the static-like JSON representation of a route's server-side rendered (SSR) state (_payload.json) and bypass configured page guards and application middleware to obtain highly sensitive user session records.
CVE-2026-71318 is a vulnerability in Nuxt where unauthenticated remote attackers can trigger unauthorized component instantiation and arbitrary HTML element injection. This security flaw is caused by default attribute inheritance (fallthrough) combined with polymorphic root components inside island components accessible via the /__nuxt_island/ endpoint. Attackers can bypass standard routing checks to instantiate globally registered components or inject raw HTML tags like iframes. This vector is highly reachable since it does not require enabling the vue.runtimeCompiler option. It is patched in Nuxt versions 3.21.10 and 4.5.1.
An unauthenticated remote code execution (RCE) vulnerability exists in Nuxt DevTools prior to version 3.3.1. The vulnerability arises from an unauthenticated RPC channel exposed over the Vite Hot Module Replacement (HMR) WebSocket server, allowing an attacker to modify file editor configurations and execute arbitrary commands under the server context.
A highly critical Server-Side Remote Code Execution (RCE) vulnerability exists in the Nuxt framework when Server Islands and the Vue runtime compiler are simultaneously enabled. This allows unauthenticated remote attackers to execute arbitrary system commands on the host process by passing a crafted component definition object to the dynamic component resolution engine via public island endpoints.