Malhar Ujawane

Blog

Explainer·(updated October 31, 2026)

The xz backdoor explained: CVE-2024-3094 step by step

The xz backdoor (CVE-2024-3094) hid in xz 5.6.0 and 5.6.1 release tarballs to hook sshd. How it worked, how it was caught, and a tarball diff in Python.

The xz backdoor explained: CVE-2024-3094 step by step

The xz backdoor (CVE-2024-3094) was malicious code planted in the release tarballs of xz-utils 5.6.0 and 5.6.1, the compression library almost every Linux distribution ships. On x86-64 Linux systems that built it as a Debian or RPM package, it modified liblzma so that, loaded into OpenSSH’s server through a systemd patch, it intercepted RSA signature checks before authentication. Andres Freund found it on March 29, 2024 because SSH logins on his Debian test machine had become half a second slower.

What makes it the reference case for supply chain attacks is how it got in. No server was hacked and no credentials were stolen. A contributor spent more than two years earning maintainer rights on an under-resourced project, then shipped the backdoor in signed releases under their own name.

How was the xz backdoor discovered?

By accident, and by someone measuring the right thing. Freund’s post to oss-security (March 29, 2024) opens with the symptoms: “logins with ssh taking a lot of CPU, valgrind errors” on Debian sid machines “over the last weeks”. He timed a login attempt for a user that doesn’t exist. Before the upgrade it took 0.299 seconds; with the backdoored liblzma, 0.807 seconds.

That half second is the whole detection story. There was no signature, no scanner hit, no anomaly alert. An engineer doing performance work noticed sshd was burning CPU it shouldn’t, followed the valgrind errors into liblzma, and kept pulling the thread. His conclusion, in the second paragraph of the post: “The upstream xz repository and the xz tarballs have been backdoored.”

Red Hat assigned CVE-2024-3094, NVD published it the same day, and NVD scores it 10.0. CISA’s alert told users to “downgrade XZ Utils to an uncompromised version”, naming 5.4.6 Stable.

How did the xz backdoor work?

It came in three layers, and each one was built to survive a different kind of review.

1. Payload in git, disguised as test data. Two binary files, tests/files/bad-3-corrupt_lzma2.xz and tests/files/good-large_compressed.lzma, were committed to the public repository by Jia Tan on February 23, 2024 in a commit titled “Tests: Add a few test files.” Corrupt-input test files are normal for a compression library, and nobody reads binary blobs in a diff. Freund notes “the files were not even used for any “tests” in 5.6.0.“

2. Trigger only in the release tarball. The line that unpacks the payload lives in m4/build-to-host.m4, an autotools macro file. Freund: “That line is not in the upstream source of build-to-host, nor is build-to-host used by xz in git.” It appeared only in the tarballs the maintainer uploaded, not in the “source code” archives GitHub generates from the tag. Anyone who reviewed the repository saw nothing. Anyone who built from the tarball, which is what distribution packagers do, ran it.

3. Narrow targeting. At the end of configure, the injected script checks its environment and quietly exits unless the build is x86-64 Linux with gcc and the GNU linker, running inside a Debian or RPM package build (debian/rules present, or RPM_ARCH=x86_64). Freund’s read is that the last condition was “likely aimed at making it harder to reproduce the issue for investigators”. When it does fire, it rewrites the liblzma Makefile so the build extracts an object file from the test blobs and links it into liblzma.

At runtime, the NVD description summarizes the result: a modified liblzma “intercepting and modifying the data interaction with this library”. The path into SSH is indirect. OpenSSH doesn’t use liblzma. But Debian and several other distributions patch sshd to send readiness notifications to systemd, libsystemd depends on liblzma, and so liblzma gets loaded into sshd. Once there, the backdoor installs a dynamic linker audit hook, waits for RSA_public_decrypt to be resolved and redirects it to its own code. Freund’s perf trace shows RSA_public_decrypt landing inside liblzma.so.5.6.0. Because that check runs before authentication, he judged it “likely to allow some form of access or other form of remote code execution”. He also found it switched itself off if TERM was set or when common debugging variables like LD_DEBUG were present.

Who was Jia Tan?

