CVE-2025-66570
CVE-2025-66570
Weakness (CWE)
CVSS Vector
v3.1- Attack Vector
- Network
- Attack Complexity
- Low
- Privileges Required
- None
- User Interaction
- None
- Scope
- Changed
- Confidentiality
- High
- Integrity
- High
- Availability
- None
Description
cpp-httplib is a C++11 single-file header-only cross platform HTTP/HTTPS library. Prior to 0.27.0, a vulnerability allows attacker-controlled HTTP headers to influence server-visible metadata, logging, and authorization decisions. An attacker can inject headers named REMOTE_ADDR, REMOTE_PORT, LOCAL_ADDR, LOCAL_PORT that are parsed into the request header multimap via read_headers() in httplib.h (headers.emplace), then the server later appends its own internal metadata using the same header names in Server::process_request without erasing duplicates. Because Request::get_header_value returns the first entry for a header key (id == 0) and the client-supplied headers are parsed before server-inserted headers, downstream code that uses these header names may inadvertently use attacker-controlled values. Affected files/locations: cpp-httplib/httplib.h (read_headers, Server::process_request, Request::get_header_value, get_header_value_u64) and cpp-httplib/docker/main.cc (get_client_ip, nginx_access_logger, nginx_error_logger). Attack surface: attacker-controlled HTTP headers in incoming requests flow into the Request.headers multimap and into logging code that reads forwarded headers, enabling IP spoofing, log poisoning, and authorization bypass via header shadowing. This vulnerability is fixed in 0.27.0.
Comprehensive Technical Analysis of CVE-2025-66570
1. Vulnerability Assessment and Severity Evaluation
CVE ID: CVE-2025-66570 CVSS Score: 10
The vulnerability in cpp-httplib, a C++11 single-file header-only cross-platform HTTP/HTTPS library, allows attacker-controlled HTTP headers to influence server-visible metadata, logging, and authorization decisions. This vulnerability is critical due to its potential for IP spoofing, log poisoning, and authorization bypass, which can lead to severe security breaches. The CVSS score of 10 indicates the highest level of severity, reflecting the potential for significant impact on affected systems.
2. Potential Attack Vectors and Exploitation Methods
Attack Vectors:
- IP Spoofing: An attacker can inject headers such as
REMOTE_ADDRto spoof the client's IP address, making it appear as if the request originated from a different IP. - Log Poisoning: By injecting headers like
REMOTE_PORT,LOCAL_ADDR, andLOCAL_PORT, an attacker can manipulate log entries, making it difficult to trace the actual source of malicious activities. - Authorization Bypass: An attacker can exploit the vulnerability to bypass authorization checks by injecting headers that influence the server's decision-making process.
Exploitation Methods:
- Header Injection: The attacker sends HTTP requests with specially crafted headers that are parsed and stored in the
Request.headersmultimap. - Header Shadowing: The attacker-supplied headers are processed before the server-inserted headers, leading to the use of attacker-controlled values in downstream code.
3. Affected Systems and Software Versions
Affected Software:
- cpp-httplib versions prior to 0.27.0
Affected Files/Locations:
cpp-httplib/httplib.h(functions:read_headers,Server::process_request,Request::get_header_value,get_header_value_u64)cpp-httplib/docker/main.cc(functions:get_client_ip,nginx_access_logger,nginx_error_logger)
4. Recommended Mitigation Strategies
Immediate Actions:
- Upgrade: Upgrade to cpp-httplib version 0.27.0 or later, which includes the fix for this vulnerability.
- Patch Management: Ensure that all systems using cpp-httplib are patched and updated to the latest version.
Long-Term Strategies:
- Input Validation: Implement strict input validation for HTTP headers to prevent injection of malicious values.
- Logging Enhancements: Enhance logging mechanisms to detect and alert on suspicious header values.
- Authorization Checks: Ensure that authorization decisions are based on reliable and verified data sources.
5. Impact on Cybersecurity Landscape
The discovery and exploitation of this vulnerability highlight the importance of secure coding practices and thorough input validation. The potential for IP spoofing, log poisoning, and authorization bypass underscores the need for robust security measures in HTTP/HTTPS libraries. Organizations must prioritize regular updates and patches to mitigate such risks and protect against evolving threats.
6. Technical Details for Security Professionals
Vulnerability Details:
- The vulnerability arises from the way cpp-httplib handles HTTP headers. Attacker-controlled headers are parsed into the
Request.headersmultimap viaread_headers()inhttplib.h. - The server appends its own internal metadata using the same header names in
Server::process_requestwithout erasing duplicates. - The
Request::get_header_valuefunction returns the first entry for a header key (id == 0), leading to the use of attacker-controlled values if they are parsed before server-inserted headers.
Code Analysis:
- read_headers(): Parses incoming HTTP headers and stores them in the
Request.headersmultimap. - Server::process_request: Appends server-internal metadata to the headers without erasing duplicates.
- Request::get_header_value: Returns the first entry for a header key, which can be attacker-controlled if injected before server-inserted headers.
References:
By addressing this vulnerability promptly and implementing robust security measures, organizations can significantly reduce the risk of exploitation and enhance their overall cybersecurity posture.