CVE-2023-22795
📋 TL;DR
This CVE describes a ReDoS (Regular Expression Denial of Service) vulnerability in Ruby on Rails Action Dispatch. Attackers can send specially crafted HTTP If-None-Match headers to cause catastrophic backtracking in the regex engine, consuming excessive CPU and memory. This affects Ruby on Rails applications running on Ruby versions below 3.2.0.
💻 Affected Systems
- Ruby on Rails Action Dispatch
📦 What is this software?
Rails by Rubyonrails
Rails by Rubyonrails
⚠️ Risk & Real-World Impact
Worst Case
Complete service unavailability due to resource exhaustion, potentially affecting multiple applications on shared infrastructure.
Likely Case
Degraded performance and intermittent service disruptions under attack conditions.
If Mitigated
Minimal impact with proper rate limiting, request filtering, and updated Ruby versions.
🎯 Exploit Status
Exploitation requires crafting specific If-None-Match header values but is straightforward for attackers with basic HTTP knowledge.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: Action Dispatch 6.1.7.1 or 7.0.4.1
Vendor Advisory: https://discuss.rubyonrails.org/t/cve-2023-22795-possible-redos-based-dos-vulnerability-in-action-dispatch/82118
Restart Required: Yes
Instructions:
1. Update Ruby on Rails gem: 'bundle update actionpack' 2. Update Gemfile to specify patched version 3. Restart application server 4. Verify update with 'bundle show actionpack'
🔧 Temporary Workarounds
Upgrade Ruby Version
allUpgrade to Ruby 3.2.0 or later which includes regex engine improvements preventing catastrophic backtracking
rvm install 3.2.0
rbenv install 3.2.0
Request Filtering
allImplement middleware to filter or sanitize If-None-Match headers before they reach Action Dispatch
🧯 If You Can't Patch
- Implement rate limiting and request throttling to limit impact of DoS attempts
- Deploy WAF rules to block malicious If-None-Match header patterns
🔍 How to Verify
Check if Vulnerable:
Check Rails version with 'rails --version' and Ruby version with 'ruby --version'. Vulnerable if Rails <6.1.7.1 or <7.0.4.1 AND Ruby <3.2.0
Check Version:
rails --version && ruby --version
Verify Fix Applied:
Verify Rails version >=6.1.7.1 or >=7.0.4.1 AND/OR Ruby version >=3.2.0
📡 Detection & Monitoring
Log Indicators:
- Spike in CPU/memory usage
- Multiple requests with malformed If-None-Match headers
- Increased request processing times
Network Indicators:
- HTTP requests with unusually long If-None-Match headers
- Repeated requests to same endpoints with varying If-None-Match values
SIEM Query:
source="web_logs" AND (If-None-Match="*{*" OR If-None-Match="*"*" OR If-None-Match="*"*")
🔗 References
- https://discuss.rubyonrails.org/t/cve-2023-22795-possible-redos-based-dos-vulnerability-in-action-dispatch/82118
- https://security.netapp.com/advisory/ntap-20240202-0010/
- https://www.debian.org/security/2023/dsa-5372
- https://discuss.rubyonrails.org/t/cve-2023-22795-possible-redos-based-dos-vulnerability-in-action-dispatch/82118
- https://security.netapp.com/advisory/ntap-20240202-0010/
- https://www.debian.org/security/2023/dsa-5372