/

CVE-2026-33745

Severity:

HIGH RISK

(7.4)

Information Exposure / Credential Leakage in cpp-httplib

CVE-2026-33745

Analyzed

Vulnerability type

Category:

Information Exposure / Credential Leakage

CWE:

CWE-200

Impact:

Exposure of Authentication Credentials to Unauthorized Hosts

Severity:

HIGH RISK

(7.4)

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 HTTP client reused stored Basic, Bearer, and Digest authentication credentials across cross-origin redirects, sending them to arbitrary hosts in the Authorization header.

When a malicious or compromised server issues a redirect to an attacker-controlled domain, that domain can receive these plaintext credentials and potentially reuse them against the original service or other systems.

Affected context

This vulnerability affects applications that use cpp-httplib's HTTP client (prior to 0.39.0) and enable automatic redirect following.

It is relevant when:

  • The client stores or sets Basic Auth, Bearer Token, or Digest Auth credentials for a given host, and
  • The contacted server can return 301/302/307/308 redirects to a different origin (different host, scheme, or port).

In such cases, the client may automatically include the original Authorization header on requests to the redirected, cross-origin destination.

Exploit preconditions

  • Attack surface: Outbound HTTP/HTTPS requests made by cpp-httplib clients that:
  • Use automatic redirect handling, and
  • Carry Authorization headers (Basic, Bearer, or Digest).
  • Required access: Ability for an attacker to:
  • Control or compromise an HTTP(S) endpoint that the client talks to, or
  • Influence DNS or routing so that a client connects to an attacker-controlled server that can issue redirects.
  • Trigger point: The attacker-controlled or compromised server responds with a 301/302/307/308 redirect to a different origin under the attacker's control.
  • Why exploitation is possible: The HTTP client did not properly scope or filter Authorization headers on cross-origin redirects, so credentials bound to one origin were forwarded to another, unauthorized origin.

Why this happens

The underlying issue is improper scoping of sensitive headers during HTTP redirect handling.

cpp-httplib's client logic reused existing authentication headers for redirected requests without validating that the target origin matched the original authenticated origin.

This maps to CWE-200: Exposure of Sensitive Information to an Unauthorized Actor, since authentication tokens and passwords were disclosed to hosts that were not intended recipients.

At a design level, redirect handling failed to enforce the principle that credentials and other sensitive headers should not be automatically propagated across origins unless explicitly re-authorized.

Potential impact

  • Attackers may obtain plaintext Basic Auth credentials (username and password) for services the client accesses.
  • Attackers may capture Bearer tokens or API keys and reuse them to impersonate the client or user.
  • Attackers can harvest Digest Auth material and attempt offline cracking or replay where applicable.
  • Compromised credentials can be used to access protected APIs, exfiltrate data, or modify resources on the original service.
  • Collected tokens may enable further lateral movement into internal systems or cloud environments that trust those tokens.

General mitigation guidance

Effective mitigation focuses on tightening redirect and credential handling behavior:

  • Ensure that authentication headers are not automatically forwarded across origin boundaries during redirects; credentials should be scoped to their original host/realm.
  • Apply explicit checks in client code so that on redirect, any Authorization header is dropped unless the new origin is trusted and matches expected criteria (e.g., same host or preconfigured allowlist).
  • Where possible, separate tokens per domain or service, avoiding reuse of a single bearer token across multiple unrelated endpoints.
  • Favor short-lived, least-privilege tokens so that any exposed token has limited utility and lifetime.
  • Restrict which redirects are followed by default; for security-sensitive flows, require explicit approval or custom handling of redirects.
  • Apply defense-in-depth at the server side by limiting the privileges of tokens and enforcing strict audience/issuer checks for bearer-style authentication.

How teams detect issues like this

Detecting and preventing similar issues can involve:

  • Code review patterns:
  • Look for HTTP client logic that automatically follows redirects while carrying over all headers, especially Authorization, Cookie, or custom auth headers.
  • Verify that redirect handlers compare original and new origins, and strip sensitive headers on cross-origin changes.
  • Static analysis and linters:
  • Use rules that flag propagation of authentication headers across requests when the target host or scheme changes.
  • Enforce policies that disallow blind header_copy behavior for security-sensitive fields.
  • Runtime and logging analysis:
  • Enable logging of outbound requests at a sanitized level to detect when credentials appear in requests to unexpected domains (take care to avoid logging full secrets).
  • Monitor network egress patterns (e.g., via proxies or gateways) for Authorization headers being sent to untrusted or unknown hosts.
  • Security testing:
  • In integration testing, stand up controlled endpoints that issue cross-origin redirects and verify that clients do not forward sensitive headers to the redirected destination.

Sources

SourceLink
github.comgithub.com/yhirose/cpp-httplib/security/advisories/GHSA-6hrp-7fq9-3qv2

Frequently asked

questions

Yes. If a client connects to a malicious or compromised server that uses cpp-httplib's vulnerable redirect handling, that server can issue redirects to attacker-controlled hosts and receive the client's credentials.

The attacker primarily needs control over, or the ability to impersonate, a server that the client contacts.

They do not need prior authentication to the client's target service; instead, they exploit the client's trust in redirects to capture the credentials.

The safest pattern is to prevent Authorization (and other sensitive) headers from being automatically reused across origins.

On any redirect where host, scheme, or port changes, drop or re-evaluate credentials and only reattach them if the new origin is explicitly trusted and matches expected security constraints.

Design redirect handling with strict origin-awareness: treat changes in host, scheme, or port as potential trust boundary crossings.

Implement default rules that strip sensitive headers on cross-origin redirects, use per-origin credentials, and add tests and automated checks that simulate hostile redirects to ensure credentials are never leaked to unintended hosts.

Find out what's already
exploitable in your codebase.