xz Utils backdoor
The xz backdoor: a two-year con caught by half a second of lag
A contributor spent two years earning maintainer rights to a small compression library, then hid a backdoor that could have opened SSH on Linux servers worldwide. An engineer chasing slow logins found it weeks before it reached stable releases.
- Disclosed
- 29 March 2024
- Type
- Supply chain
- Identifier
- CVE-2024-3094
- Read time
- 9 minutes
- Trust built over two yearsFrom 2021, "Jia Tan" contributes patches and gains maintainer rights.
- Backdoor hidden in test filesMalicious code is disguised as binary test data.
- Release tarballs tamperedVersions 5.6.0 and 5.6.1 carry a build step that is not in the git repository.
- Hooks into SSH loginsThrough liblzma, the code reaches into sshd on some Linux distributions.
- Caught before stable releaseFound in testing and development versions, then pulled.
In plain terms
Much of the internet runs on maintained by a handful of volunteers. xz Utils is one of these projects: a tool for compressing files, built into almost every Linux system.
For years it was looked after by one person in their spare time. In 2021 a new contributor calling themselves Jia Tan began sending helpful fixes. Meanwhile, other accounts complained that the project was moving too slowly and pushed for a new maintainer. Over two years Jia Tan was given more and more control.
In early 2024 Jia Tan published new versions with a hidden . On some Linux systems it attached itself to SSH, the program administrators use to log in to servers remotely. Anyone holding the attacker's secret key could have used it to run commands on those servers.
It was found by chance. Andres Freund, a software engineer, noticed SSH logins on his test machine were taking about half a second longer than usual, dug in, and found the backdoor. Because the poisoned versions had only reached testing and development versions of Linux, it was stopped before it spread to most servers.
The deep analysis follows: what happened, root cause, mitigation and prevention.
What happened
xz Utils provides the xz command and the liblzma library. On Debian, Fedora and related distributions, OpenSSH's server is patched to support systemd notifications, and through libsystemd it loads liblzma into the sshd process. That indirect link is what made a compression library a route into remote login.
- The GitHub account JiaT75 begins contributing to xz and other open-source projects.
- Accounts with little other history press the long-time maintainer, Lasse Collin, on the mailing list to bring in help. By early 2023 Jia Tan is co-maintaining the project and publishing releases.
- xz 5.6.0 is released, with binary "test files" containing the backdoor and a modified build script in the release tarball only.
- xz 5.6.1 is released, adjusting the backdoor. Both versions enter testing and rolling distributions.
- Andres Freund reports the backdoor on the oss-security mailing list. CVE-2024-3094 is assigned with a CVSS score of 10.0. CISA issues an alert the same day.
- Distributions roll back to 5.4.x. Affected releases included Fedora Rawhide and Fedora 41, Debian testing and unstable, Kali Linux and openSUSE Tumbleweed. Stable releases such as RHEL and Debian stable were not affected.
Root cause
The technical payload was clever, but the root cause was a trust failure. Every check that would normally catch malicious code was in the hands of the attacker.
The person reviewing was the attacker
In a project with one overworked maintainer, a new co-maintainer's commits and releases face little independent review. The pressure campaign from sock-puppet accounts made the handover look like the community's wish.
The release didn't match the source
The activating code was in build-to-host.m4, a build macro included in the release tarballs but not in the git repository. Reviewers reading the source on GitHub would not see it. Projects using autotools routinely ship generated files in tarballs, so the difference was not suspicious.
Payload disguised as test data
The backdoor lived in two binary files, bad-3-corrupt_lzma2.xz and good-large_compressed.lzma, presented as test cases for corrupted archives. Nobody reads binary test fixtures. The build script extracted and decoded them only when building packages on x86-64 Linux with glibc, which narrowed the target to distribution builds.
The hook
Using a glibc feature called IFUNC, the malicious liblzma replaced OpenSSL's RSA_public_decrypt in sshd while the program loaded. When a client authenticated with a certificate carrying a payload signed by the attacker's Ed448 key, the backdoor executed the embedded command before any login took place. Without that private key nobody else could use it.
Mitigation
- Check your version. Run
xz --version. Versions 5.6.0 and 5.6.1 are compromised. - Downgrade to a known-good release. Distributions shipped xz 5.4.x (or a clean rebuild) as the fix. Apply your distribution's update rather than building your own.
- Treat exposed hosts as suspect. If a system ran an affected version with sshd reachable from the internet, CISA and distributions advised treating it as potentially compromised: rebuild it and rotate the keys and credentials stored on it.
- Check build and CI images too. Rolling distributions are common in containers and build runners, which are easy to forget.
Prevention
For projects and distributions
- Make release artifacts reproducible from source. Build tarballs from the tagged repository in CI, and have distributions compare published tarballs with the git tree. The extra build file would have shown up.
- Treat binary test files as code. Document how each was generated, and generate them in the build where possible.
- Reduce what loads into sensitive processes. After this incident systemd moved to loading compression libraries only when needed (via
dlopen), so sshd no longer pulled in liblzma. - Fund and staff critical projects. A single unpaid maintainer is a single point of failure. Several maintainers who review each other's releases are a control, not a luxury.
For organisations
- Keep an inventory of what you run (a software bill of materials) so you can answer "do we have xz 5.6.x?" in minutes.
- Keep production off rolling and testing releases, and keep SSH off the public internet: put it behind a VPN or a bastion host.
- Watch for performance anomalies. This backdoor was caught by benchmarking, not by a security tool. Unexplained slowdowns in sensitive services deserve a look.
Sources
Change here for
-
SolarWinds
Build server breachedTargets spied on
SolarWinds SUNBURST: the signed update that carried a spy
The supply chain attack that wasn't caught in time.
-
Log4Shell
Exposed onlineAttacker runs commands
Log4Shell: how one logged line of text handed over the server
Another open-source library inside almost everything.
-
CrowdStrike
New template type8.5 million PCs crash
How one faulty content update crashed 8.5 million Windows PCs
A trusted update with no attacker involved at all.