Cookie jar load skips public suffix check on PSL builds
curl's cookie jar loading path skips the public suffix check that the live Set-Cookie path performs, so a cookie with a public-suffix domain such as co.uk is accepted from a Netscape cookie file. An attacker who can get data into a cookie jar can plant a supercookie that curl then sends to unrelated hosts under that suffix.
- Disclosed after 8 days
On curl 8.21.0 with libpsl (official curl.se 8.21.0_6 win64, Features: PSL), HTTP Set-Cookie: Domain=co.uk is dropped in verbose. The same cookie loaded from a Netscape jar file or a Set-Cookie: line in that file is accepted and later sent to unrelated hosts under the suffix (bank.co.uk, other.co.uk).
Root cause: is_public_suffix() in lib/cookie.c only calls libpsl when the setting-host domain argument is non-NULL (line 815). cookie_load() passes NULL at line 1179. CURLOPT_COOKIELIST uses the same path. docs/cmdline-opts/cookie.md says PSL builds discard suffix-domain cookies on --cookie file load; that check is missing here.
Version: curl 8.21.0 (x86_64-w64-mingw32), libcurl/8.21.0, libpsl/0.23.0, Windows 11.
Control (HTTP - works):
- Server returns Set-Cookie: trk=http; Domain=co.uk; Path=/
- curl -v -c jar -b jar --resolve evil.co.uk:9999:127.0.0.1 http://evil.co.uk:9999/
- Verbose: must not set cookies for 'co.uk'. Request to bank.co.uk with -b jar sends no Cookie: header.
Bug (jar - broken):
- cookies.txt (tab-separated Netscape format):
Netscape HTTP Cookie File
.co.uk TRUE / FALSE 0 trk planted 2. curl -v -b cookies.txt --resolve bank.co.uk:9998:127.0.0.1 http://bank.co.uk:9998/ 3. Request includes Cookie: trk=planted. Same jar also sends to other.co.uk.
Also reproduces with Set-Cookie: trk=viafile; Domain=co.uk; Path=/ as the only line in the file. PoC attached runs control + bug twice on localhost.
(AI for report polishing)
Impact
If untrusted data can be merged into a cookie jar (shared file, -b -, CURLOPT_COOKIELIST, app importing a foreign cookie export), an attacker can plant a supercookie for a public suffix (co.uk, github.io, etc.). curl then attaches it on requests to unrelated sites under that suffix. Same impact class as prior PSL supercookie fixes on live Set-Cookie, but the gap is jar/COOKIELIST import where domain is NULL and the PSL gate is skipped.
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 public suffix check in is_public_suffix() only calls libpsl when the setting-host argument is non-NULL, and cookie_load() (also used by CURLOPT_COOKIELIST) passes NULL, so the check is skipped.
Impact
If untrusted data can be merged into a cookie jar, an attacker could plant a supercookie for a public suffix that curl then attaches to requests for unrelated sites under that suffix.
What the attacker needed
Curl built with libpsl (PSL feature); attacker can influence a cookie jar file or COOKIELIST input
The fix
The jar and CURLOPT_COOKIELIST loading paths should apply the same public suffix check as the live Set-Cookie path.
How it was found
- Create a Netscape-format cookie file containing a cookie whose domain is the public suffix co.uk.
- Run curl with -b pointing at that file against a host under the suffix, such as bank.co.uk.
- Observe that the request includes the planted cookie, and that the same jar also sends it to other.co.uk.
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.
A public suffix is a domain ending like co.uk that many unrelated organisations share, so a cookie set for it would be sent to all of them. curl normally refuses such cookies when a website sets them, but this report shows it accepts them when they come from a saved cookie file instead. That means anyone who can influence that file can make curl leak a cookie to sites it should never reach.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.