CVE-2022-27775: Bad local IPv6 connection reuse
libcurl's connection reuse logic ignored the IPv6 zone id when matching connections, so a transfer using one zone id could reuse a connection established for a different zone id. This could lead to the wrong connection being reused, potentially exposing confidential information.
- Fixed in 36 hours
- Paid in 36 hours
- Disclosed after 47 hours
Summary by the program
Curl Advisory: Bad local IPv6 connection reuse Project curl Security Advisory, April 27 2022
VULNERABILITY libcurl keeps previously used connections in a connection pool for subsequent transfers to reuse, if one of them matches the setup.
Due to errors in the logic, the config matching function did not take the IPv6 address zone id into account which could lead to libcurl reusing the wrong connection when one transfer uses a zone id and a subsequent transfer uses another (or no) zone id.
We are not aware of any exploit of this flaw.
INFO Zone ids are only used for non-global scoped IPv6 addresses and they are only used when specifying the address numerically.
This flaw has existed in curl since commit 2d0e9b40d3237b1, shipped in libcurl 7.65.0, released on May 22 2019. Previous versions will instead not accept URLs with zone ids.
The Common Vulnerabilities and Exposures (CVE) project has assigned the name CVE-2022-27775 to this issue.
CWE-200: Exposure of Sensitive Information to an Unauthorized Actor Severity: Low
AFFECTED VERSIONS Affected versions: curl 7.65.0 to and including 7.82.0 Not affected versions: curl < 7.65.0 and curl >= 7.83.0 Also note that libcurl is used by many applications, and not always advertised as such.
THE SOLUTION A fix for CVE-2022-27775
RECOMMENDATIONS A - Upgrade curl to version 7.83.0 B - Apply the patch to your local version C - Do not use non-global numerical IPv6 addresses in URLs to curl
TIMELINE This issue was reported to the curl project on April 21, 2022. We contacted distros@openwall on April 21. libcurl 7.83.0 was released on April 27 2022, coordinated with the publication of this advisory.
CREDITS This issue was reported by Harry Sintonen. Patched by Daniel Stenberg. Thanks a lot!
https://curl.se/docs/CVE-2022-27775.html
The report
Summary:
curl/libcurl doesn't consider IPv6 address zone index when doing connection reuse. if connection exists to specific IPv6 address (and other conditions for connection reuse are fulfilled) it will be reused for connections regardless of the zone index.
Steps To Reproduce:
- Set up a fake server:
echo -ne 'HTTP/1.1 200 OK\r\nContent-Length: 6\r\n\r\nHello\n' | nc -6 -v -l -p 9999 - curl "http://[ipv6addr]:9999/x" "http://[ipv6addr%25lo]:9999/y"
Both connections arrive to the test server:
Listening on :: 9999
Connection received on somehost someport
GET /x HTTP/1.1
Host: [ipv6addr]:9999
User-Agent: curl/7.83.0-DEV
Accept: */*
GET /y HTTP/1.1
Host: [ipv6addr]:9999
User-Agent: curl/7.83.0-DEV
Accept: */*
Clearly the 2nd connection should fail as the address is not available at interface lo. (Lone connection to http://[ipv6addr%25lo]:9999/ fails with curl: (7) Couldn't connect to server)
This vulnerability isn't exploitable with public IPv6 addresses on linux systems (it seems kernel strips out zone index for public addresses). It is exploitable with macOS however, and possibly other non-linux OSes.
Impact
Reuse of wrong connection leading to potential disclosure of confidential information.
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 connection-matching function compared IPv6 addresses without including the zone id, so connections to the same address but different zones were treated as identical.
Impact
Reuse of the wrong connection could lead to disclosure of confidential information, though the advisory states no exploit is known and the flaw is not exploitable with public IPv6 addresses on Linux (but is on macOS and possibly other non-Linux systems).
What the attacker needed
Libcurl 7.65.0 to 7.82.0; non-global numerical IPv6 address with zone id
The fix
The issue was fixed in curl 7.83.0; a patch is available.
How it was found
- Start a simple IPv6 test server that returns a fixed HTTP response.
- Run curl with two URLs: one using a plain IPv6 address and one using the same address with a zone id for the loopback interface.
- Observe that both requests arrive at the test server, showing the second request reused the first connection instead of failing.
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 program makes several requests to the same server, it often keeps the network connection open and reuses it to save time. This report says that for a special kind of numeric IPv6 address that includes a 'zone id' (which tells the computer which network interface to use), the program did not check that the zone id matched before reusing a connection. So it might send a request over a connection meant for a different interface, which could leak data.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.