CVE-2026-34786 Overview
A security header bypass vulnerability exists in Rack, the modular Ruby web server interface. Prior to versions 2.2.23, 3.1.21, and 3.2.6, the Rack::Static#applicable_rules method evaluates header rules against the raw URL-encoded PATH_INFO, while the underlying file-serving path is decoded before the file is served. This discrepancy allows attackers to request URL-encoded variants of static paths to serve files without the security-relevant response headers that header_rules were intended to apply.
Critical Impact
Attackers can bypass security-critical response headers (such as Content-Security-Policy, X-Frame-Options, or X-Content-Type-Options) on static content by requesting URL-encoded path variants, potentially enabling subsequent attacks like XSS or clickjacking.
Affected Products
- Rack versions prior to 2.2.23
- Rack versions prior to 3.1.21
- Rack versions prior to 3.2.6
Discovery Timeline
- 2026-04-02 - CVE CVE-2026-34786 published to NVD
- 2026-04-02 - Last updated in NVD database
Technical Details for CVE-2026-34786
Vulnerability Analysis
This vulnerability stems from an inconsistent handling of URL encoding between path matching and file serving operations within Rack::Static. When header_rules are configured to attach security-relevant HTTP headers to static content, the rules matching logic operates on the raw, URL-encoded PATH_INFO value. However, the actual file-serving mechanism decodes the path before accessing the file system.
This creates a security gap where an attacker can craft a request using URL-encoded characters (e.g., %2F for /, %2E for .) that will bypass the header rule matching while still successfully serving the intended file. The impact is particularly concerning for deployments that rely on Rack::Static to enforce security headers like Content-Security-Policy, X-Frame-Options, X-Content-Type-Options, or custom cache control directives.
Root Cause
The root cause is categorized as CWE-180: Incorrect Behavior Order: Validate Before Canonicalize. The Rack::Static middleware validates header rules against the non-canonical (URL-encoded) form of the path before canonicalizing (decoding) it for file access. This ordering violation means security checks operate on a different representation of the resource than what is ultimately served.
Attack Vector
The attack is network-accessible and requires no authentication or user interaction. An attacker identifies static resources protected by header_rules in a target Rack application. By requesting these resources using URL-encoded path variants, the attacker receives the same file content but without the intended security headers. For example, if /static/script.js is configured to return with Content-Security-Policy headers, requesting /static/%73cript.js (with s encoded as %73) may serve the same JavaScript file without those protective headers.
This bypass is particularly dangerous when combined with other attack vectors. Without proper X-Frame-Options headers, static HTML content becomes susceptible to clickjacking. Without X-Content-Type-Options, browsers may perform MIME sniffing that leads to security issues. Missing Content-Security-Policy headers remove an important defense-in-depth layer.
Detection Methods for CVE-2026-34786
Indicators of Compromise
- Unusual percentage-encoded characters in request paths for static content (e.g., %2F, %2E, or encoded alphanumeric characters)
- Requests for static assets with URL-encoded path segments that resolve to the same files as their decoded equivalents
- Response header inconsistencies where the same static file is served with different header sets depending on URL encoding
Detection Strategies
- Implement web application firewall (WAF) rules to detect and alert on requests containing unnecessary URL encoding in static asset paths
- Configure logging to capture raw request URIs and compare header sets for requests resolving to identical files
- Use SentinelOne Singularity Platform to monitor for anomalous request patterns targeting web application endpoints
Monitoring Recommendations
- Enable detailed access logging to capture URL-encoded request paths before any normalization
- Monitor for sudden increases in requests containing percent-encoded characters for static resources
- Deploy application-layer monitoring to verify that security headers are consistently applied across all static content responses
How to Mitigate CVE-2026-34786
Immediate Actions Required
- Upgrade Rack to version 2.2.23, 3.1.21, or 3.2.6 depending on your current major version
- Audit your Rack::Static configuration to identify any security-critical header_rules that may be affected
- Implement additional header enforcement at the reverse proxy or load balancer level as defense-in-depth
- Review access logs for evidence of exploitation attempts using URL-encoded static asset requests
Patch Information
The Rack maintainers have released patched versions that address this vulnerability by ensuring consistent path handling between rule matching and file serving. The fix normalizes the path before evaluating header_rules, eliminating the encoding discrepancy.
- Rack 2.x users: Upgrade to version 2.2.23 or later
- Rack 3.1.x users: Upgrade to version 3.1.21 or later
- Rack 3.2.x users: Upgrade to version 3.2.6 or later
For full details, see the GitHub Security Advisory.
Workarounds
- Apply security headers at the reverse proxy layer (nginx, Apache, or similar) rather than relying solely on Rack::Static
- Implement middleware that normalizes URL-encoded paths before they reach Rack::Static
- Configure your CDN or edge servers to enforce required security headers for static content, providing an additional layer of protection
# Example nginx configuration to enforce security headers on static content
location /static/ {
add_header X-Frame-Options "DENY" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Content-Security-Policy "default-src 'self'" always;
# Proxy to application or serve directly
}
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


