Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2024-47887 Overview
CVE-2024-47887 is a Regular Expression Denial of Service (ReDoS) vulnerability in Action Pack, the Ruby on Rails framework component that handles web requests. The flaw resides in Action Controller's HTTP Token authentication logic, specifically in the raw_params method of the Token module. A carefully crafted Authorization header can cause the regular expression used to parse authentication pairs to backtrack excessively, consuming CPU resources and degrading application availability. The issue affects Rails versions from 4.0.0 up to the patched releases 6.1.7.9, 7.0.8.5, 7.1.4.1, and 7.2.1.1. Applications using authenticate_or_request_with_http_token or similar APIs are exposed. Rails 8.0.0.beta1 is unaffected because it requires Ruby 3.2, which mitigates the underlying regex engine behavior.
Critical Impact
Unauthenticated remote attackers can trigger CPU exhaustion by sending a malformed HTTP Token Authorization header, degrading or denying service to the Rails application.
Affected Products
- Ruby on Rails Action Pack >= 4.0.0, < 6.1.7.9
- Ruby on Rails Action Pack >= 7.0.0, < 7.0.8.5 and >= 7.1.0, < 7.1.4.1
- Ruby on Rails Action Pack >= 7.2.0, < 7.2.1.1
Discovery Timeline
- 2024-10-16 - CVE-2024-47887 published to NVD
- 2026-06-17 - Last updated in NVD database
Technical Details for CVE-2024-47887
Vulnerability Analysis
The vulnerability is a ReDoS flaw classified under [CWE-1333: Inefficient Regular Expression Complexity]. Action Controller's HTTP Token authenticator parses the Authorization header by splitting on a regular expression that wraps the pair delimiters with \s* on both sides. When an attacker supplies a header containing long runs of whitespace mixed with delimiter characters, the regex engine performs catastrophic backtracking. Parsing time grows non-linearly with input length, blocking the request thread and consuming CPU. Because HTTP Token authentication is reachable before any business logic, no credentials or user interaction are required to trigger the condition.
Root Cause
The root cause lives in actionpack/lib/action_controller/metal/http_authentication.rb. The raw_params method used the pattern /\s*#{AUTHN_PAIR_DELIMITERS}\s*/ with String#split. The surrounding \s* quantifiers combined with the alternation inside AUTHN_PAIR_DELIMITERS created ambiguous match paths. Ruby versions prior to 3.2 do not optimize this regex, so adversarial input forces exponential-time matching.
Attack Vector
An unauthenticated attacker sends an HTTP request with a crafted Authorization: Token ... header to any Rails endpoint that invokes authenticate_or_request_with_http_token, authenticate_with_http_token, or related helpers. The malicious header is parsed before controller logic runs, so even unauthenticated routes that call the helper are exploitable. Repeated requests amplify the effect and can exhaust worker processes.
# Patched implementation in actionpack/lib/action_controller/metal/http_authentication.rb
# This method takes an authorization body and splits up the key-value
# pairs by the standardized :, ;, or \t delimiters defined in AUTHN_PAIR_DELIMITERS.
def raw_params(auth)
- _raw_params = auth.sub(TOKEN_REGEX, "").split(/\s*#{AUTHN_PAIR_DELIMITERS}\s*/)
+ _raw_params = auth.sub(TOKEN_REGEX, "").split(AUTHN_PAIR_DELIMITERS).map(&:strip)
+ _raw_params.reject!(&:empty?)
if !_raw_params.first&.start_with?(TOKEN_KEY)
_raw_params[0] = "#{TOKEN_KEY}#{_raw_params.first}"
Source: Rails commit 56b2fc3. The fix removes the \s* wrappers from the regex and strips whitespace with String#strip after splitting, eliminating the ambiguous backtracking path.
Detection Methods for CVE-2024-47887
Indicators of Compromise
- Authorization headers containing unusually long sequences of whitespace, commas, semicolons, or tab characters following the Token scheme.
- Rails request logs showing elevated response times or timeouts on endpoints that invoke HTTP Token authentication.
- Spikes in Puma, Unicorn, or Passenger worker CPU utilization correlated with inbound requests to token-authenticated routes.
Detection Strategies
- Inspect reverse proxy or WAF logs for Authorization: Token headers exceeding a reasonable length (for example, 1 KB) or containing repeated delimiter patterns.
- Instrument Rails middleware to record parse duration for the Authorization header and alert on outliers.
- Correlate HTTP 5xx or request timeout bursts with the source IP addresses issuing malformed token headers.
Monitoring Recommendations
- Enable per-request CPU time metrics in the Rails application and export them to a centralized observability platform.
- Monitor the Ruby version in use across production fleets; flag any host running Ruby < 3.2 with vulnerable Rails releases.
- Track dependency inventories for actionpack gem versions and alert when fixed releases are not deployed.
How to Mitigate CVE-2024-47887
Immediate Actions Required
- Upgrade actionpack to 6.1.7.9, 7.0.8.5, 7.1.4.1, or 7.2.1.1 depending on the Rails branch in use.
- If upgrading Rails is not immediately possible, move the application to Ruby 3.2 or newer, which neutralizes the backtracking behavior.
- Apply the upstream patch from the Rails Security Advisory GHSA-vfg9-r3fq-jvx4 to custom forks that cannot be upgraded.
Patch Information
The Rails security team released fixes across multiple maintained branches. The relevant commits are 56b2fc3, 7c13988, 8e057db, and f4dc83d. Each fix replaces the whitespace-wrapped delimiter regex with a plain split followed by String#strip, eliminating the backtracking path.
Workarounds
- Deploy a WAF rule that rejects Authorization headers exceeding a safe length threshold or containing repeated whitespace runs around delimiter characters.
- Enforce a strict request timeout at the web server or reverse proxy layer to limit the impact of slow parsing.
- Temporarily disable HTTP Token authentication on routes where it is not required, pending the upgrade.
# Bundler constraint example to enforce patched Action Pack versions
bundle update actionpack --conservative
# Gemfile pin examples per branch
# gem "actionpack", "~> 6.1.7", ">= 6.1.7.9"
# gem "actionpack", "~> 7.0.8", ">= 7.0.8.5"
# gem "actionpack", "~> 7.1.4", ">= 7.1.4.1"
# gem "actionpack", "~> 7.2.1", ">= 7.2.1.1"
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

