curl vulnerability (CVE-2023-38545): what to update, and where

On Wednesday, 11 October, curl 8.4.0 was released, fixing two flaws: the high-severity curl vulnerability was assigned CVE-2023-38545, and the low-severity flaw fixed alongside it CVE-2023-38546. curl and its libcurl library are on almost every Linux server, and countless programs use them in the background, so the news attracted a lot of attention from the moment it was pre-announced a week earlier. Below we sum up what is known about the flaw, who it actually affects, and what is worth reviewing now.

Why was there so much fuss?

curl’s maintainer, Daniel Stenberg, announced in advance on 4 October that 8.4.0 would fix one flaw rated HIGH and one rated LOW, and described the more serious one as “probably the worst curl security flaw in a long time”. He deliberately gave no details until the release, and the distributions were notified on 3 October on openwall’s closed distros list.

This kind of advance notice is useful: it gave everyone a week to work out where curl or libcurl runs and to schedule the update. Without the details, however, many prepared for the worst. Now that the official description is public, it turns out that the flaw is indeed serious, but it can only be exploited under fairly narrow conditions.

What is the flaw?

CVE-2023-38545 is a heap buffer overflow in the SOCKS5 proxy handshake.

  • Affected versions: libcurl 7.69.0 to 8.3.0. The flaw entered the code in early 2020, when the SOCKS5 handshake was converted from a blocking function into a non-blocking state machine. Versions before 7.69.0 and versions 8.4.0 or newer are not affected.
  • Condition: the client uses a SOCKS5 proxy with remote name resolution. This is the socks5h:// scheme, the --socks5-hostname option, CURLPROXY_SOCKS5_HOSTNAME in libcurl, or a proxy environment variable (http_proxy, HTTPS_PROXY, ALL_PROXY) set to socks5h://.
  • What happens: if the host name is longer than 255 bytes, curl should switch to local name resolution. With a slow handshake, however, a variable can get the wrong value, and curl copies the full host name, up to 65,535 bytes long, into a buffer that is too small.
  • Attack path: according to the advisory, one example is a malicious HTTPS server that redirects the client to a URL with a long host name. Normal network latency may be enough to trigger the flaw.

Because of the buffer size, the curl command-line tool and programs that use libcurl are not affected in the same way:

Environment Default buffer Exploitable?
curl command 100 kB Only if --limit-rate is set below 65,541 bytes/s
Application using libcurl 16 kB Yes, unless it sets a buffer larger than 65,541 bytes (CURLOPT_BUFFERSIZE)

Where does socks5h come up? Typically behind Tor clients, with ssh -D dynamic tunnels and with some corporate proxies. Rarely on an average web server that reaches the internet directly, but don’t assume that – check it: proxy environment variables can also be set by the services’ unit files and by /etc/environment.

The smaller flaw: CVE-2023-38546

This affects applications using libcurl 7.9.1 to 8.3.0 that clone a handle with cookie handling enabled using curl_easy_duphandle(). If there is a suitably formatted file called none in the working directory, the clone may also load cookies from it. The curl command is not affected, and it is unlikely that all the conditions are met at once.

What have the distributions released?

On servers you don’t install curl 8.4.0, but your distribution’s fixed package, into which the fix has been backported. So the package version number won’t be 8.4.0, and curl --version also shows the old number. Status as of Friday morning:

Distribution curl version Status
Debian 12 bookworm 7.88.1 Fixed: 7.88.1-10+deb12u4 (DSA-5523-1)
Debian 11 bullseye 7.74.0 Fixed: 7.74.0-1.3+deb11u10 (DSA-5523-1)
Debian 10 buster 7.64.0 Not affected by CVE-2023-38545
Ubuntu 22.04 LTS 7.81.0 Fixed: 7.81.0-1ubuntu1.14 (USN-6429-1)
Ubuntu 23.04 7.88.1 Fixed: 7.88.1-8ubuntu2.3 (USN-6429-1)
Ubuntu 20.04 LTS 7.68.0 Not affected by the SOCKS5 flaw; cookie flaw fixed: 7.68.0-1ubuntu2.20
RHEL 6, 7, 8 and their clones 7.61.1 or older Not affected, according to Red Hat
RHEL 9 and its clones 7.76.1 In the affected range; watch the advisories from Red Hat and the clones

Proxmox VE 8 is based on Debian 12 and 7.x on Debian 11, so the fixed Debian package is the solution there too.

How to check your servers

You can check the version like this, but as we wrote above, with a distribution package the package version is what counts:

curl --version | head -1

Debian, Ubuntu, Proxmox VE:

dpkg -l 'curl' 'libcurl*' | grep ^ii
apt update && apt install --only-upgrade curl libcurl4 libcurl3-gnutls

RHEL family:

rpm -q curl libcurl libcurl-minimal
dnf updateinfo list --cve CVE-2023-38545

After the update, processes that are already running still keep the old library in memory. Restart the services that use libcurl – for example PHP-FPM, since PHP’s curl extension is also built on it. On a Debian-based system, needrestart shows what needs to be restarted, or you can search manually:

lsof -n 2>/dev/null | grep libcurl | grep -E 'DEL|deleted'

libcurl can be where you don’t expect it

  • Container images: every image brings its own libcurl. Updating the host doesn’t fix them; update the base image and rebuild your own images.
  • Self-compiled or bundled software: some applications ship libcurl statically or in their own directory. A quick search shows the copies outside the package manager:

    find / -xdev -name 'libcurl*.so*' 2>/dev/null
    
  • CI/CD runners and build machines: the curl used during the build also counts if the pipeline downloads through a proxy.
  • Legacy systems: an unsupported distribution won’t get a fixed package. We wrote about this in detail in our article on the risks of unsupported software.

If you can’t update right now

The curl project suggests two workarounds: don’t use a CURLPROXY_SOCKS5_HOSTNAME type proxy, and don’t set a proxy environment variable to socks5h://. Where a SOCKS proxy is unavoidable, socks5:// (local name resolution) is not affected, but then the DNS requests bypass the proxy, which is not always acceptable from a privacy point of view.

What can we learn from it?

The advance notice gave everyone a week, but it was only useful to those who knew where curl ran on their systems. An up-to-date inventory of servers, images and the packages in them is the most valuable tool in situations like this. You can find a more general checklist in our article on what to do in times of heightened cybersecurity risk. And with the RHEL clones it is clear once again that the timing of fixes depends on Red Hat’s releases; we covered this in our article on the changes around the RHEL source code.

If you need help reviewing your servers and containers or scheduling updates, get in touch; you can read about our operations services on the Infrastructure and operations page.

Let’s talk about your project

Tell us briefly how we can help, and we will get back to you as soon as we can.

Get in touch