Nobody knows, and that’s the uncomfortable part. Russ Cox’s timeline of the attack, built from public mailing list archives and git history, shows the pattern. Jia Tan’s first patch to the xz-devel list arrived on October 29, 2021. Through 2022, accounts named Jigar Kumar and Dennis Ens pressed the original maintainer, Lasse Collin, to hand over work: “Progress will not happen until there is new maintainer.” In June 2022 Collin wrote that Jia Tan was “practically a co-maintainer already”. By March 2023 Jia Tan was tagging releases.

The 5.6.0 tag is dated February 24, 2024 and 5.6.1 March 9, 2024, both signed by Jia Tan. The Cox timeline records the follow-up: requests to get 5.6.x into Fedora, Debian and Ubuntu, and Debian unstable taking 5.6.1 on March 27, 2024. Freund’s post notes the bad versions had “not yet widely been integrated by linux distributions, and where they have, mostly in pre-release versions.” Collin’s own xz backdoor page confirms the tarballs were “created and signed by Jia Tan”, and clean releases followed on May 29, 2024.

How do you detect a tarball that differs from git?

The structural lesson is that what you build is not what you review. Distributions build from release tarballs, and autotools tarballs legitimately contain files that are not in git: configure, Makefile.in and a pile of .m4 macros generated at make dist time. A naive diff against the tag can’t tell a generated file from a tampered one.

This script shows both checks on a toy copy of the xz layout. Check 1 compares the tarball to the git tag and allows generated files. Check 2 regenerates those files from the tag (in real life, autoreconf -fi) and compares byte for byte.

# tarball_vs_git.py: diff a release tarball against the git tag it claims to come from.
# Python 3 stdlib only. File contents are toy stand-ins; the file names mirror xz 5.6.0.
import hashlib, io, tarfile

GIT_TREE = {  # what `git archive v5.6.0` would contain (abridged)
    "configure.ac": "AC_INIT([XZ Utils], [5.6.0])\n",
    "src/liblzma/check/crc64_fast.c": "/* crc64 */\n",
    "tests/files/bad-3-corrupt_lzma2.xz": "<binary test blob>\n",
    "tests/files/good-large_compressed.lzma": "<binary test blob>\n",
}
# Files autotools generates at `make dist` time; they exist only in tarballs.
EXPECTED_GENERATED = {"configure", "Makefile.in", "m4/libtool.m4", "m4/build-to-host.m4"}
REGENERATED = {  # what running autoreconf yourself on the git tree produces
    "configure": "#! /bin/sh\n# generated\n",
    "Makefile.in": "# generated\n",
    "m4/libtool.m4": "# libtool macros\n",
    "m4/build-to-host.m4": "# gnulib build-to-host macros\n",
}

def make_release_tarball():  # the maintainer's tarball: generated files plus one extra line
    files = dict(GIT_TREE, **REGENERATED)
    files["m4/build-to-host.m4"] += "# one extra line that runs a script hidden in tests/files\n"
    buf = io.BytesIO()
    with tarfile.open(fileobj=buf, mode="w:gz") as tar:
        for name, text in files.items():
            data = text.encode()
            info = tarfile.TarInfo(f"xz-5.6.0/{name}"); info.size = len(data)
            tar.addfile(info, io.BytesIO(data))
    return buf.getvalue()

def read_tarball(blob):
    with tarfile.open(fileobj=io.BytesIO(blob)) as tar:
        return {m.name.split("/", 1)[1]: tar.extractfile(m).read().decode() for m in tar if m.isfile()}

sha = lambda s: hashlib.sha256(s.encode()).hexdigest()[:12]
tarball = read_tarball(make_release_tarball())

print("check 1: tarball vs git tag")
for name in sorted(tarball):
    if name in GIT_TREE:
        status = "same" if sha(tarball[name]) == sha(GIT_TREE[name]) else "DIFFERS"
    else:
        status = "only in tarball (generated, expected)" if name in EXPECTED_GENERATED else "ONLY IN TARBALL"
    print(f"  {status:38} {name}")

print("check 2: tarball vs autoreconf run on the git tag")
reference = dict(GIT_TREE, **REGENERATED)
bad = [n for n in sorted(tarball) if sha(tarball[n]) != sha(reference.get(n, ""))]
for n in bad:
    print(f"  DIFFERS  {n}  tarball {sha(tarball[n])} vs rebuilt {sha(reference[n])}")
