oss-sec mailing list archives
Re: backdoor in upstream xz/liblzma leading to ssh server compromise
From: Solar Designer <solar () openwall com>
Date: Fri, 29 Mar 2024 22:46:15 +0100
On Fri, Mar 29, 2024 at 12:19:26PM -0700, Andres Freund wrote:
On 2024-03-29 19:44:05 +0100, Matthias Weckbecker wrote:I've attached a yara rule to detect the *.o droplet you attached in the email (liblzma_la-crc64-fast.o.gz).Unfortunately xz 5.61 added further obfuscations, making it harder to detect. Should have made it clearer that the attached .o was from 5.60. Among others 5.61 removed the two symbols you're checking against here. That's why Vegard's script looks for a specific instructions sequence, but obviously is also more obscure :/
Andres, maybe you (or Florian or someone else) can post the .o file from 5.61 as well (gzipped just like the previous one, please)? On Fri, Mar 29, 2024 at 08:51:26AM -0700, Andres Freund wrote:
openssh does not directly use liblzma. However debian and several other distributions patch openssh to support systemd notification, and libsystemd does depend on lzma.
It is indeed a security risk that sshd on major distros brings in so many libraries. For example, on RHEL 9.x and its rebuilds, "ldd sshd" is 28 lines. In the Rocky Linux SIG/Security override package, we've so far reduced this to 13 lines, which is still a lot: https://sig-security.rocky.page/packages/openssh For systemd notification, I patched it (half a year ago, so not in response to these new findings) to dlopen() libsystemd into a new sshd child process that's briefly spawned on sshd service startup or restart, notifies systemd, and exits. I could probably also drop privileges in that child process, but so far I didn't bother. I just didn't want those libraries to stay in the process address space after startup. Luckily, RHEL is not affected by the xz backdoor anyway, but if it were I think these changes would just happen to have prevented the backdoor from working. Indeed, it's still bad code that could run as root (and even if not in sshd, then in other services that use libsystemd), so it could have as well e.g. modified sshd on disk, but its current way of dynamically plugging into sshd authentication wouldn't work. I've attached the patch, which applies on top of Red Hat's patches. If using it in a package, explicit dependency on libsystemd (or the package that provides it) should be added to the (sub)package with sshd, e.g.: Requires: systemd-libs That's because the package manager would no longer automatically detect the dependency, which is now a soft one. I took this approach back then in order not to drop functionality, but I'd re-think it now. Perhaps systemd notification isn't worth even the reduced risk, and should be dropped completely. For the latter, an edit to the systemd unit file is needed, changing "Type=notify" to "Type=simple", which should fit "sshd -D". Not only Red Hat'ish distros, but also Debian and Ubuntu are similar in this respect, and I think should want to make similar changes. Alexander
Attachment:
openssh-8.7p1-rocky-systemd.patch
Description:
Current thread:
- Re: Re: backdoor in upstream xz/liblzma leading to ssh server compromise, (continued)
- Re: Re: backdoor in upstream xz/liblzma leading to ssh server compromise Loganaden Velvindron (Mar 30)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Solar Designer (Mar 31)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Alexander E. Patrakov (Mar 29)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Alexander E. Patrakov (Mar 29)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Rein Fernhout (Levitating) (Mar 29)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise terraminator (Mar 29)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Alexander E. Patrakov (Mar 29)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Rein Fernhout (Levitating) (Mar 29)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Matthias Weckbecker (Mar 29)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Andres Freund (Mar 29)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Loganaden Velvindron (Mar 29)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Solar Designer (Mar 29)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Demi Marie Obenour (Mar 29)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Solar Designer (Mar 29)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Solar Designer (Mar 31)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Michael Tokarev (Mar 31)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Andres Freund (Mar 29)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Rein Fernhout (Levitating) (Mar 29)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Andres Freund (Mar 29)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Rein Fernhout (Levitating) (Mar 30)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Matthias Weckbecker (Mar 30)
- Re: backdoor in upstream xz/liblzma leading to ssh server compromise Solar Designer (Mar 29)