Summary
HTTP::Tiny before 0.095 forwards caller-supplied credential headers like Authorization, Cookie, and Proxy-Authorization to cross-origin redirect targets without origin checks.
This behavior can expose secrets to arbitrary hosts, including over downgraded https to http redirects, whenever callers follow redirects with sensitive headers.
Affected context
The issue arises in Perl applications that use HTTP::Tiny versions prior to 0.095 and:
- Supply their own
Authorization,Cookie, orProxy-Authorizationheaders - Allow HTTP::Tiny to follow redirects automatically via
_maybe_redirect - Interact with endpoints that may return cross-origin 3xx responses with attacker-controlled or untrusted
Locationheaders
In these conditions, HTTP::Tiny reuses caller headers on the new request without verifying that the redirect target shares the original origin or security properties (scheme, host, or port).
Exploit preconditions
- Attack surface: Outbound HTTP requests made via HTTP::Tiny in Perl applications.
- Required access: Ability to influence or control the redirecting server or its
Locationheader (e.g., operating a malicious endpoint, exploiting open redirects, or controlling upstream responses). - Trigger point: A 3xx HTTP response that causes
_maybe_redirectto issue a follow-up request, during which_prepare_headers_and_cbre-merges the original caller-provided headers. - Why exploitation is possible: HTTP::Tiny does not enforce any origin or scheme checks when forwarding caller-supplied credential headers, so secrets are sent to arbitrary redirect targets, including insecure or cross-origin destinations.
Why this happens
The root cause is an insecure credential handling pattern where sensitive headers are treated as generic metadata and blindly reused on redirected requests.
Specifically, HTTP::Tiny's _maybe_redirect logic follows any Location header while _prepare_headers_and_cb re-merges the caller's headers argument into the new request without validating origin consistency or downgrades from https to http.
This maps to CWE-522: Insufficiently Protected Credentials, because credentials are transmitted to untrusted or less secure endpoints, violating basic confidentiality guarantees and assumptions about header scoping across redirects.
Potential impact
- Disclosure of bearer tokens, API keys, or Basic-auth credentials via the
Authorizationheader to attacker-controlled hosts - Leakage of session identifiers and user state via
Cookieheaders across origins - Exposure of proxy authentication secrets (
Proxy-Authorization) to arbitrary endpoints - Credential interception over downgraded
httpstohttpredirects, enabling on-path attackers to capture secrets in plaintext - Unauthorized access or account takeover if leaked credentials are reused by attackers against the original service
General mitigation guidance
Mitigations generally focus on constraining where credentials travel and reducing implicit trust in redirect targets:
- Treat caller-supplied credential headers as origin-bound and avoid reusing them on redirects unless the new destination is explicitly validated as same-origin and equally secure.
- Separate authentication state from generic request headers, using per-origin credential stores instead of passing raw
AuthorizationorCookieheaders into low-level clients. - Enforce redirect policies that disallow cross-origin redirects, scheme downgrades, or excessive redirect chains when credentials are present.
- Apply least-privilege principles to issued tokens (scoped, short-lived, revocable) so any leaked value has limited utility.
- Prefer transport security and strict policies (e.g., refusing to follow redirects from
httpstohttp) in components that handle authentication material.
How teams detect issues like this
Effective detection typically combines code-level and runtime analysis:
- Static analysis or grep-based review for code paths that pass explicit
Authorization,Cookie, orProxy-Authorizationheaders into HTTP::Tiny and also enable redirect following. - Code review checklists that flag any HTTP client configuration where redirects are followed automatically while custom credential headers are present.
- Logging and telemetry to capture redirect chains, including original and target hosts, schemes, and whether credential-bearing requests were redirected across origins.
- Security testing and fuzzing that injects crafted 3xx responses with cross-origin
Locationheaders to observe whether sensitive headers are forwarded. - Use of automated review tools or linters that enforce policies like "no credential headers on cross-origin redirects" for HTTP client usage.