assert bad == ["m4/build-to-host.m4"]

Output (Python 3.13.11):

check 1: tarball vs git tag
  only in tarball (generated, expected)  Makefile.in
  only in tarball (generated, expected)  configure
  same                                   configure.ac
  only in tarball (generated, expected)  m4/build-to-host.m4
  only in tarball (generated, expected)  m4/libtool.m4
  same                                   src/liblzma/check/crc64_fast.c
  same                                   tests/files/bad-3-corrupt_lzma2.xz
  same                                   tests/files/good-large_compressed.lzma
check 2: tarball vs autoreconf run on the git tag
  DIFFERS  m4/build-to-host.m4  tarball 09d8eae30a97 vs rebuilt 0715f3286919

Check 1 passes everything, which is roughly the review the real tarball got. The test blobs are identical to git, because the payload really was in git, and the tampered macro hides among files that are supposed to be missing from the repository. Only check 2, regenerate and compare, flags it. That’s the argument for reproducible builds: if two independent parties can produce the same bytes from the same tagged source, a maintainer can’t slip in a file that the source doesn’t explain.

The script’s file contents are stand-ins. The names, the split between git and tarball, and which check catches it follow Freund’s description.

Why does the xz backdoor matter to a builder?

Because nothing in a normal security program would have caught it. The code was signed by the legitimate maintainer. It passed CI. It came from the official upstream. Dependency scanners look up known CVEs, and this one had no CVE until the day it was found. An SBOM would have told you that you shipped xz 5.6.1, which helps on day one of the response and does nothing to prevent it.

From a data-platform seat, the line I’d circle is the dependency path. The target was sshd, and sshd doesn’t depend on xz. A distribution patch pulled in libsystemd, which pulled in liblzma, which ran in a root process that accepts connections from the internet. Most teams can name their direct dependencies. Very few can name what gets loaded into their most privileged process three hops away.

It’s the mirror image of Log4Shell. Log4Shell was a feature with an unsafe default that nobody meant as a weapon. xz was a weapon built to look like routine maintenance. Both landed in the same place: a small open source project, maintained by very few people, sitting under a huge part of the internet.

What I would do

  1. Build from git tags where you can, and treat release tarballs as unreviewed code. If a project ships autotools tarballs, regenerate and diff, as check 2 does.
  2. Prune what loads into privileged processes. Run ldd on sshd, your ingress proxy and your agent runtimes, and ask why each library is there. Fewer libraries means fewer maintainers you are trusting.
  3. Pin and wait. Don’t take a new upstream release into production the week it ships unless it fixes something you need. Most of the damage was avoided because 5.6.x hadn’t reached stable releases yet. A short soak period is cheap, the same logic as a staged rollout.
  4. Investigate performance regressions you can’t explain. That’s how this one was caught. A half-second slowdown in a login path is a signal.
  5. Fund or staff your critical dependencies. The social engineering worked because one tired maintainer was being told the project was too slow. The same pressure shows up anywhere a team installs tools from strangers, including the MCP servers an agent loads.

FAQ

Which xz versions had the backdoor?

xz-utils 5.6.0 and 5.6.1, specifically their release tarballs. CISA recommended downgrading to 5.4.6, and the project published clean releases on May 29, 2024.

Was my server affected by CVE-2024-3094?

Probably not, unless it ran a rolling or pre-release distribution in March 2024. The backdoor needed x86-64 Linux with glibc, a Debian or RPM package build of xz 5.6.0 or 5.6.1, and an sshd linked to libsystemd. Freund wrote that the bad versions had mostly reached only pre-release distributions.

Who found the xz backdoor?

Andres Freund, who noticed slow SSH logins and valgrind errors on Debian sid and published his analysis on oss-security on March 29, 2024. Florian Weimer extracted the injected object file.

Could code review have caught it?

Not easily. The trigger was absent from git, and the payload was binary test data. Reproducible builds and a regenerate-and-diff check on tarballs would have flagged the modified build macro.

Sources

Get new posts in your inbox

© 2026 Malhar Ujawane. Built with Astro.