/

CVE-2026-126080

Severity:

HIGH RISK

(7.5)

Regex Injection (CWE-74) in Rails Active Support Inflector

CVE-2026-126080

Awaiting Analysis

Vulnerability type

Category:

Regular Expression Injection

CWE:

CWE-74

Impact:

Denial of Service

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Active Support's safe_constantize can build a regular expression from an unescaped constant name when constant lookup raises LoadError. If untrusted input reaches this code, crafted patterns may trigger defects in Ruby's regular expression compiler and crash the server process.

Affected context

The issue affects Rails applications using affected Active Support behavior when constant lookup raises LoadError and the requested constant name is used to build a regular expression without escaping. Action Cable can expose this path by passing a channel value from a subscribe command to safe_constantize; reachability depends on the application mounting Action Cable and accepting connections from untrusted clients without an additional authentication check.

Exploit preconditions

  • Attack surface: An application path that invokes Active Support's safe_constantize with a value that can be influenced by a client
  • Required access: For the Action Cable path, an unauthenticated connection may be sufficient if the application accepts untrusted clients without an added authentication check
  • Trigger point: Constant lookup raises LoadError, causing the requested name to be used in regular-expression construction
  • Why exploitation is possible: The name is not escaped before it becomes part of the pattern, allowing crafted input to affect the expression compiled by Ruby

Why this happens

The underlying bug is failure to neutralize regular-expression metacharacters in data used to construct a pattern. When safe_constantize handles a LoadError, it builds a regular expression using the requested constant name without escaping it. This is an injection weakness associated with CWE-74: Improper Neutralization of Special Elements in Output Used by a Downstream Component.

Potential impact

  • Crafted input may trigger a defect in Ruby's regular-expression compiler
  • The affected request may crash the server process
  • Repeated requests could keep the application unavailable

General mitigation guidance

Defensive approaches focus on preventing untrusted values from controlling regular-expression syntax and limiting the effect of failures.

  • Escape user-controlled text before incorporating it into regular expressions, or avoid constructing patterns from such text
  • Prefer explicit allowlists for values that select constants or channels
  • Authenticate and authorize clients before processing sensitive Action Cable subscription operations
  • Handle parsing and lookup failures in a way that limits their effect on application availability
  • Apply resource and process isolation appropriate to the service's availability requirements

How teams detect issues like this

  • Use static analysis to identify regular expressions constructed from untrusted values without escaping
  • Review safe_constantize and similar lookup calls for inputs originating from requests, channel messages, or other external sources
  • Test error paths in which constant lookup raises LoadError, including their behavior under malformed input
  • Enforce code-review or CI policies that require escaping or allowlisting when dynamic patterns are used
  • Monitor for repeated request failures or unexpected server process restarts

Sources

SourceLink
github.comgithub.com/rails/rails/commit/210ac22d446c8e2625b091e79256806b836eee20
github.comgithub.com/rails/rails/commit/95aa9e416016524956d4904fed96eaed079580bb
github.comgithub.com/rails/rails/releases/tag/v8.0.5.2
github.comgithub.com/rails/rails/releases/tag/v8.1.4.1
github.comgithub.com/rails/rails/security/advisories/GHSA-8474-xrp6-wh69

Frequently asked

questions

It may be reachable remotely when an application exposes the affected code to client-controlled input. In Action Cable, reachability depends on the application accepting untrusted connections without an additional authentication check.

The required access depends on the application's exposure and controls. For the described Action Cable path, an unauthenticated client may be able to reach the code under the stated conditions.

Avoid allowing untrusted input to define regular-expression syntax. Escape dynamic text or use strict allowlists for values used in constant or channel lookup.

Trace external input into dynamic pattern construction, test error-handling paths, and enforce review or automated checks for unescaped input in regular expressions.

Find out what's already
exploitable in your codebase.