Skip to content
Crypto Disclosed report Advanced CVE-2023-38546

CVE-2023-38546: cookie injection with none file

When curl duplicates an easy handle, it re-initialises the cookie engine using the stored cookie filename, which defaults to the literal string 'none' if no file was set. If a file named 'none' exists in the current working directory, its contents are loaded as cookies and injected into requests made with the duplicated handle.

w0x42 Follow

Originally disclosed on HackerOne

  • Triaged in 22 hours
  • Fixed in 27 days
  • Disclosed after 27 days

When curl_easy_duphandle() is used to duplicate an easy handle it is possible to inject cookies into that duplicated handle if a file none exists in the current working directory.

PoC / Steps to reproduce:

  1. Open 2 terminals
  2. compile F2699218
  3. in terminal 1: nc -l -p 8888 127.0.0.1
  4. in terminal 2:
    • echo -e "127.0.0.1\tTRUE\t/\tFALSE\t0\tname\tvalue" > none
    • /path/to/poc_cookieinj

(poc_cookieinj does not have to be in the same directory as the file none)

Supporting Material/References:

The flaw is in Curl_cookie_init()

if(!inc) {
    /* we didn't get a struct, create one */
    c = calloc(1, sizeof(struct CookieInfo));
    if(!c)
      return NULL; /* failed to get memory */
    c->filename = strdup(file?file:"none"); /* copy the name just in case */
    if(!c->filename)
      goto fail; /* failed to get memory */

and in curl_easy_duphandle() the injection happens

if(data->cookies) {
    /* If cookies are enabled in the parent handle, we enable them
       in the clone as well! */
    outcurl->cookies = Curl_cookie_init(data,
                                        data->cookies->filename,
                                        outcurl->cookies,
                                        data->set.cookiesession);
    if(!outcurl->cookies)
      goto fail;
  }

Impact

cookies injection into an http request

The original report as published on HackerOne, by w0x42. 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 cookie filename defaults to the literal string 'none' rather than being unset, so duplicating a handle re-reads a file from the current working directory.

Impact

An attacker who can place a file named 'none' in the working directory could inject cookies into HTTP requests made through a duplicated handle.

What the attacker needed

Ability to write a file named 'none' in the working…; program uses curl_easy_duphandle()

How it was found

  1. Open two terminals and compile the proof-of-concept program.
  2. In the first terminal, start a listener on the loopback address.
  3. In the second terminal, create a file named 'none' containing a cookie line.
  4. Run the proof-of-concept binary, which need not be in the same directory as the file.

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.

curl is a tool and library for making web requests. When a program copies a curl 'handle' (its internal state for a connection), curl re-reads a cookie file whose name defaults to the word 'none'. If an attacker can place a file called 'none' in the folder the program runs from, its contents get treated as cookies and sent with requests.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More by w0x42

View all

3 more disclosed reports, best first.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.