Debian changes OpenSSH packaging
In the wake of the XZ backdoor, the Debian project has revisited some of the patches included in its OpenSSH packages to improve security. The outcome of this is that the project will be splitting out support for Kerberos key exchange into a separate set of packages, though not until after the Debian 13 ("trixie") release expected next year. The impact on Debian users should be minimal, but it is an interesting look into the changes Linux distributions make to upstream software as well as some of the long-term consequences of those choices.
Patches revisited
In April, Colin Watson (one of the OpenSSH package maintainers for
Debian) started
a discussion on the debian-devel mailing list, saying that he was
"reconsidering some choices in Debian's OpenSSH packaging
"
because he hoped to configure the package "more wisely
within more or less our current constraints
". Watson did not
elaborate much beyond that, but it was patching OpenSSH to link to libsystemd
that made Debian and Fedora's packages vulnerable to the XZ backdoor,
which was still very fresh in everyone's mind at the time. See LWN's coverage of how the
XZ backdoor works for more detail.
Debian carries nearly 40 patches against OpenSSH, ranging from fairly large patches like the one that enables GSS-API and changes OpenSSH functionality to small documentation patches. Out of all of the patches Debian applies to OpenSSH, Watson identified four for discussion: the patches for libsystemd, SELinux, TCP wrappers, and Generic Security Service Application Program Interface (GSS-API), which is used to provide a vendor-independent method of authenticating against different Kerberos implementations.
At the time, he said that the libsystemd patch (actually called the
systemd-readiness
patch) was "the obvious
thing on everyone's mind right now
" due to its role in the XZ
backdoor. OpenSSH was patched so that it could notify systemd when it
was ready to accept connections, using the libsystemd library, which
in turn had a dependency on the liblzma library that was
compromised.
Watson said it had seemed reasonable to merge the patch when he did it,
but "we do seem to have ended up on the wrong side of history with that
one
". However, he noted that there was work to remove the
dependency on libsystemd itself, and to move the readiness protocol
upstream, "so we'll get rid of that linkage and reduce our patch load
a bit
".
Debian also compiles OpenSSH with support for SELinux, which
OpenSSH developer Damien Miller
said
should be in an alternate package (along with Kerberos/GSS-API) to reduce
exposure for the bulk of users who may not need the feature. However,
Watson said, "my inclination is to leave this [patch] be
", but
invited SELinux experts to weigh in. No SELinux experts turned up to
voice an opinion one way or another, and that
patch remains.
TCP wrappers
The idea of dropping support for TCP wrappers
drew more discussion. TCP wrappers is a system for filtering access to
services, such as OpenSSH, using host-based access-control lists
(ACLs) placed in /etc/hosts.deny and
/etc/hosts.allow. The upstream OpenSSH project dropped
support for TCP wrappers in 2014, just ahead of the Debian 8
("jessie") freeze. Watson said that he had patched it back in
"temporarily
" and then "dropped the ball on organizing a
proper transition
". He also noted that Fedora had dropped the use
of TCP wrappers in 2018.
A few users were reluctant to lose TCP wrappers, even if the project was considered outdated. Marc Haber said it was much easier to use TCP wrappers to protect his system than to use a packet filter. Marco d'Itri objected to removing support for TCP wrappers since it supports use cases like DNS-based ACLs that are not supported by layer 3 firewalls.
Watson suggested
d'Itri could replace the functionality with tcpd as Fedora
suggested when dropping TCP wrappers, and pointed
out that OpenSSH supports DNS-based ACLs without requiring a
separate library. That did not convince d'Itri, who complained
that the tcpd approach would require socket activation of
sshd "which is not the default for good reasons
". He
did not elaborate on this, but there are reports that socket
activation can be exploited to cause a denial of service, and recent changes that
split
sshd into multiple binaries have made Debian's non-default
support for socket activation more fragile.
Watson wanted to get rid of the TCP wrappers dependency because its library, libwrap, pulls in a heavy dependency chain, including support for the little-used Network Information Service (NIS). He suggested refactoring libwrap to reduce its dependency chain, which d'Itri seems to have done. TCP wrappers support does not appear to be on the chopping block at this point—though Watson hasn't explicitly confirmed that as of yet.
GSS-API key exchange
OpenSSH added initial support for GSS-API in version 3.7 back in 2003. But OpenSSH's GSS-API support still requires SSH host keys to authenticate the server to the user, as Simon Wilkinson pointed out in announcing a version of his GSS-API patch for OpenSSH 5.0p1. (The "p" in the release version indicates it is an OpenSSH portable release for systems other than OpenBSD.) Many users of OpenSSH did not want to maintain both a Kerberos infrastructure and OpenSSH host keys, so the patch allows organizations to use a single security architecture rather than managing both.
In 2004, Matthijs Mohlmann requested that Debian add support for Kerberos to OpenSSH. Ultimately, after some discussion and waiting for the patch to mature, Watson merged the patch in 2005. A number of attempts were made over the years to persuade the OpenSSH developers to accept the patch, but they officially turned it down in 2010. Miller said that none of the OpenSSH developers were in favor of the patch:
This is not a slight on Simon's patch, which is of fine quality, but just that a) we don't trust GSSAPI implementations that much and b) we don't like adding new KEX [key exchange] since they are pre-auth attack surface. This one is particularly scary, since it requires hooks out to typically root-owned system resources.
The patch is now maintained on GitHub by contributors from Debian and Fedora, and both distributions carry a version of the patch in their OpenSSH packages.
In his initial message to debian-devel, Watson said that the
GSS-API patch was the largest patch applied to Debian OpenSSH "by
an order of magnitude, and easily the most intrusive in terms of complexity
and exposure
". He added that he had come to regret merging the
patch a few times over the years, but he was also aware that people
depend on the functionality in the patch. "We've had it for nearly
20 years now, so we can take the time to do a proper job that at least
tries not to leave users in the lurch.
"
His proposal was to create special ("dependency-only
")
packages for Debian trixie that would have names to reflect GSS-API
support. For the trixie release, those packages would effectively be
aliases for Debian's OpenSSH client and server packages, which would
still contain GSS-API support. However, that functionality will be
split out into packages with the same name in the Debian 14 ("forky")
release, so users who have the special packages installed would
automatically get the new packages when they upgrade. The patch would
be dropped from the regular OpenSSH packages in forky. The OpenSSH package
NEWS.debian file and trixie's release notes will also inform
users of the changes.
Michael Stone suggested
speeding things up by doing things the opposite way: creating
"nogss" packages that don't contain the GSS-API patch for Debian
trixie, so users could move to the new, non-GSS-API, version
quickly. "Pushing back the ability to install the unpatched version
for a few more years seems suboptimal.
" Watson said
that he worried about churn and inviting more bugs by approaching it
that way, but he'd consider it.
Split
In the end, though, he went with his original approach. On August 30, he announced that he'd created the special openssh-client-gssapi and openssh-server-gssapi packages with the intent to split out GSS-API key-exchange support and authentication in forky. For now, Debian does not have an OpenSSH package without the GSS-API patch. Users who want those features in forky will need to use the -gssapi packages, and users who want to run OpenSSH without the patch will want the openssh-client and openssh-server packages.
Miller said
this was excellent news: "this substantially reduces the amount of
pre-authentication attack surface exposed on your users' sshd by
default
".
I emailed the maintainers of the OpenSSH packages for Fedora, and Dmitry Belyavskiy said that Fedora will be keeping the patch. He added that the maintainers had discussed following Debian's approach, but they do not plan on getting rid of GSS-API support for now or breaking it out to separate packages.
The transition should be painless for Debian users. Those who depend on the GSS-API patch will have years to ensure that their systems are ready for the transition. Meanwhile, it's an interesting case to ponder for Linux distribution packagers thinking about carrying a patch against an upstream project. A patch applied today may still need tending for years, if not decades.
[Thanks to LWN reader A. Karl Kornel who suggested this story.]
