/

CVE-2026-102944

Severity:

HIGH RISK

(7.5)

Cookie Leakage (CWE-522) in cpp-httplib Redirect Handling

CVE-2026-102944

Deferred

Vulnerability type

Category:

Sensitive Credential Exposure

CWE:

CWE-522

Impact:

Session Cookie Disclosure and Account Compromise

Severity:

HIGH RISK

(7.5)

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

A cookie-handling flaw in cpp-httplib before 0.51.0 can preserve cookies when a client follows certain cross-origin HTTP redirects. If an attacker controls the redirect response or can observe traffic from a non-HTTPS origin, session cookies intended for the original host may be disclosed to the redirect target.

A cookie-handling flaw in cpp-httplib before 0.51.0 can preserve cookies when a client follows certain cross-origin HTTP redirects. If an attacker controls the redirect response or can observe traffic from a non-HTTPS origin, session cookies intended for the original host may be disclosed to the redirect target.

Affected context

The issue occurs in cpp-httplib clients that follow cross-origin 301, 302, 307, or 308 redirects. The redirect-handling logic removes Host, Proxy-Authorization, and Authorization headers but retains Cookie headers supplied directly or through default_headers_. The risk depends on whether an untrusted redirect target can be introduced or network traffic from a non-HTTPS origin can be observed.

The issue occurs in cpp-httplib clients that follow cross-origin 301, 302, 307, or 308 redirects. The redirect-handling logic removes Host, Proxy-Authorization, and Authorization headers but retains Cookie headers supplied directly or through default_headers_. The risk depends on whether an untrusted redirect target can be introduced or network traffic from a non-HTTPS origin can be observed.

Exploit preconditions

  • Attack surface: HTTP or HTTPS client redirect handling
  • Required access: Ability to cause or control a redirect response, or observe traffic from a non-HTTPS origin
  • Trigger point: Following a cross-origin 301, 302, 307, or 308 redirect
  • Required data: Cookies associated with the original request, including cookies configured through default_headers_
  • Why exploitation is possible: The request is copied for the redirect while sensitive Cookie headers remain attached after other origin-bound headers are removed
  • Attack surface: HTTP or HTTPS client redirect handling
  • Required access: Ability to cause or control a redirect response, or observe traffic from a non-HTTPS origin
  • Trigger point: Following a cross-origin 301, 302, 307, or 308 redirect
  • Required data: Cookies associated with the original request, including cookies configured through default_headers_
  • Why exploitation is possible: The request is copied for the redirect while sensitive Cookie headers remain attached after other origin-bound headers are removed

Why this happens

The underlying bug is incomplete sanitization of security-sensitive request headers during cross-origin redirect processing. Although several authentication and routing headers are removed, Cookie headers survive the copied-request path for 301, 302, 307, and 308 responses. This maps to CWE-522: Insufficiently Protected Credentials, because session credentials can be transmitted to an unintended recipient when origin boundaries are not enforced consistently.

The underlying bug is incomplete sanitization of security-sensitive request headers during cross-origin redirect processing. Although several authentication and routing headers are removed, Cookie headers survive the copied-request path for 301, 302, 307, and 308 responses. This maps to CWE-522: Insufficiently Protected Credentials, because session credentials can be transmitted to an unintended recipient when origin boundaries are not enforced consistently.

Potential impact

  • Session cookies may be disclosed to an attacker-controlled redirect destination
  • Authenticated sessions could be hijacked
  • Users may experience unauthorized account activity
  • Sensitive application data could be accessed through stolen session credentials
  • Exposure may extend to multiple clients or users if shared default headers are configured
  • Session cookies may be disclosed to an attacker-controlled redirect destination
  • Authenticated sessions could be hijacked
  • Users may experience unauthorized account activity
  • Sensitive application data could be accessed through stolen session credentials
  • Exposure may extend to multiple clients or users if shared default headers are configured

General mitigation guidance

Mitigation generally focuses on preventing credential-bearing headers from crossing origin boundaries.

Common defensive patterns include:

  • Remove Cookie and other session-bearing headers before following cross-origin redirects
  • Reconstruct redirected requests using an explicit allowlist of headers
  • Treat redirect destinations as untrusted unless they match an approved origin policy
  • Prefer HTTPS for every request and validate redirect schemes and destinations
  • Avoid placing broadly scoped credentials in shared default headers
  • Limit session cookie scope, lifetime, and privileges where practical
  • Use redirect policies that require explicit application approval for cross-origin transitions

Mitigation generally focuses on preventing credential-bearing headers from crossing origin boundaries.

Common defensive patterns include:

  • Remove Cookie and other session-bearing headers before following cross-origin redirects
  • Reconstruct redirected requests using an explicit allowlist of headers
  • Treat redirect destinations as untrusted unless they match an approved origin policy
  • Prefer HTTPS for every request and validate redirect schemes and destinations
  • Avoid placing broadly scoped credentials in shared default headers
  • Limit session cookie scope, lifetime, and privileges where practical
  • Use redirect policies that require explicit application approval for cross-origin transitions

How teams detect issues like this

Organizations can detect this class of issue through:

  • Static analysis and code review checks for copied requests that retain Cookie or authorization headers
  • Tests covering every redirect status supported by the client, including cross-origin destinations
  • Integration tests that verify sensitive headers are absent after redirect processing
  • Policy checks requiring explicit origin validation before forwarding credentials
  • Network monitoring for session cookies appearing in requests to unexpected hosts
  • Automated security review tools that flag credential propagation across trust boundaries

Organizations can detect this class of issue through:

  • Static analysis and code review checks for copied requests that retain Cookie or authorization headers
  • Tests covering every redirect status supported by the client, including cross-origin destinations
  • Integration tests that verify sensitive headers are absent after redirect processing
  • Policy checks requiring explicit origin validation before forwarding credentials
  • Network monitoring for session cookies appearing in requests to unexpected hosts
  • Automated security review tools that flag credential propagation across trust boundaries

Sources

SourceLink
github.comgithub.com/yhirose/cpp-httplib/commit/0c1cc8c9866bb567ff11c1cd0d09779e8c5f8585
github.comgithub.com/yhirose/cpp-httplib/releases/tag/v0.51.0
github.comgithub.com/yhirose/cpp-httplib/security/advisories/GHSA-22mf-w2v3-r2jv

Frequently asked

questions

Yes, when an attacker can control a redirect response or influence a destination that the client follows. Network observation may also matter when the original request uses a non-HTTPS origin.

Not necessarily. The key requirement is the ability to cause a vulnerable client to follow a cross-origin redirect while cookies are attached to the request.

Do not forward Cookie or other session-bearing headers across origins. Build redirected requests from an explicit safe header allowlist and apply an origin policy.

Test redirect behavior across all supported status codes, enforce HTTPS, restrict redirect destinations, minimize default credential headers, and monitor for credentials sent to unexpected hosts.

Yes, when an attacker can control a redirect response or influence a destination that the client follows. Network observation may also matter when the original request uses a non-HTTPS origin.

Not necessarily. The key requirement is the ability to cause a vulnerable client to follow a cross-origin redirect while cookies are attached to the request.

Do not forward Cookie or other session-bearing headers across origins. Build redirected requests from an explicit safe header allowlist and apply an origin policy.

Test redirect behavior across all supported status codes, enforce HTTPS, restrict redirect destinations, minimize default credential headers, and monitor for credentials sent to unexpected hosts.

Find out what's already
exploitable in your codebase.