CVE-2022-23633 Overview
CVE-2022-23633 is an Information Leakage vulnerability in Ruby on Rails Action Pack framework. Under certain circumstances, response bodies are not properly closed, which prevents ActionDispatch::Executor from being notified of the close event. When this occurs, the executor fails to reset thread local state for subsequent requests, potentially allowing sensitive data from one request to leak to subsequent requests handled by the same thread.
This vulnerability affects multiple versions of Ruby on Rails across the 5.x, 6.x, and 7.x branches. The issue is particularly concerning in multi-threaded application server environments where thread reuse is common, such as Puma.
Critical Impact
Sensitive user data including session information, authentication tokens, and request-specific variables may leak between unrelated requests, potentially exposing private information to unauthorized users.
Affected Products
- Ruby on Rails versions prior to 7.0.2.1
- Ruby on Rails versions 6.1.x prior to 6.1.4.5
- Ruby on Rails versions 6.0.x prior to 6.0.4.5
- Ruby on Rails versions 5.2.x prior to 5.2.6.1
- Debian Linux 10.0 and 11.0
Discovery Timeline
- February 11, 2022 - CVE-2022-23633 published to NVD
- November 21, 2024 - Last updated in NVD database
Technical Details for CVE-2022-23633
Vulnerability Analysis
The vulnerability exists in how Action Pack's ActionDispatch::Executor middleware handles response body lifecycle management. In Ruby on Rails, the Executor is responsible for managing thread-local state between requests, ensuring proper isolation of request data. The Executor relies on receiving a close notification from response bodies to trigger cleanup of thread-local variables.
When certain types of responses are generated—particularly those involving streaming, certain middleware configurations, or specific response types—the response body may not properly signal closure to the Executor. Without this notification, thread-local state persists and becomes accessible to subsequent requests processed by the same thread.
This behavior creates a race condition where sensitive data stored in thread-local variables from one user's request could leak to a completely different user's subsequent request. The attack requires no special privileges and can be triggered remotely through normal HTTP requests, though successful exploitation depends on specific timing conditions related to thread reuse in the application server.
Root Cause
The root cause lies in the improper handling of response body closure notifications in the ActiveSupport::Reloader class. The run! method did not properly account for scenarios where thread state needed to be reset even when the standard check did not pass. The fix introduces a reset parameter to explicitly control when thread-local state should be cleared, ensuring proper cleanup regardless of the response body closure status.
Attack Vector
An attacker can exploit this vulnerability through network-based requests to a vulnerable Rails application. The attack scenario involves:
- A legitimate user makes a request containing sensitive data (authentication tokens, session information, form data)
- The response body fails to properly close, leaving thread-local state intact
- An attacker's subsequent request is routed to the same thread
- The attacker's request can potentially access the residual thread-local data from the previous user's request
The vulnerability is exploitable without authentication and requires no user interaction, though successful exploitation depends on thread scheduling and timing factors controlled by the application server.
prepare!
end
- def self.run! # :nodoc:
+ def self.run!(reset: false) # :nodoc:
if check!
super
else
Source: GitHub Rails Commit Details
The patch adds a reset parameter to the run! method, allowing explicit control over when thread-local state should be cleared, ensuring proper cleanup even when the standard check conditions are not met.
Detection Methods for CVE-2022-23633
Indicators of Compromise
- Unusual session data appearing in application logs that doesn't match the current user context
- User reports of seeing other users' data or authenticated content in their responses
- Application logs showing thread-local variable state inconsistencies
- Unexpected authentication bypass incidents where users gain access to resources belonging to other users
Detection Strategies
- Monitor application logs for data leakage patterns such as mismatched user IDs in request/response cycles
- Implement request correlation tracking to detect when response data doesn't match request origins
- Review application server thread pool configurations and monitor thread reuse patterns
- Deploy application-level instrumentation to track thread-local variable lifecycle
Monitoring Recommendations
- Enable verbose logging for ActionDispatch::Executor and related middleware components
- Configure application performance monitoring (APM) tools to track request isolation boundaries
- Set up alerts for authentication anomalies where user context changes unexpectedly within a session
- Monitor for unusual patterns in response body sizes or content that may indicate data leakage
How to Mitigate CVE-2022-23633
Immediate Actions Required
- Upgrade Ruby on Rails to patched versions: 7.0.2.1, 6.1.4.5, 6.0.4.5, or 5.2.6.1 immediately
- If immediate upgrade is not possible, implement the workaround middleware described in the security advisory
- Review application logs for any indicators of prior exploitation
- Consider temporarily reducing thread pool sizes to minimize exposure until patching is complete
Patch Information
Security patches are available in the following Rails versions:
- Rails 7.0.2.1 for Rails 7.0.x users
- Rails 6.1.4.5 for Rails 6.1.x users
- Rails 6.0.4.5 for Rails 6.0.x users
- Rails 5.2.6.1 for Rails 5.2.x users
The fix is documented in commit f9a2ad03943d5c2ba54e1d45f155442b519c75da. For detailed patch information, refer to the GitHub Security Advisory GHSA-wh98-p28r-vrc9.
Debian users should apply updates via Debian Security Announcement DSA-5372 or the Debian LTS Announcement.
Workarounds
- Deploy the workaround middleware described in the GitHub Security Advisory GHSA-wh98-p28r-vrc9
- Reduce application server thread pool sizes to limit thread reuse opportunities
- Consider switching to process-based request handling temporarily to eliminate thread-local state sharing
- Implement additional response body cleanup middleware to ensure proper closure notification
# Workaround middleware configuration
# Add to config/application.rb before upgrading Rails
# See GHSA-wh98-p28r-vrc9 for the complete middleware implementation
config.middleware.insert_before(
ActionDispatch::Executor,
WorkaroundMiddleware
)
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


