Cookie attribute truncation in curl drops Secure/HttpOnly protections
curl's cookie parser stops reading attributes when a Set-Cookie header contains an equals sign right after a semicolon, so attributes that follow, including Secure and HttpOnly, are silently ignored. An attacker who can influence a cookie header could therefore have curl store a cookie without its Secure flag and later send it over plain HTTP.
Originally disclosed on HackerOne
- Disclosed after 26 hours
Description:
If a Set-Cookie header contains an = immediately after a semicolon (i.e., ;=), curl stops parsing the attributes and discards everything that follows. This silently drops protections like Secure and HttpOnly, causing curl to later send the cookie over unencrypted HTTP.
Root Cause:
In parse_cookie_header() (lib/cookie.c:614), an = immediately following a ; causes curlx_str_cspn to fail with a zero-length match. This terminates the attribute-parsing loop early, before the Secure attribute is ever evaluated.
Impact: Sensitive cookie data is sent in plaintext over the network (CWE-201).
Steps to Reproduce (PoC):
-
Start a local HTTPS server with a self-signed certificate for the name
cookie.test, and a plain-HTTP server on a second port. The HTTPS one returns this header:Set-Cookie: session=secret;=x; Secure
-
Fetch the HTTPS URL with curl 8.22.0 and save the cookie jar.
--resolvepoints the name at the local server, so no DNS and no public host are needed;-kis only for the self-signed certificate:curl -k -c jar.txt --resolve cookie.test:8443:127.0.0.1 https://cookie.test:8443/
-
Inspect
jar.txt. The fourth tab-separated field is the Secure flag:cookie.test FALSE / FALSE 0 session secret
-
Request the same host name over plaintext HTTP, reusing the jar:
curl -b jar.txt --resolve cookie.test:8080:127.0.0.1 http://cookie.test:8080/
Expected Result:
The Secure attribute is applied, so field 4 of the jar reads TRUE and the
plaintext request in step 4 carries no Cookie: header.
Actual Result: Field 4 reads FALSE and the plaintext server receives the cookie:
GET / HTTP/1.1 Host: cookie.test:8080 User-Agent: curl/8.22.0 Accept: / Cookie: session=secret
Parsing was truncated at the ;= sequence, so Secure was never evaluated.
Reproduction script: one command
python poc.py
(Attachment on the original report: poc.py)


Impact
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
The attribute-parsing loop treats an equals sign immediately after a semicolon as a zero-length match and exits early, before later attributes such as Secure are evaluated.
Impact
Cookies that should have been protected are sent in plaintext over the network.
What the attacker needed
Attacker can set a crafted cookie header; victim uses curl to fetch that response; later plaintext request reuses the jar
How it was found
- Run an HTTPS server for a test host name that returns a Set-Cookie header with an equals sign right after a semicolon, plus a plain-HTTP server on another port
- Fetch the HTTPS URL with curl, saving cookies to a jar file
- Inspect the jar file and note that the Secure flag field reads FALSE
- Request the same host over plain HTTP reusing the jar and observe the cookie being sent
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 website sets a cookie, it can add labels such as Secure, which tells the browser or tool to send that cookie only over encrypted connections. curl reads these labels one by one, but a malformed piece in the header made it stop reading early, so the Secure label was never seen. The cookie was then treated as ordinary and sent over an unencrypted connection, where someone watching the network could read it.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.