The xz-utils backdoor (CVE-2024-3094): how it worked and how to check
On 2024-03-29 Andres Freund reported that the release tarballs of xz-utils 5.6.0 and 5.6.1 contained a backdoor. The tarballs were made and signed by a co-maintainer account of the project, and the backdoor was aimed at the OpenSSH server on Linux distributions. It was found before it reached any stable release of the big distributions, by a developer who noticed that SSH logins on his Debian unstable machine used too much CPU.
What broke
xz-utils provides the xz tool and the liblzma compression library. Almost every Linux system has it.
Two parts made up the backdoor:
- In the Git repository, two test files (
tests/files/bad-3-corrupt_lzma2.xzandtests/files/good-large_compressed.lzma) contained the obfuscated payload. Binary test files are normal in a compression project. - In the release tarballs only, a modified
m4/build-to-host.m4added a step to the build that extracted the payload from the test files and linked a prebuilt object into liblzma. The source code on GitHub did not contain this step, so reading the repository did not show it.
The build step only ran under narrow conditions: an x86-64 Linux target with glibc, built as part of a Debian or RPM package. The xz project page states that the 5.6.0 and 5.6.1 tarballs were created and signed by the maintainer account "Jia Tan".
How the attack worked, in plain terms
OpenSSH does not use liblzma. But Debian and several other distributions patch sshd to report its status to systemd, and libsystemd links liblzma. On Debian 12 you can see the chain:
ldd /usr/sbin/sshd | grep -E 'lzma|systemd'
libsystemd.so.0 => /lib/x86_64-linux-gnu/libsystemd.so.0
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5
When sshd started, the backdoored liblzma redirected the OpenSSL function RSA_public_decrypt, which sshd calls during public key login, to its own code. Freund noted that this code runs before authentication and "seems likely to allow some form of access or other form of remote code execution". It checked its environment first (the program had to be /usr/sbin/sshd, TERM unset, no debugging variables) to stay hidden from people testing it.
The CNA rated it 10.0. It is not on the CISA KEV list: there is no evidence that it was used against anyone.
Who was affected
Only systems that installed xz-utils or liblzma 5.6.0 or 5.6.1 built by a distribution with the tarball. Those were mostly development and rolling releases:
- Debian: no stable release. Testing, unstable and experimental had compromised packages from 5.5.1alpha-0.1 (uploaded 2024-02-01) up to and including 5.6.1-1. Debian reverted to the 5.4.5 code as
5.6.1+really5.4.5-1(DSA-5649-1). - Fedora: Rawhide and the Fedora 40 beta received 5.6.0 or 5.6.1. Red Hat states that no version of RHEL was affected.
- Red Hat noted that other distributions may also be affected; their own notices are the reference.
Servers on Debian stable and on RHEL and its rebuilds never had the backdoor.
How to check a server today
Check the installed version of the library and the tool:
# Debian, Ubuntu
dpkg-query -W liblzma5 xz-utils
# RHEL, Fedora, Rocky, Alma
rpm -q xz xz-libs
# Alpine
apk list --installed xz-libs xz
# any system with the xz command
xz --version
On Debian 12 the first command prints liblzma5:amd64 5.4.1-1+deb12u2 or similar: a 5.4 version, not affected. The backdoored upstream versions are 5.6.0 and 5.6.1. Debian packages named 5.6.1+really5.4.5 are the reverted, clean ones.
Also check container images and VM templates built in spring 2024 from development releases. Run the same command inside the image:
docker run --rm --entrypoint dpkg-query <image> -W liblzma5
If a server did run 5.6.0 or 5.6.1 with sshd reachable from the internet, treat it as possibly compromised, even though no use was ever shown. Rebuild it from a known good image and rotate the credentials it held. The guide on the first hour of a security incident lists the steps.
How it was fixed
Debian and Fedora reverted to 5.4.x within days. GitHub suspended the accounts of both maintainers for a time. The original maintainer reviewed the history of the project, published review notes and made clean releases on 2024-05-29, starting with XZ Utils 5.6.2.
What to take from it
- Release tarballs are not the repository. Many projects publish tarballs with generated files (configure scripts, m4 macros) that are not in Git. Distributions build from those tarballs. Reproducible builds and building from the Git tag reduce this gap.
- Indirect dependencies count. sshd did not depend on liblzma; a distribution patch made it load the library. An SBOM of the host shows these links,
lddshows them for one binary. - Stable releases buy time. The backdoor reached testing and rolling releases. Servers on stable releases were never exposed, because new upstream versions take months to arrive there.
- Performance oddities deserve a look. The backdoor was found because sshd used more CPU than expected (about 0.5 s on the machine of the reporter) and valgrind reported errors.
Sources
- CVE-2024-3094 record (description, affected versions, CVSS, CWE-506)
- Andres Freund: backdoor in upstream xz/liblzma leading to ssh server compromise, oss-security, 2024-03-29 (files, build conditions, sshd and libsystemd, RSA_public_decrypt, environment checks)
- XZ Utils backdoor, tukaani.org (tarballs signed by Jia Tan, clean releases on 2024-05-29)
- Debian DSA-5649-1 (affected Debian versions, revert to 5.4.5)
- Red Hat: Urgent security alert for Fedora Linux 40 and Fedora Rawhide users (Fedora versions, RHEL not affected)
- CISA KEV catalog, version 2026.11.25 (CVE-2024-3094 not listed)
lddanddpkg-queryoutput from adebian:bookworm-20261027-slimcontainer on 2026-11-26
Check your servers every day
The agent of Patchbrief reports the packages and settings of a server once a day; the digest names what to fix first.