/

CVE-2026-45372

Severity:

CRITICAL RISK

(9.9)

HTTP Response Splitting / Header Injection in cpp-httplib

CVE-2026-45372

Modified

Vulnerability type

Category:

HTTP Response Splitting / Header Injection

CWE:

CWE-93, CWE-444

Impact:

HTTP Response Splitting and Header Injection

Severity:

CRITICAL RISK

(9.9)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

cpp-httplib's server implementation applies percent-decoding to most header values only after performing validity checks, allowing encoded CRLF sequences (%0D%0A) to bypass field validation.

An attacker who can supply crafted HTTP headers may inject raw CRLF bytes into stored header values, enabling HTTP response splitting and header injection in applications built on cpp-httplib.

Affected context

This vulnerability affects applications using cpp-httplib's server component to accept and process HTTP requests, where:

  • User-controlled input is copied into HTTP headers in responses or proxied downstream
  • The server relies on cpp-httplib's internal header validation for safety
  • Headers (other than Location and Referer) undergo percent-decoding after validation

In such setups, an attacker-controlled request header that includes encoded CRLF sequences can be stored and later reflected or reused by the application.

Exploit preconditions

  • Attack surface: HTTP(S) server endpoints implemented with cpp-httplib.
  • Required access: Ability to send crafted HTTP requests, including custom headers, to the server (typically unauthenticated network access).
  • Trigger point: The server's request parsing logic percent-decodes header values after running is_field_value validation, allowing %0D%0A to become \r\n within stored header values.
  • Why exploitation is possible: Validation is performed on the encoded representation, not the decoded content, so CRLF injection is not detected and can be propagated into HTTP responses or downstream requests, leading to response splitting or header injection.

Why this happens

The underlying bug is a classic input canonicalization and validation ordering problem mapped to CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection').

cpp-httplib validates header values using is_field_value on the raw, percent-encoded string, then percent-decodes it afterward for most headers. Because %0D%0A passes validation yet decodes into \r\n, untrusted header values can contain embedded line breaks.

This creates a condition where user-controlled input can terminate or extend HTTP headers, aligning with HTTP response splitting and related header injection behaviors (also associated with CWE-444 for improper handling of HTTP requests).

Potential impact

  • Attackers may inject additional HTTP response headers by breaking the header section with injected CRLF sequences.
  • Attackers could perform HTTP response splitting, causing the server to emit multiple responses for a single request.
  • Malicious responses may enable cache poisoning in upstream or downstream HTTP caches.
  • Users can be redirected to attacker-controlled content or served manipulated pages, enabling phishing or content spoofing.
  • Security controls that rely on header integrity, such as CSP or secure cookie flags, can be weakened or bypassed.

General mitigation guidance

Effective mitigation revolves around robust canonicalization and strict CRLF handling in header processing:

  • Normalize or decode request data before validation so checks run on the canonical form of header values.
  • Enforce strict rejection of any header value that contains or decodes to control characters like \r or \n.
  • Apply a whitelist-based policy for headers derived from user input, limiting allowed characters and length.
  • Isolate user-controlled data to header-safe contexts or move user input into the body rather than headers.
  • Implement defense-in-depth by treating all header-derived data as untrusted and re-validating before reusing it in outbound responses or proxied requests.

How teams detect issues like this

Organizations can identify this kind of vulnerability through:

  • Static analysis: Rules that flag percent-decoding or similar canonicalization happening after validation or sanitization, especially for HTTP header fields.
  • Code review: Looking for patterns where user-controlled header values are stored and reused, or where CRLF characters are not explicitly excluded in header-handling code.
  • Dynamic testing: Fuzzing HTTP endpoints with encoded CRLF sequences (e.g., %0D%0A) in headers and observing whether extra headers or split responses are produced.
  • Policy enforcement: Introducing coding guidelines that mandate validation on canonicalized inputs and prohibit direct propagation of unverified header values.

Sources

SourceLink
github.comgithub.com/yhirose/cpp-httplib/security/advisories/GHSA-xjxg-64p4-vj4m

Frequently asked

questions

It is generally exploitable wherever cpp-httplib's server is exposed over the network and reflects or reuses request headers in responses or downstream requests, making many typical web APIs and services potentially affected.

Typically no; the attacker usually only needs the ability to send crafted HTTP requests to the cpp-httplib-based server. However, the exact preconditions depend on how the application gates access to specific endpoints.

Ensure that all header values are fully canonicalized (percent-decoded or otherwise normalized) before validation, then strictly reject any value that contains CRLF or other control characters. Where possible, avoid embedding user-controlled data in headers altogether.

Design header processing to be conservative: validate on canonical forms, apply strict character whitelists, and centralize header construction in utility functions that enforce these rules. Combine this with secure code review practices and automated tests that specifically exercise CRLF and response-splitting edge cases.

Find out what's already
exploitable in your codebase.