Bug 1136104 - sshd crash with GSSAPIKeyExchange setting
Summary: sshd crash with GSSAPIKeyExchange setting
Status: RESOLVED FIXED
: 1159097 (view as bug list)
Alias: None
Product: openSUSE Distribution
Classification: openSUSE
Component: Basesystem (show other bugs)
Version: Leap 15.1
Hardware: 64bit All
: P2 - High : Normal with 2 votes (vote)
Target Milestone: ---
Assignee: E-mail List
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-05-23 15:54 UTC by Ralf Kölmel
Modified: 2023-05-30 10:41 UTC (History)
5 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
sshd_config (443 bytes, text/plain)
2019-05-23 15:54 UTC, Ralf Kölmel
Details
sshd debug log (6.48 KB, text/plain)
2019-05-23 15:57 UTC, Ralf Kölmel
Details
client ssh config (.ssh/config) (100 bytes, text/plain)
2019-05-27 11:06 UTC, Ralf Kölmel
Details
ssh client debug log when the segfault is happening on the serverside (2.05 KB, text/plain)
2019-05-27 11:07 UTC, Ralf Kölmel
Details
sshd stacktrace of worker thread in the segfault case (1.25 KB, text/x-log)
2019-05-28 15:02 UTC, Ralf Kölmel
Details
Change for the openssh-7.7p1-gssapi_key_exchange.patch (621 bytes, patch)
2019-05-31 13:58 UTC, Vítězslav Čížek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf Kölmel 2019-05-23 15:54:12 UTC
Created attachment 805870 [details]
sshd_config

In the current openSUSE Leap 15.1 the sshd (Version 7.9p1-lp151.3.4) is reproducably crashing with a set GSSAPIKeyExchange option during unpriviledged user login with different authentication methods (Pub Key, password or Kerberos Key forwarding).
If the option is set to no, which is default, sshd is working.
The setup is working under openSUSE Leap 15.0.
Comment 1 Ralf Kölmel 2019-05-23 15:57:15 UTC
Created attachment 805871 [details]
sshd debug log
Comment 2 Ralf Kölmel 2019-05-27 11:06:06 UTC
Created attachment 806051 [details]
client ssh config (.ssh/config)

the "segfault" is "only" occuring if a kerberos context with a forwardable ticket  is present on the client side and the client ssh config (s. config) requests ticket forwarding. Furthermore it must be combined with a NFSv4 Kerberos Mountpoint on the serverside.
Without NFSv4 the ticket forwarding for krbtgt is working without segfault. Then authentication with gssapi-with-mic is used.
If i use the openssh 7.6p1 package from openSUSE 15.0 for the new 15.1 release, the bug is not happening.
I increase the priority, because in my opinion ticket forwarding and usage of NFSv4 with Kerberos is a common case in a kerberos setup with single sign-on.
Comment 3 Ralf Kölmel 2019-05-27 11:07:28 UTC
Created attachment 806053 [details]
ssh client debug log when the segfault is happening on the serverside
Comment 5 Vítězslav Čížek 2019-05-28 12:30:52 UTC
Could you also please provide the core file?
Comment 6 Ralf Kölmel 2019-05-28 15:02:33 UTC
Created attachment 806234 [details]
sshd stacktrace of worker thread in the segfault case

The segfault in the child thread of the sshd doesn't produce a core.
Maybe some signal handler catches the segfault. Instead i've appended a gdb stacktrace of the segfault.
Comment 7 Vítězslav Čížek 2019-05-31 11:29:32 UTC
I haven't tried reproducing the issue, but I think I see the problem.

openssh-7.7p1-gssapi_key_exchange.patch is wrong.
A bug got introduced there while porting the patch to OpenSSL 1.1.

In kexgsss.c
 81        const BIGNUM *p, *g, *pub_key;
[...]
124                 dh = PRIVSEP(choose_dh(min, nbits, max));
125                 if (dh == NULL)
126                         packet_disconnect("Protocol error: no matching group found");
127 
128                 DH_set0_pqg(dh, &p, NULL, &g);           
129                 packet_start(SSH2_MSG_KEXGSS_GROUP);
130                 packet_put_bignum2((BIGNUM *)p);
131                 packet_put_bignum2((BIGNUM *)g);

DH_set0_pqg() on line 128 should be DH_get0_pqg() instead.

The current code tries to retrieve the values of p and g from dh in order to send them over the wire with the packet_put_bignum2() right below.

But instead of getting the values from dh, it actually sets dh->p and dh->g to uninitialized values which causes the eventual crash in openssl's BN_num_bits.
Comment 8 Vítězslav Čížek 2019-05-31 11:35:49 UTC
Ralf,
would you mind testing the openssh packages from https://build.opensuse.org/package/show/home:vitezslav_cizek:branches:network/openssh?

You can download the Leap 15.1 packages from https://download.opensuse.org/repositories/home:/vitezslav_cizek:/branches:/network/openSUSE_Leap_15.1/ or you could also build them yourself from the OBS project.
Comment 9 Ralf Kölmel 2019-05-31 12:16:38 UTC
Dear Vítězslav,
i've tested with your openssh packages (openssh-7.9p1-lp151.234.1.x86_64.rpm ...) and i couldn't reproduce the segfault in my tests.
Your patch fixes the problem.
Thank you for your investigation.
Comment 10 Vítězslav Čížek 2019-05-31 13:31:26 UTC
Thanks for the quick testing, Ralf.
I've submitted the fixed package to Factory.

Hans-Peter,
please take care of fixing SLE-15-SP1.
Comment 11 Vítězslav Čížek 2019-05-31 13:56:52 UTC
Affects SLE-15-SP1/Factory only.

It is however a kinda nasty bug.
Given that the dh->p and dh->g parameters are essentially replaced by uninitialized data from the stack, one should assume the possibility that sometimes the server won't crash, but it'll negotiate these weak (random) dh parameters with the client instead.
Comment 12 Vítězslav Čížek 2019-05-31 13:58:40 UTC
Created attachment 806544 [details]
Change for the openssh-7.7p1-gssapi_key_exchange.patch
Comment 16 Swamp Workflow Management 2019-06-21 13:17:12 UTC
SUSE-RU-2019:1633-1: An update that has one recommended fix can now be installed.

Category: recommended (moderate)
Bug References: 1136104
CVE References: 
Sources used:
SUSE Linux Enterprise Module for Server Applications 15-SP1 (src):    openssh-7.9p1-6.3.1
SUSE Linux Enterprise Module for Open Buildservice Development Tools 15-SP1 (src):    openssh-7.9p1-6.3.1
SUSE Linux Enterprise Module for Desktop Applications 15-SP1 (src):    openssh-askpass-gnome-7.9p1-6.3.1
SUSE Linux Enterprise Module for Basesystem 15-SP1 (src):    openssh-7.9p1-6.3.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 17 Swamp Workflow Management 2019-07-19 19:15:21 UTC
openSUSE-RU-2019:1729-1: An update that has one recommended fix can now be installed.

Category: recommended (moderate)
Bug References: 1136104
CVE References: 
Sources used:
openSUSE Leap 15.1 (src):    openssh-7.9p1-lp151.4.3.1, openssh-askpass-gnome-7.9p1-lp151.4.3.1
Comment 18 Hans Petter Jansson 2019-07-22 22:52:50 UTC
Code changes have been submitted; reassigning to maint-coord.
Comment 19 Marcus Meissner 2020-04-01 07:54:23 UTC
seems fixed
Comment 20 Frank Scheiner 2020-05-07 14:26:05 UTC
*** Bug 1159097 has been marked as a duplicate of this bug. ***