CVE-2026-31870: CWE-248: Uncaught Exception in yhirose cpp-httplib
cpp-httplib is a C++11 single-file header-only cross platform HTTP/HTTPS library. Prior to 0.37.1, when a cpp-httplib client uses the streaming API (httplib::stream::Get, httplib::stream::Post, etc.), the library calls std::stoull() directly on the Content-Length header value received from the server with no input validation and no exception handling. std::stoull throws std::invalid_argument for non-numeric strings and std::out_of_range for values exceeding ULLONG_MAX. Since nothing catches these exceptions, the C++ runtime calls std::terminate(), which kills the process with SIGABRT. Any server the client connects to — including servers reached via HTTP redirects, third-party APIs, or man-in-the-middle positions can crash the client application with a single HTTP response. No authentication is required. No interaction from the end user is required. The crash is deterministic and immediate. This vulnerability is fixed in 0.37.1.
AI Analysis
Technical Summary
The vulnerability CVE-2026-31870 affects cpp-httplib, a popular C++11 single-header HTTP/HTTPS library used for client-server communication. In versions prior to 0.37.1, when using the streaming API methods such as httplib::stream::Get or httplib::stream::Post, the library directly calls std::stoull() on the Content-Length header value received from the server without validating the input or handling exceptions. If the Content-Length header contains a non-numeric string or a numeric value exceeding the maximum unsigned long long integer (ULLONG_MAX), std::stoull throws exceptions (std::invalid_argument or std::out_of_range). Since these exceptions are not caught within the library, the C++ runtime calls std::terminate(), causing the client application to crash immediately with a SIGABRT signal. This behavior can be triggered deterministically by any server response, including those from legitimate servers, redirected endpoints, third-party APIs, or malicious actors performing man-in-the-middle attacks. No authentication or user interaction is required to exploit this vulnerability, making it trivial for attackers to cause denial-of-service conditions on affected client applications. The issue is resolved in cpp-httplib version 0.37.1 by presumably adding input validation and exception handling around the Content-Length parsing logic.
Potential Impact
The primary impact of CVE-2026-31870 is a denial-of-service (DoS) condition caused by client application crashes. Applications using vulnerable versions of cpp-httplib for HTTP streaming can be forced to terminate unexpectedly by sending crafted HTTP responses with malicious Content-Length headers. This can disrupt service availability, degrade user experience, and potentially cause cascading failures in systems relying on these clients. Since the vulnerability can be exploited without authentication or user interaction and can be triggered by any server the client connects to, the attack surface is broad. Organizations integrating cpp-httplib in critical infrastructure, API clients, or embedded systems may face operational interruptions. While there is no direct impact on confidentiality or integrity, the availability impact is significant, especially for high-availability or real-time systems. The lack of known exploits in the wild currently limits immediate risk, but the ease of exploitation and deterministic crash behavior make this a high-risk vulnerability.
Mitigation Recommendations
To mitigate CVE-2026-31870, organizations should upgrade all instances of cpp-httplib to version 0.37.1 or later, where the vulnerability is fixed. If upgrading immediately is not feasible, developers should implement input validation and exception handling around the parsing of the Content-Length header in their client code to catch std::invalid_argument and std::out_of_range exceptions from std::stoull. Additionally, applying network-level controls such as validating HTTP responses from trusted servers, employing TLS with certificate validation to prevent man-in-the-middle attacks, and filtering or sanitizing HTTP headers can reduce exposure. Monitoring client application logs for unexpected crashes and implementing automated restarts or failover mechanisms can help maintain availability. Finally, conducting code reviews and fuzz testing on HTTP header parsing logic in custom integrations can identify similar issues proactively.
Affected Countries
United States, Germany, Japan, South Korea, United Kingdom, France, Canada, Australia, China, India
CVE-2026-31870: CWE-248: Uncaught Exception in yhirose cpp-httplib
Description
cpp-httplib is a C++11 single-file header-only cross platform HTTP/HTTPS library. Prior to 0.37.1, when a cpp-httplib client uses the streaming API (httplib::stream::Get, httplib::stream::Post, etc.), the library calls std::stoull() directly on the Content-Length header value received from the server with no input validation and no exception handling. std::stoull throws std::invalid_argument for non-numeric strings and std::out_of_range for values exceeding ULLONG_MAX. Since nothing catches these exceptions, the C++ runtime calls std::terminate(), which kills the process with SIGABRT. Any server the client connects to — including servers reached via HTTP redirects, third-party APIs, or man-in-the-middle positions can crash the client application with a single HTTP response. No authentication is required. No interaction from the end user is required. The crash is deterministic and immediate. This vulnerability is fixed in 0.37.1.
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The vulnerability CVE-2026-31870 affects cpp-httplib, a popular C++11 single-header HTTP/HTTPS library used for client-server communication. In versions prior to 0.37.1, when using the streaming API methods such as httplib::stream::Get or httplib::stream::Post, the library directly calls std::stoull() on the Content-Length header value received from the server without validating the input or handling exceptions. If the Content-Length header contains a non-numeric string or a numeric value exceeding the maximum unsigned long long integer (ULLONG_MAX), std::stoull throws exceptions (std::invalid_argument or std::out_of_range). Since these exceptions are not caught within the library, the C++ runtime calls std::terminate(), causing the client application to crash immediately with a SIGABRT signal. This behavior can be triggered deterministically by any server response, including those from legitimate servers, redirected endpoints, third-party APIs, or malicious actors performing man-in-the-middle attacks. No authentication or user interaction is required to exploit this vulnerability, making it trivial for attackers to cause denial-of-service conditions on affected client applications. The issue is resolved in cpp-httplib version 0.37.1 by presumably adding input validation and exception handling around the Content-Length parsing logic.
Potential Impact
The primary impact of CVE-2026-31870 is a denial-of-service (DoS) condition caused by client application crashes. Applications using vulnerable versions of cpp-httplib for HTTP streaming can be forced to terminate unexpectedly by sending crafted HTTP responses with malicious Content-Length headers. This can disrupt service availability, degrade user experience, and potentially cause cascading failures in systems relying on these clients. Since the vulnerability can be exploited without authentication or user interaction and can be triggered by any server the client connects to, the attack surface is broad. Organizations integrating cpp-httplib in critical infrastructure, API clients, or embedded systems may face operational interruptions. While there is no direct impact on confidentiality or integrity, the availability impact is significant, especially for high-availability or real-time systems. The lack of known exploits in the wild currently limits immediate risk, but the ease of exploitation and deterministic crash behavior make this a high-risk vulnerability.
Mitigation Recommendations
To mitigate CVE-2026-31870, organizations should upgrade all instances of cpp-httplib to version 0.37.1 or later, where the vulnerability is fixed. If upgrading immediately is not feasible, developers should implement input validation and exception handling around the parsing of the Content-Length header in their client code to catch std::invalid_argument and std::out_of_range exceptions from std::stoull. Additionally, applying network-level controls such as validating HTTP responses from trusted servers, employing TLS with certificate validation to prevent man-in-the-middle attacks, and filtering or sanitizing HTTP headers can reduce exposure. Monitoring client application logs for unexpected crashes and implementing automated restarts or failover mechanisms can help maintain availability. Finally, conducting code reviews and fuzz testing on HTTP header parsing logic in custom integrations can identify similar issues proactively.
Technical Details
- Data Version
- 5.2
- Assigner Short Name
- GitHub_M
- Date Reserved
- 2026-03-09T19:02:25.014Z
- Cvss Version
- 3.1
- State
- PUBLISHED
Threat ID: 69b1b88a2f860ef943602159
Added to database: 3/11/2026, 6:46:34 PM
Last enriched: 3/18/2026, 7:04:56 PM
Last updated: 4/28/2026, 9:23:44 AM
Views: 58
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
External Links
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.