Executive brief
cpp-httplib is a widely used C++ library that allows applications to handle web traffic (HTTP/HTTPS). A flaw in how the library processes data transfers allows a remote attacker to send a specially crafted request that forces the server to attempt to allocate an impossible amount of memory. This results in an immediate crash of the application, leading to a denial-of-service (DoS) where the service becomes unavailable to legitimate users.
Technical details
The ChunkedDecoder::read_payload function in httplib.h uses std::strtoul() to parse the chunk-size field of HTTP chunked transfer encoding. Because strtoul() performs unsigned wrap-around for negative inputs, a value such as '-2' is interpreted as a near-maximum unsigned long value (e.g., 0xFFFFFFFFFFFFFFFE). While the library explicitly checks for and rejects ULONG_MAX (the result of '-1'), it fails to validate other negative inputs. This causes the server to enter a read loop attempting to consume an extremely large amount of data, leading to unbounded memory allocation (std::bad_alloc) and a process crash. The vulnerability is fixed in version 0.43.4 by ensuring the parser correctly rejects non-hexadecimal characters like the leading minus sign.
Affected products
- yhirose cpp-httplib < 0.43.4
Timeline
- 2026-05-12: advisory: GitHub Security Advisory published
- 2026-05-29: disclosed: CVE-2026-45352 published to NVD