Skip to content
Info disclosure Disclosed report Advanced

Cross‑Layer State Confusion in libcurl: Credential & Key‑Material Persistence Across Redirect / Connection Reuse Boundaries

The report claims that libcurl may carry credential or key-material state across redirects, connection reuse, or scheme changes without enforcing a trust-boundary reset. An attacker could potentially cause credentials intended for one origin to be sent to another, leading to credential exfiltration.

onevone Follow

Originally disclosed on HackerOne

Critical View original
  • Disclosed after 7 hours
## Summary:
This report describes a state‑level security invariant violation in libcurl where credential‑ or key‑related state may persist or be re‑applied across logical trust boundaries (redirects, connection reuse, or scheme transitions) without a formal invariant enforcing reset semantics.
The issue is not a parsing bug, not an HTTP smuggling issue, and not a broken cryptographic primitive. It is a cross‑layer state confusion between transport/session state and security intent, observable under realistic client workflows.

## Affected Component
libcurl (client‑side HTTP stack)
Redirect handling
Connection reuse / pooling
Credential / key‑material attachment to requests

## Steps To Reproduce:
[add details for how we can reproduce the issue]

#Intended Security Invariant (Formal)

```
Invariant I:
For any request r_i sent to origin O_i,
any credential or key-material C must satisfy:

C(r_i) is valid  ⇔  TrustBoundary(r_i) == TrustBoundary(C)

Where TrustBoundary is defined by:
  (scheme, authority, port, security context)

Violation occurs if:
  C(r_i) ≠ �
  AND  TrustBoundary(r_i) ≠ TrustBoundary(C)
```

##Broken Invariant (Observed)

```
Observed:
There exist execution traces where
C(r_i) ≠ �
 while TrustBoundary(r_i) has changed
due to redirect, reuse, or internal state carry-over.

⇒ Invariant I is violated.
```

This violation is state‑based, not request‑syntax‑based.

## Why This Is Not a Known / Duplicate Issue
Non‑Duplication Statement
This report does not describe a known curl vulnerability, CVE, or previously disclosed issue.
Existing curl security advisories focus on protocol parsing, memory safety, or TLS implementation flaws, whereas this issue concerns a cross‑request security state violation where authentication context persists across trust boundaries without a formally enforced invariant.
A review of curl’s documented CVEs and security advisories shows no coverage of this class of client‑side trust boundary state confusion, making this report novel and non‑overlapping.
This is not:
HTTP Request Smuggling
Broken crypto algorithm
TLS downgrade
Misconfiguration
This is a formal state invariant violation across layers.
Existing reports focus on what is sent; this focuses on when state must be invalidated but isn’t formally enforced.
The invariant itself is not explicitly specified or proven in current libcurl documentation.
##Realistic Cloud Scenario (100% Practical)
Scenario:
1)A service uses libcurl as a shared HTTP client inside:
CI runners
Kubernetes sidecars
API gateways
2)The client:
Uses authentication headers or key‑bound credentials
Enables redirects
Enables connection reuse
3)A request is redirected (or reused) across:
Origin boundary
Scheme boundary
Security context boundary
**Result:**
The semantic intent (“credential bound to original trust domain”) is lost.
State survives longer than its trust scope.
No attacker interaction is required beyond normal network behavior.

##Proof of Concept (Safe, Non‑Exploit)
Goal
Demonstrate state persistence across logical boundaries — without leaking secrets.
PoC Concept
We track state identity hashes, not secrets.
##Python PoC (Safe)

```
import hashlib
import pycurl
from io import BytesIO

def state_fingerprint(headers, conn_id):
    h = hashlib.sha256()
    h.update(str(headers).encode())
    h.update(str(conn_id).encode())
    return h.hexdigest()

buffer = BytesIO()
c = pycurl.Curl()

c.setopt(c.URL, "https://example.com/redirect")
c.setopt(c.FOLLOWLOCATION, True)
c.setopt(c.USERPWD, "user:token")  # dummy credential
c.setopt(c.WRITEDATA, buffer)

# Instrumentation (conceptual)
initial_state = state_fingerprint(
    headers={"Authorization": "present"},
    conn_id="conn_1"
)

c.perform()

# After redirect / reuse
post_state = state_fingerprint(
    headers={"Authorization": "present"},
    conn_id="conn_1"
)

print("Initial State:", initial_state)
print("Post Boundary State:", post_state)

if initial_state == post_state:
    print("⚠️ State persisted across boundary (Invariant violation)")
```

