CVE-2026-145494 in Hypercorn
Summary
by MITRE • 12/05/2026
Hypercorn through 0.18.0 contains a header spoofing vulnerability in the WSGI wrapper _build_environ that allows remote attackers to spoof trusted headers by conflating underscores and hyphens in environ keys. Attackers can send headers such as x_remote_user through reverse proxies that only strip hyphenated forms, causing applications to read attacker values as trusted headers to spoof authenticated users.
If you want to get best quality of vulnerability data, you may have to visit VulDB.
Analysis
by VulDB Data Team • 12/05/2026
The vulnerability identified in Hypercorn versions up to 0.18.0 represents a critical flaw within the Web Server Gateway Interface wrapper mechanism known as _build_environ. This function is responsible for translating HTTP request data into the environment dictionary expected by WSGI applications, effectively serving as the bridge between the raw network traffic and the application logic. The core technical deficiency lies in how this wrapper processes header keys that contain underscores versus those containing hyphens. In many web server architectures, particularly when operating behind reverse proxies or load balancers, there is a common convention where headers are normalized to use hyphens as separators. However, Python's WSGI specification historically allows for the conversion of hyphens in HTTP header names into underscores within the environ dictionary keys to maintain compatibility with variable naming conventions that do not permit hyphens. Hypercorn’s implementation fails to strictly distinguish between these two formats during this translation process, leading to a conflation where headers sent by clients are treated identically regardless of whether they use underscores or hyphens in their original form.
This lack of strict separation creates an opportunity for header spoofing attacks that exploit the trust relationships established by reverse proxies. In typical deployment scenarios, administrators configure reverse proxies such as Nginx or Apache to strip specific headers from incoming requests before forwarding them to backend applications like Hypercorn. These stripped headers often include sensitive information such as user identity, IP addresses, or authentication tokens, which are then added back into the request environment by the proxy based on its own secure internal state. The vulnerability arises because an attacker can send a header using underscores instead of hyphens in their HTTP request. Since many reverse proxies only strip headers with hyphenated names, they will pass through underscored variants unchecked. Hypercorn subsequently processes these unstripped headers and may map them to the same environ keys as the trusted proxy-added headers due to its flawed normalization logic.
The operational impact of this flaw is severe, primarily facilitating unauthorized access and identity spoofing. By sending specially crafted requests with underscores in header names, remote attackers can inject values into fields that the application believes are populated by a trusted upstream proxy. For instance, if an application relies on the X-Remote-User or HTTP_X_REMOTE_USER environment variable to determine the current user's identity for authorization decisions, an attacker could send an X_Remote_User header with their own username. Because Hypercorn conflates these keys and the reverse proxy did not strip the underscored version due to its naming convention mismatch, the application accepts the attacker-supplied value as legitimate. This allows attackers to bypass authentication mechanisms entirely or escalate privileges by impersonating other users without needing valid credentials for those accounts.
From a classification perspective, this vulnerability aligns with CWE-16: Configuration and CWE-20: Improper Input Validation, specifically relating to the failure to validate input against expected formats and constraints during environment variable construction. It also maps closely to MITRE ATT&CK technique T1557.003, which covers Adversary-in-the-Middle attacks involving header spoofing within lateral movement or initial access phases where trust boundaries are manipulated. The root cause is not merely a coding error but a misconfiguration of security expectations regarding how headers should be normalized and validated relative to proxy behavior.
Mitigation strategies must address both the immediate code flaw and broader architectural assumptions. For organizations using Hypercorn versions prior to 0.18.1, upgrading to the patched version is the primary remediation step as it corrects the header normalization logic in _build_environ to strictly enforce separation between hyphenated and underscored keys or properly validate against a whitelist of allowed headers. Additionally, developers should implement defense-in-depth measures by ensuring that applications do not blindly trust environment variables derived from HTTP headers without additional verification steps such as checking for specific request signatures or using session-based authentication rather than header-based identity alone where possible. Reverse proxy configurations should also be audited to ensure they are stripping all variations of sensitive headers, including those with underscores if the backend application processes them in that format, although relying solely on proxy configuration is insufficient given this specific implementation flaw within Hypercorn itself.