Skip to content

Set-Cookie silently no longer sent without domain #6723

Description

@martindorey

I did this

$ cat /tmp/cookie
Set-Cookie: key=value
$ curl --verbose --cookie /tmp/cookie http://blank.org/

With 7.60.0, I get no cookie sent:

martind@pizzagate:/tmp/curl-7.60.0$ ./src/curl --verbose --cookie /tmp/cookie http://blank.org/
*   Trying 18.217.80.105...
* TCP_NODELAY set
* Connected to blank.org (18.217.80.105) port 80 (#0)
> GET / HTTP/1.1
> Host: blank.org
> User-Agent: curl/7.60.0
> Accept: */*
> 
< HTTP/1.1 200 OK
...

I expected the following

Cookie: key=value

... as seen in:

martind@pizzagate:/tmp/curl-7.59.0$ ./src/curl --verbose --cookie /tmp/cookie http://blank.org/
*   Trying 18.217.80.105...
* TCP_NODELAY set
* Connected to blank.org (18.217.80.105) port 80 (#0)
> GET / HTTP/1.1
> Host: blank.org
> User-Agent: curl/7.59.0
> Accept: */*
> Cookie: key=value
> 
< HTTP/1.1 200 OK
...

curl/libcurl version

martind@pizzagate:/tmp/curl-7.60.0$ ./src/curl -V
curl 7.60.0 (x86_64-pc-linux-gnu) libcurl/7.60.0 OpenSSL/1.1.1d zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) nghttp2/1.36.0 librtmp/2.3
Release-Date: 2018-05-16
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp smb smbs smtp smtps telnet tftp 
Features: AsynchDNS IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL 
martind@pizzagate:/tmp/curl-7.60.0$ 

operating system

martind@pizzagate:/tmp/curl-7.60.0$ uname -a
Linux pizzagate 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2+deb10u1 (2020-06-07) x86_64 GNU/Linux
martind@pizzagate:/tmp/curl-7.60.0$ 

If I add an appropriate domain to the Set-Cookie file, then all is well:

martind@pizzagate:/tmp/curl-7.60.0$ cat /tmp/cookie
Set-Cookie: key=value; domain=blank.org
martind@pizzagate:/tmp/curl-7.60.0$ ./src/curl --verbose --cookie /tmp/cookie http://blank.org/
*   Trying 18.217.80.105...
* TCP_NODELAY set
* Connected to blank.org (18.217.80.105) port 80 (#0)
> GET / HTTP/1.1
> Host: blank.org
> User-Agent: curl/7.60.0
> Accept: */*
> Cookie: key=value
> 
< HTTP/1.1 200 OK

Why am I sending you a bug report on a version from 3 years ago? Because I suspect that the cause of my pain is a change in this version, specifically b8d5036, which I will attempt to demonstrate by nobbling part of it and showing that the cookie returns:

martind@pizzagate:/tmp/curl-7.60.0$ diff -u ./lib/cookie.c{,.martind}
--- ./lib/cookie.c	2021-03-10 23:45:36.309320486 -0800
+++ ./lib/cookie.c.martind	2021-03-10 23:45:11.113604028 -0800
@@ -292,7 +292,7 @@
     return 0;
 
   top = get_top_domain(domain, &len);
-  return cookie_hash_domain(top, len);
+  return cookie_hash_domain(top, len) * 0;
 }
 
 /*
martind@pizzagate:/tmp/curl-7.60.0$ cp ./lib/cookie.c{.martind,}
martind@pizzagate:/tmp/curl-7.60.0$ make -j8
...
martind@pizzagate:/tmp/curl-7.60.0$ cat /tmp/cookie
Set-Cookie: key=value
martind@pizzagate:/tmp/curl-7.60.0$ ./src/curl --verbose --cookie /tmp/cookie http://blank.org/
*   Trying 18.217.80.105...
* TCP_NODELAY set
* Connected to blank.org (18.217.80.105) port 80 (#0)
> GET / HTTP/1.1
> Host: blank.org
> User-Agent: curl/7.60.0
> Accept: */*
> Cookie: key=value
> 
< HTTP/1.1 200 OK
...

I have no problem with the Set-Cookie file format requiring a domain. It would be nice if the requirement were documented, though the documentation for this file format is... skimpy. I suspect that this was an accidental change in behavior, a side-effect of a doubtless worthy performance improvement. If it's a change that trips up others, then they might appreciate finding a bug report that nudges them in the direction of adding a domain.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions