News for hackers. Stuff that matters.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by bonyt on Friday March 29, 2024 @12:58PM (#39866307)
For those panicking, here are some key things to look for, based on the writeup:

- A very recent version of liblzma5 - 5.6.0 or 5.6.1. This was added in the last month or so. If you're not on a rolling release distro, your version is probably older.

- A debian or RPM based distro of Linux on x86_64. In an apparent attempt to make reverse engineering harder, it does not seem to apply when built outside of deb or rpm packaging. It is also specific to Linux.

- Running OpenSSH sshd from systemd. OpenSSH as patched by some distros only pulls in libsystemd for logging functionality, which pulls in the compromised liblzma5.

Debian testing already has a version called '5.6.1+really5.4.5-1' that is really an older version 5.4, repackaged with a newer version to convince apt that it is in fact an upgrade.

It is possible there are other flaws or backdoors in liblzma5, though.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by pdw on Friday March 29, 2024 @04:46PM (#39868804)
Focusing on sshd is the wrong approach. The backdoor was in liblzma5. It was discovered to attack sshd, but it very likely had other targets as well. The payload hasn't been analyzed yet, but _almost everything_ links to libzma5. Firefox and Chromium do. Keepassxc does. And it might have made arbitrary changes to your system, so installing the security update might not remove the backdoor.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by junon on Friday March 29, 2024 @07:01PM (#39869961)
From what I'm understanding it's trying to patch itself into the symbol resolution step of ld.so specifically for libcrypto under systemd on x86_64. Am I misreading the report?

That's a strong indication it's targeting sshd specifically.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by pdw on Friday March 29, 2024 @07:14PM (#39870087)
Lots of software links both liblzma and libcrypto. As I read Andres Freund's report, there is still a lot of uncertainty:

"There's lots of stuff I have not analyzed and most of what I observed is purely from observation rather than exhaustively analyzing the backdoor code."

"There are other checks I have not fully traced."

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by lostmsu on Sunday March 31, 2024 @03:02AM (#39882077)
As mentioned many times in other places now, this account had control over xz code for 2 years. The discovered CVE might be just a tip of an iceberg.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by saagarjha on Saturday March 30, 2024 @09:49AM (#39874862)
It checks for argv[0] == "sshd"
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by treffer on Friday March 29, 2024 @01:26PM (#39866676)
Ubuntu still ships 5.4.5 on 24.03 (atm).

I did a quick diff of the source (.orig file from packages.ubuntu.com) and the content mostly matched the 5.4.5 github tag except for Changelog and some translation files. It does match the tarball content, though.

So for 5.4.5 the tagged release and download on github differ.

It does change format strings, e.g.

   +#: src/xz/args.c:735
   +#, fuzzy
   +#| msgid "%s: With --format=raw, --suffix=.SUF is required unless writing to stdout"
   +msgid "With --format=raw, --suffix=.SUF is required unless writing to stdout"
   +msgstr "%s: amb --format=raw, --suffix=.SUF és necessari si no s'escriu a la sortida estàndard"
There is no second argument to that printf for example. I think there is at least a format string injection in the older tarballs.

[Edit] formatting

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by mort96 on Friday March 29, 2024 @02:41PM (#39867517)
FYI, your formatting is broken. Hacker News doesn't support backtick code blocks, you have to indent code.

Anyway, so... the xz project has been compromised for a long time, at least since 5.4.5. I see that this JiaT75 guy has been the primary guy in charge of at least the GitHub releases for years. Should we view all releases after he got involved as probably compromised?

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by treffer on Friday March 29, 2024 @03:07PM (#39867790)
Thank you, formatting fixed.

My TLDR is that I would regard all commits by JiaT75 as potentially compromised.

Given the ability to manipulate gitnhistory I am not sure if a simple time based revert is enough.

It would be great to compare old copies of the repo with the current state. There is no guarantee that the history wasn't tampered with.

Overall the only safe action would IMHO to establish a new upstream from an assumed good state, then fully audit it. At that point we should probably just abandon it and use zstd instead.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by tomrod on Friday March 29, 2024 @06:29PM (#39869690)
Not just Jia. There are some other accounts of concern with associated activity or short term/bot-is names.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by jdright on Saturday March 30, 2024 @07:41AM (#39873900)
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by account42 on Wednesday April 03, 2024 @09:03AM (#39916911)
Interesting, this would suggest exploits other than the known sshd one.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by ogurechny on Friday March 29, 2024 @07:13PM (#39870079)
Zstd belongs to the class of speed-optimized compressors providing “tolerable” compression ratios. Their intended use case is wrapping some easily compressible data with negligible (in the grand scale) performance impact. So when you have a server which sends gigabits of text per second, or caches gigabytes of text, or processes a queue with millions of text protocol messages, you can add compression on one side and decompression on the other to shrink them without worrying too much about CPU usage.

Xz is an implant of 7zip's LZMA(2) compression into traditional Unix archiver skeleton. It trades long compression times and giant dictionaries (that need lots of memory) for better (“much-better-than-deflate”) compression ratios. Therefore, zstd, no matter how fashionable that name might be in some circles, is not a replacement for xz.

It should also be noted that those LZMA-based archive formats might not be considered state-of-the-art today. If you worry about data density, there are options for both faster compression at the same size, and better compression in the same amount of time (provided that data is generally compressible). 7zip and xz are widespread and well tested, though, and allow decompression to be fast, which might be important in some cases. Alternatives often decompress much slowly. This is also a trade-off between total time spent on X nodes compressing data, and Y nodes decompressing data. When X is 1, and Y is in the millions (say, software distribution), you can spend A LOT of time compressing even for relatively minuscule gains without affecting the scales.

It should also be noted that many (or most) decoders of top compressing archivers are implemented as virtual machines executing chains of transform and unpack operations defined in archive file over pieces of data also saved there. Or, looking from a different angle, complex state machines initializing their state using complex data in the archive. Compressor tries to find most suitable combination of basic steps based on input data, and stores the result in the archive. (This is logically completed in neural network compression tools which learn what to do with data from data itself.) As some people may know, implementing all that byte juggling safely and effectively is a herculean task, and compression tools had exploits in the past because of that. Switching to a better solution might introduce a lot more potentially exploited bugs.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by treffer on Friday March 29, 2024 @07:51PM (#39870322)
Arch Linux switched switched from xz to zstd, with neglectable increase in size (<1%) but massive speedup on decompression. This is exactly the use case of many people downloading ($$$) and decompressing. It is the software distribution case. Other distributions are following that lead.

You should use ultra settings and >=19 as the compression level. E.g. arch used 20 and higher compression levels do exist, but they were already at a <1% increase.

It does beat xz for these tasks. It's just not the default settings as those are indeed optimized for the lzo to gzip/bzip2 range.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by the8472 on Friday March 29, 2024 @08:39PM (#39870644)
Note that the xz CLI does not expose all available compression options of the library. E.g. rust release tarballs are xz'd with custom compression settings. But yeah, zstd is good enough for many uses.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by ogurechny on Friday March 29, 2024 @09:31PM (#39870993)
My bad, I was too focused on that class in general, imagining “lz4 and friends”.

Zstd does reach LZMA compression ratios on high levels, but compression times also drop to LZMA level. Which, obviously, was clearly planned in advance to cover both high speed online applications and slow offline compression (unlike, say, brotli). Official limit on levels can also be explained by absence of gains on most inputs in development tests.

Distribution packages contain binary and mixed data, which might be less compressible. For text and mostly text, I suppose that some old style LZ-based tools can still produce an archive roughly 5% percent smaller (and still unpack fast); other compression algorithms can certainly squeeze it much better, but have symmetric time requirements. I was worried about the latter kind being introduced as a replacement solution.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by account42 on Wednesday April 03, 2024 @08:59AM (#39916856)
> the lzo to gzip/bzip2 range

bzip2 is a pig that has no place being in the same sentence as lzo and gzip. It's nieche was maximum compression no matter the speed but it hasn't been relevant even there for a long time.

Yet tools still need to support bzip2 because bzip2 archives are still out there and are still being produced. So we can't get rid of libbz2 anytime soon - same for liblzma.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by shanipribadi on Saturday March 30, 2024 @12:59AM (#39871961)
Looking forward to the time when Meta will make https://github.com/facebookincubator/zstrong.git public

found it mentioned in https://github.com/facebook/proxygen/blob/main/build/fbcode_..., looks like it's going to be cousin of zstd, but maybe for the stronger compression use cases

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by joveian on Friday March 29, 2024 @10:21PM (#39871251)
Note that zstd (the utility) currently links to liblzma since it can compress and decompress other formats.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by account42 on Wednesday April 03, 2024 @09:04AM (#39916922)
Lol as if there weren't enough general archivers already.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by account42 on Wednesday April 03, 2024 @08:52AM (#39916787)
> Given the ability to manipulate gitnhistory I am not sure if a simple time based revert is enough.

Rewritten history is not a real concern because it would have been immediately noticed by anyone updating an existing checkout.

> Overall the only safe action would IMHO to establish a new upstream from an assumed good state, then fully audit it. At that point we should probably just abandon it and use zstd instead.

This is absurd and also impossible without breaking backwards compatibility all over the place.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by chasil on Friday March 29, 2024 @02:40PM (#39867512)
RHEL9 is shipping 5.2.5; RHEL8 is on 5.2.4.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by fransje26 on Friday March 29, 2024 @01:36PM (#39866807)
Thanks for the heads up.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by jwilk on Friday March 29, 2024 @05:01PM (#39868962)
"#, fuzzy" means the translation is out-of-date and it will be discarded at compile time.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by treffer on Friday March 29, 2024 @05:26PM (#39869197)
I tried to get the translation to trigger by switching to french and it does not show. You are right.

So it's just odd that the tags and release tarballs diverge.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by blcknight on Friday March 29, 2024 @02:01PM (#39867098)
> Debian testing already has a version called '5.6.1+really5.4.5-1' that is really an older version 5.4, repackaged with a newer version to convince apt that it is in fact an upgrade.

I'm surprised .deb doesn't have a better approach. RPM has epoch for this purpose http://novosial.org/rpm/epoch/index.html

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by stefanor on Friday March 29, 2024 @02:15PM (#39867242)
Debian has epochs, but it's a bad idea to use them for this purpose.

Two reasons:

1. Once you bump the epoch, you have to use it forever. 2. The deb filename often doesn't contain the epoch (we use a colon which isn't valid on many filesystems), so an epoch-revert will give the same file name as pre-epoch, which breaks your repository.

So, the current best practice is the +really+ thing.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by kzrdude on Friday March 29, 2024 @04:04PM (#39868415)
Thanks for the info, the filename thing sounds like a problem, one aspect of the epoch system doesn't work for the purpose then.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by o11c on Friday March 29, 2024 @03:01PM (#39867723)
Honestly, the Gentoo-style global blacklist (package.mask) to force a downgrade is probably a better approach for cases like this. Epochs only make sense if your upstream is insane and does not follow a consistent numbering system.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by account42 on Wednesday April 03, 2024 @09:10AM (#39917003)
Gentoo also considers the repository (+overlays) to be the entire set of possible versions so simply removing the bad version will cause a downgrade, unlike debian and RPM systems where installing packages outside a repository is supported.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by intel_brain on Friday March 29, 2024 @02:31PM (#39867424)
Got this on OpenSUSE: `5.6.1.revertto5.4-3.2`
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by debianisajoke32 on Friday April 05, 2024 @12:50AM (#39938770)
Stop the cap your honor. There is not a single filesystem that prevents you from using colons in filenames except exfat, I went ahead and checked and ext4, xfs, btrfs, zfs, and even reiserfs let you use any characters you want except \0 and /.

And I fail to see why bumping the epoch would ever be a problem. Using the epoch not a reason why its bad.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by nicolas_17 on Friday March 29, 2024 @02:14PM (#39867234)
.deb has epochs too, but I think Debian developers avoid it where possible because 1:5.4.5 is interpreted as newer than anything without a colon, so it would break eg. packages that depend on liblzma >= 5.0, < 6. There may be more common cases that aren't coming to mind now.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by account42 on Wednesday April 03, 2024 @09:09AM (#39916978)
Seems like debian is mixing too many things into the package version - version used for deciding on upgrades and abi version for dependencies should be decoupled like it is in modern RPM distros.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by nicolas_17 on Wednesday April 03, 2024 @12:00PM (#39919147)
If a binary library ABI is backwards-incompatible, they change the package name. I was just guessing at the reason epoch is avoided and that <6 is probably an awful example.

So now I actually bothered to look it up, and it turns out the actual reason is that the epoch changes what version is considered "greater", but it's not part of the .deb filename, so you still can't reuse version numbers used in the past. If you release 5.0, then 5.1, then you want to rollback and release 1:5.0, it's going to break things in the Debian archives. https://www.debian.org/doc/debian-policy/ch-binary.html#uniq...

Additionally, once you add an epoch you're stuck with it forever, while if you use 5.1+really5.0, you can get rid of the kludge when 5.2 is out. https://www.debian.org/doc/debian-policy/ch-controlfields.ht...

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by pja on Friday March 29, 2024 @02:06PM (#39867143)
Debian packages can have epochs too. I’m not sure why the maintainers haven’t just bumped the epoch here.

Maybe they’re expecting a 5.6.x release shortly that fixes all these issues & don’t want to add an epoch for a very short term packaging issue?

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by 5p4n911 on Friday March 29, 2024 @05:06PM (#39869021)
I really like the XBPS way of the reverts keyword in the package template that forces a downgrade from said software version. It's simple but works without any of the troubles RPM epochs have with resolving dependencies as it's just literally a way to tell xbps-install that "yeah, this is a lower version number in the repository but you should update anyway".
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by fransje26 on Friday March 29, 2024 @01:34PM (#39866782)
I did notice that my debian-based system got noticeably slower and unresponsive at times the last two weeks, without obvious reasons. Could it be related?

I read through the report, but what wasn't directly clear to me was: what does the exploit actually do?

My normal internet connection has such an appalling upload that I don't think anything relevant could be uploaded. But I will change my ssh keys asap.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by anarazel on Friday March 29, 2024 @01:58PM (#39867057)
> I did notice that my debian-based system got noticeably slower and unresponsive at times the last two weeks, without obvious reasons. Could it be related?

Possible but unlikely.

> I read through the report, but what wasn't directly clear to me was: what does the exploit actually do?

It injects code that runs early during sshd connection establishment. Likely allowing remote code execution if you know the right magic to send to the server.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by fransje26 on Friday March 29, 2024 @04:37PM (#39868739)
Thank you for the explanation.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by cpach on Friday March 29, 2024 @02:08PM (#39867162)
Are you on stable/testing/unstable?

With our current knowledge, stable shouldn’t be affected by this.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by fransje26 on Friday March 29, 2024 @04:35PM (#39868717)
Stable, luckily. Thank you for the information.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by idoubtit on Friday March 29, 2024 @01:35PM (#39866804)
The article gives a link to a simple shell script that detects the signature of the compromised function.

> Running OpenSSH sshd from systemd

I think this is irrelevant.

From the article: "Initially starting sshd outside of systemd did not show the slowdown, despite the backdoor briefly getting invoked." If I understand correctly the whole section, the behavior of OpenSSH may have differed when launched from systemd, but the backdoor was there in both cases.

Maybe some distributions that don't use systemd strip the libxz code from the upstream OpenSSH release, but I wouldn't bet on it if a fix is available.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by anarazel on Friday March 29, 2024 @01:56PM (#39867039)
> From the article: "Initially starting sshd outside of systemd did not show the slowdown, despite the backdoor briefly getting invoked." If I understand correctly the whole section, the behavior of OpenSSH may have differed when launched from systemd, but the backdoor was there in both cases.

It looks like the backdoor "deactivates" itself when it detects being started interactively, as a security researcher might. I was eventually able to circumvent that, but unless you do so, it'll not be active when started interactively.

However, the backdoor would also be active if you started it with an shell script (as the traditional sys-v rc scripts did) outside the context of an interactive shell, as TERM wouldn't be set either in that context.

> Maybe some distributions that don't use systemd strip the libxz code from the upstream OpenSSH release, but I wouldn't bet on it if a fix is available.

There's no xz code in openssh.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by bonyt on Friday March 29, 2024 @01:47PM (#39866929)
I think the distributions that do use systemd are the ones that add the libsystemd code, which in turn brings in the liblzma5 code. So, it may not be entirely relevant how it is run, but it needs to be a version of OpenSSH patched.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by nwallin on Saturday March 30, 2024 @06:36AM (#39873540)
> Maybe some distributions that don't use systemd strip the libxz code from the upstream OpenSSH release, but I wouldn't bet on it if a fix is available.

OpenSSH is developed by the OpenBSD project, and systemd is not compatible with OpenBSD. The upstream project has no systemd or liblzma code to strip. If your sshd binary links to liblzma, it's because the package maintainers for your distro have gone out of their way to add systemd's patch to your sshd binary.

> From the article: "Initially starting sshd outside of systemd did not show the slowdown, despite the backdoor briefly getting invoked." If I understand correctly the whole section, the behavior of OpenSSH may have differed when launched from systemd, but the backdoor was there in both cases.

From what I understand, the backdoor detects if it's in any of a handful of different debug environments. If it's in a debug environment or not launched by systemd, it won't hook itself up. ("nothing to see here folks...") But if sshd isn't linked to liblzma to begin with, none of the backdoor's code even exists in the processes' page maps.

I'm still downgrading to an unaffected version, of course, but it's nice to know I was never vulnerable just by typing 'ldd `which sshd`' and not seeing liblzma.so.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by hostyle on Friday March 29, 2024 @01:31PM (#39866741)
$ dpkg-query -W liblzma5

liblzma5:amd64 5.4.1-0.2

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by NotPractical on Friday March 29, 2024 @03:15PM (#39867877)
> If you're not on a rolling release distro, your version is probably older.

Ironic considering security is often advertised as a feature of rolling release distros. I suppose in most instances it does provide better security, but there are some advantages to Debian's approach (stable Debian, that is).

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by javajosh on Saturday March 30, 2024 @01:15AM (#39872032)
>Ironic considering security is often advertised as a feature of rolling release distros.

Security is a feature of rolling release. But supply-chain attacks like this are the exception to the rule.

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by yreg on Saturday March 30, 2024 @07:05AM (#39873704)
Isn't that what security-updates-only is for?

This particular backdoor is not shipped inside of a security patch, right?

Re:Backdoor in upstream xz/liblzma leading to SSH server com... by leeoniya on Saturday March 30, 2024 @02:19AM (#39872318)
i mean, rolling implies rolling 0-days, too.
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by rathermucker on Saturday March 30, 2024 @09:23PM (#39880464)
Tumbleweed has a package: liblzma5-5.6.1.revertto5.4-3.2.x86_64 FYI
Re:Backdoor in upstream xz/liblzma leading to SSH server com... by account42 on Wednesday April 03, 2024 @09:17AM (#39917063)
revertto probably just means "revert to" but it does sound quite italian lol.