Malspec

Famous hacks, and how they were fixed.

Supply chainIncident report

The xz backdoor: how a half-second delay caught a two-year con

A trusted co-maintainer hid a backdoor in the xz compression library; one engineer's curiosity caught it before stable Linux releases shipped it.

Illustration: software boxes on a conveyor into a server, a magnifying glass revealing a hidden red mechanism in one box, a stopwatch with a half-second sliver, and a green rollback arrow.

In March 2024 a software engineer chasing a half-second slowdown on his computer uncovered a backdoor hidden inside xz, a small compression library that sits on almost every Linux system. It had been planted by a trusted co-maintainer who had spent about two years earning that trust. The backdoor had reached only test and rolling versions of a few Linux distributions, and within hours of his report they rolled xz back to a clean version. It came very close to shipping in the stable releases that run much of the internet's servers.

When: March 2024 Hit: Test and rolling versions of several Linux distributions; caught before stable releases Way in: A backdoor hidden in xz release files by a trusted co-maintainer Found by: Andres Freund, a Microsoft engineer and PostgreSQL developer Fixed by: Distributions rolling back to clean xz versions (CVE-2024-3094) Time to fix: Hours to days after disclosure

What happened

xz Utils is a free, open-source compression tool, and its library, liblzma, is used by many other programs on Linux. For most of its life it was looked after by one volunteer, Lasse Collin, in his spare time.

From 2021 a contributor using the name Jia Tan began sending useful patches. Over the following year, other accounts that had never appeared before posted on the project's mailing list complaining that progress was slow and pressing Collin to bring on another maintainer. Jia Tan gradually gained more responsibility and by 2023 was making releases.

In February and March 2024 Jia Tan released xz versions 5.6.0 and 5.6.1. Both contained a carefully hidden backdoor aimed at OpenSSH, the program that lets administrators log in to servers remotely. Fast-moving distributions such as Debian unstable and testing, Fedora Rawhide and the Fedora 41 development branch, openSUSE Tumbleweed and Kali picked the new versions up. Stable releases, which most servers run, had not yet updated.

On 29 March 2024 Andres Freund published what he had found on the oss-security mailing list. The real identity of Jia Tan, and of the accounts that pushed for them, is still unknown.

How it worked

The backdoor was built to avoid the places reviewers look. The malicious code was not in the project's readable source code. It was hidden inside binary files that looked like test data for the compression code, and it was switched on by a small change to a build script. That change appeared only in the release packages people downloaded, not in the project's public source history.

When a Linux distribution built xz from those release packages on certain systems, the build quietly mixed the hidden code into liblzma. OpenSSH does not use liblzma directly, but several distributions patch OpenSSH to talk to systemd, and that pulls liblzma in. Through that chain, the hidden code could interfere with how OpenSSH checked logins.

The result, as later analysis showed, was that someone holding a specific secret key could send commands to an affected server during login and have them run, before any authentication. Without that key the backdoor did nothing visible, which made it very hard to detect from the outside.

How it was discovered

The backdoor was found by someone who was not looking for it.

Andres Freund, a Microsoft engineer who works on the PostgreSQL database, was running performance tests on a Debian test system in March 2024. He noticed that SSH logins were using an unusual amount of CPU, even failed logins from the random bots that constantly probe servers on the internet. Each login was about half a second slower than it should have been.

Most people would have shrugged at half a second. Freund profiled the slow logins and found the time going into liblzma, a compression library that SSH had no obvious reason to be using. Earlier he had also seen odd errors from Valgrind, a tool that checks programs for memory mistakes, after xz was updated.

Following that thread, he found the altered build script and the hidden code in the test files. He told the Linux distributions' security teams privately, then published his findings on the oss-security mailing list on 29 March so that everyone running the affected versions could act at once.

The timeline

2021 · A contributor named Jia Tan starts sending patches

The new contributor's early work is helpful and unremarkable, the kind of help a project run by one volunteer is glad to get.

2022 · Pressure grows and Jia Tan becomes a co-maintainer

Previously unknown accounts complain on the mailing list about slow progress and urge the maintainer to hand over more control. Jia Tan takes on a bigger role.

2024-02-24 · xz 5.6.0 is released with the hidden backdoor

The release packages carry the disguised test files and the altered build script. Rolling distributions begin to pick it up.

2024-03-09 · xz 5.6.1 follows

A second release changes the hidden code, which had been causing errors in some testing tools.

2024-03-29 · Andres Freund raises the alarm and distributions roll back

While benchmarking an unrelated project on Debian unstable, Freund notices SSH logins using unusual amounts of CPU and taking about half a second longer, along with errors from a memory-checking tool. He traces the cause to liblzma and posts his findings. The same day, CISA tells users to downgrade, and distributions begin shipping clean versions of xz.

How it was fixed

The fix was a rollback. Affected distributions replaced 5.6.0 and 5.6.1 with an earlier version from before the backdoor, such as 5.4.6, and told users of testing and rolling releases to update at once. Red Hat warned Fedora Rawhide and Fedora 41 users to stop using affected systems for anything sensitive. CISA issued an alert the same day. GitHub suspended the xz repository while the code was examined.

Lasse Collin, who had not been involved in the backdoor, published a detailed account of what had happened, removed Jia Tan's access and the malicious files, and later released a clean version, 5.6.2.

Because the backdoor had not reached the stable releases that most servers run, the damage was very limited. Security researchers spent the following weeks reverse-engineering the hidden code to confirm exactly what it did and which systems it could have reached.

What changed after

The xz case showed that the biggest risk in open source can be a maintainer's trust, not a coding mistake. In April 2024 the OpenSSF and the OpenJS Foundation warned that other projects had seen similar attempts: friendly newcomers and outside pressure aimed at gaining maintainer access. They published signs to watch for.

It gave new energy to reproducible builds, where anyone can rebuild a release from its public source and check that the result matches byte for byte. If release packages had been compared with the source repository, the altered build script would have stood out. Several distributions began checking more carefully that what they package matches the public source.

It also renewed attention to how much critical software rests on unpaid volunteers. A burned-out lone maintainer is an easy target for someone patient enough to offer help.

Lessons that still apply

  • Build from source you can see. Prefer building from the public source repository, or check that release packages match it.
  • Know your dependency chain. OpenSSH was exposed through a library it never used directly. Map what your critical services actually load.
  • Investigate small oddities. The backdoor was caught because someone looked into half a second of delay instead of ignoring it.
  • Support the maintainers you rely on. Help with time, money or review, so no critical project rests on one tired person.

Sources

The fix → A rollback in hours, caught by one engineer who would not ignore half a second.

Share this