CVE-2024-25622
Executive Summary
CVE-2024-25622 is a configuration inheritance vulnerability in the h2o HTTP server. The flaw resides in the headers handler configuration directives. When a user defines header modification rules in an inner scope (e.g., path level), the server incorrectly discards all header directives defined in outer scopes (e.g., global level). This breaks the expected configuration inheritance model, potentially leading to unintended HTTP response headers being sent to clients. While the CVSS score is low (3.1) due to the high complexity and limited direct impact, the vulnerability can cause subtle client-side misbehavior, such as incorrect caching, security header omission, or unexpected redirects. The patch is available in the h2o repository, but no official release version has been tagged as fixed.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability affects the h2o HTTP server, which is distributed as source code and via package managers for various Linux distributions. Users relying on pre-packaged versions (e.g., from Debian, Ubuntu, or Homebrew) may be vulnerable until their distribution updates the package. No known malicious packages or backdoors have been reported in relation to this CVE.
CVSS Breakdown & Threat Level
- CVSS Score: 3.1 (Low)
- Vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:N
- Attack Vector: Network
- Attack Complexity: High (requires specific configuration and understanding of scope inheritance)
- Privileges Required: None
- User Interaction: None
- Scope: Unchanged
- Confidentiality Impact: None
- Integrity Impact: Low (unexpected header modifications)
- Availability Impact: None
Threat Level: Low. Exploitation requires the attacker to influence the server's configuration (e.g., via a compromised admin or a misconfigured deployment). The impact is limited to unexpected header behavior, not direct data breach or service disruption.
Deep Dive & Mechanics
The h2o server uses a hierarchical configuration model with scopes (global, host, path, etc.). Inner scopes are expected to inherit and merge configuration from outer scopes. The headers directive allows operators to add, set, or remove HTTP response headers.
Vulnerability Mechanism:
When a header directive is defined in an inner scope (e.g., path /api), the server's configuration parser incorrectly resets the entire header configuration for that scope, discarding any header directives from outer scopes (e.g., global header set X-Frame-Options DENY). This means that if an admin sets security headers globally but then adds a path-specific header, the global security headers are lost for that path.
Example Scenario:
- Global scope:
header set X-Content-Type-Options "nosniff" - Path scope
/downloads:header set Content-Disposition "attachment" - Expected: Both headers are sent for
/downloads. - Actual: Only
Content-Dispositionis sent;X-Content-Type-Optionsis missing.
This can lead to:
- Bypass of security headers (e.g., CSP, HSTS, X-Frame-Options).
- Incorrect caching behavior due to missing
Cache-Controlheaders. - Unexpected client-side behavior (e.g., MIME type sniffing).
Vulnerable vs. Patched Code
Vulnerable Code (simplified):
// In configuration parsing for headers directive
void apply_headers_config(h2o_configurator_t *conf, h2o_headers_command_t *cmd) {
// This function replaces the entire header list for the scope
conf->headers = cmd; // Overwrites inherited headers
}
Patched Code (from commit 123f5e2b65dcdba8f7ef659a00d24bd1249141be):
// Patched version merges instead of replaces
void apply_headers_config(h2o_configurator_t *conf, h2o_headers_command_t *cmd) {
// Merge new commands with inherited ones
h2o_headers_command_t *inherited = conf->headers;
if (inherited == NULL) {
conf->headers = cmd;
} else {
// Append cmd to the end of inherited list
h2o_headers_command_t *last = inherited;
while (last->next != NULL) last = last->next;
last->next = cmd;
}
}
The patch ensures that header directives from outer scopes are preserved and merged with inner scope directives, rather than being overwritten.
Exploitation & Lab Setup
Red Team (Attack Simulation)
Prerequisites:
- Access to modify h2o configuration file (e.g., via compromised admin account or misconfigured CI/CD).
- Target server running vulnerable h2o version.
Exploitation Steps:
- Identify a path where the admin has defined a custom header (e.g.,
/apiwithheader set Access-Control-Allow-Origin *). - Verify that global security headers (e.g.,
X-Frame-Options,CSP) are missing on that path. - Craft a client request to that path and observe the missing headers.
- Use this to bypass security controls (e.g., clickjacking via missing
X-Frame-Options).
Example curl command:
curl -v http://target.example.com/api
# Look for missing security headers
No known public exploit code exists.
Blue Team (Defense & Detection)
Detection:
- Monitor for configuration changes to h2o config files.
- Use the Sigma rule below to detect missing security headers in responses.
- Regularly audit h2o configuration for scope inheritance issues.
Mitigation:
- Apply the patch from commit 123f5e2b65dcdba8f7ef659a00d24bd1249141be.
- As a workaround, avoid using header directives in inner scopes; define all headers globally.
- Use a reverse proxy (e.g., Nginx) to enforce security headers independently.
Indicators of Compromise (IOCs)
- Configuration Anomaly: h2o config files where header directives are defined in path-level scopes without corresponding global headers.
- HTTP Response Headers: Missing expected security headers (e.g.,
X-Content-Type-Options,X-Frame-Options,Content-Security-Policy) on specific paths. - Server Version: h2o versions prior to commit 123f5e2b65dcdba8f7ef659a00d24bd1249141be (no official release version).
Detection Engineering
YARA Rule
rule CVE_2024_25622_h2o_header_inheritance {
meta:
description = "Detects h2o configuration files with potential header inheritance vulnerability"
author = "Valters IT"
date = "2024-02-20"
cve = "CVE-2024-25622"
strings:
$header_directive = /header\s+(set|add|remove|append|unset)\s+/ nocase
$scope_path = /path\s+/ nocase
condition:
#header_directive > 0 and #scope_path > 0
}
Sigma Rule
title: Missing Security Headers in h2o Response
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects HTTP responses from h2o servers missing expected security headers, indicating possible CVE-2024-25622 exploitation
author: Valters IT
logsource:
category: web
product: h2o
detection:
selection:
response_headers|contains|all:
- 'X-Content-Type-Options'
- 'X-Frame-Options'
- 'Content-Security-Policy'
condition: not selection
falsepositives:
- Intentional removal of headers by administrator
level: medium
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-25622 - Missing Security Headers in h2o Response"; flow:to_client; content:"HTTP/"; http_response_line; content:!"X-Content-Type-Options"; http_header_names; content:!"X-Frame-Options"; http_header_names; content:!"Content-Security-Policy"; http_header_names; sid:1000001; rev:1;)
Remediation & Mitigation
- Immediate Patch: Update h2o to the latest commit (123f5e2b65dcdba8f7ef659a00d24bd1249141be) or wait for an official release.
- Configuration Workaround: Avoid using
headerdirectives in inner scopes. Define all headers globally. - Defense in Depth: Use a reverse proxy (e.g., Nginx, HAProxy) to enforce security headers independently of h2o.
- Monitoring: Implement the Sigma and Suricata rules above to detect missing headers.
- Audit: Regularly review h2o configuration files for scope inheritance issues.
Valters IT
Securing Digital Frontiers