##What this proves:
State identity remains unchanged across a boundary.
No secret is exposed.
Demonstrates semantic persistence, not exploitation.

##Explicit Security Invariant (Formal – Very clear)
Intended Security Invariant (Formal):
For any request sequence R₁ … Rₙ, authentication material (credentials, tokens, or TLS‑bound state) associated with an origin O₁ must not be reused or implicitly applied to a different origin O₂ ≠ O₁ unless an explicit re‑authentication step occurs.
Formally:

```
∀ requests rᵢ, rⱼ : origin(rᵢ) ≠ origin(rⱼ) ⇒ auth_state(rᵢ) ⟂ auth_state(rⱼ)
```

##Observed Broken Invariant ( What is actually happening? )
Broken Invariant (Observed):
curl allows authentication state established for O₁ to persist and be conditionally reused during redirects or request chaining toward O₂, violating origin‑bound authentication isolation and enabling unintended credential propagation across trust boundaries.

##Why this matters in real‑world deployments (Cloud / CI / DevOps)
Real‑World Impact Scenario:
In CI/CD pipelines, cloud automation, and containerized workloads, curl is frequently used in non‑interactive contexts with embedded credentials.
A single misdirected redirect or chained request can cause credentials intended for an internal service to be transmitted to an external or attacker‑controlled endpoint, leading to:
Credential exfiltration
Lateral movement across services
Supply‑chain compromise in automated environments
This impact occurs silently and without user interaction, making detection difficult.

##Why this is a design flaw, not configuration misuse
This issue cannot be fully mitigated through user configuration alone, as it arises from implicit assumptions in curl’s authentication state handling model. The absence of a formally enforced origin‑bound invariant makes this a design‑level security weakness rather than a misuse or misconfiguration.

##CWE Classification
CWE‑310 — Cryptographic Issues (Generic)
Justification (one‑liner):
The issue arises from improper enforcement of cryptographic state lifecycle invariants rather than from a broken algorithm or protocol step.

##Why curl Specifically
libcurl explicitly manages:
Redirect logic
Connection reuse
Credential propagation
The invariant violation exists at this orchestration layer, not upstream servers.

##Suggested Mitigation (Non‑Prescriptive)
Explicit formalization of security state reset points
Invariant‑driven checks on:
Redirect boundaries
Reuse boundaries
Optional debug mode to assert invariant consistency

##Disclosure Notes
No exploitation performed
No user data accessed
This report focuses on correctness and safety of state transitions

#Final Note
This report introduces a new class of client‑side security invariant violations.
It is orthogonal to known curl issues and should be treated as design‑level security hardening with real‑world impact.

## Impact

## Summary:
Confidentiality: High
Credential/key material may be applied outside its intended trust scope.
Integrity: High
Requests may carry unintended security context.
Availability: Low
No direct DoS.
Overall Severity: High → Critical (Context‑Dependent)

The original report as published on HackerOne, by onevone. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the absence of a formally enforced invariant that resets authentication state when the trust boundary (scheme, host, port) changes during redirects or connection reuse.

Impact

Credentials or key material could be sent to an unintended origin, potentially leading to credential exfiltration and lateral movement, though the report provides no concrete exploit and notes no attacker interaction is required beyond normal network behaviour.

What the attacker needed

Libcurl used with credentials; redirects enabled; connection reuse enabled

The fix

The report suggests explicitly formalising security state reset points and adding invariant-driven checks at redirect and reuse boundaries, but does not state that a fix was applied.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When a program like curl follows a redirect to a different website, it should not automatically send the same username and password or token to the new site. This report says that curl might sometimes keep that login information and send it to the new site, which could let someone steal it.

What is Info disclosure?

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.