Bug 1498845
Summary: | ssh under newgrp'ed session fails hostbased authentication | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | k-endou |
Component: | openssh | Assignee: | Dmitry Belyavskiy <dbelyavs> |
Status: | CLOSED MIGRATED | QA Contact: | BaseOS QE Security Team <qe-baseos-security> |
Severity: | high | Docs Contact: | |
Priority: | medium | ||
Version: | 7.3 | CC: | cww, dbelyavs, jjelen, nmavrogi, rmetrich, sscheib |
Target Milestone: | rc | Keywords: | MigratedToJIRA, Reopened, Triaged |
Target Release: | --- | ||
Hardware: | x86_64 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2023-09-05 11:08:40 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
k-endou
2017-10-05 12:06:13 UTC
Did you make sure that the change was effective in your use case by re-logging in the user or using the - switch to newgrp? With what are you comparing the "working" part? Was it working before? In which version? (In reply to Jakub Jelen from comment #2) > Did you make sure that the change was effective in your use case by > re-logging in the user or using the - switch to newgrp? "newgrp - group2" made no difference. > With what are you comparing the "working" part? Was it working before? In > which version? I remember ssh in RHEL6 did not have problems like this, in other words, I used to run ssh in newgrp'ed sessions and hostbased-auth did not fail. But I can't verify that because I have no RHEL6 environment now. Instead, I tried CentOS6/openssh-5.3p1-94.el6.x86_64 ( hostname: mic, ssh client and server were on a same node ) and I found, as I expect, ssh did neither fail hostbased-auth nor report "setresgid XXXX: Operation not permitted" in a newgrp'ed session. --- not newgrp'ed user61$ getent passwd user61 user61:x:1101:1101::/home/user61:/bin/bash user61$ id uid=1101(user61) gid=1101(group61) groups=1101(group61),1102(group62) user61$ ssh -v -o PubkeyAuthentication=no -o HostbasedAuthentication=yes localhost hostname ... debug1: Next authentication method: hostbased debug1: permanently_drop_suid: 1101 debug1: Remote: Accepted for localhost [::1] by /etc/ssh/shosts.equiv. debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,hostbased debug1: permanently_drop_suid: 1101 debug1: Remote: Accepted for localhost [::1] by /etc/ssh/shosts.equiv. debug1: Authentication succeeded (hostbased). ... mic ... debug1: Exit status 0 -- newgrp'ed user61$ newgrp group62 user61$ id uid=1101(user61) gid=1102(group62) groups=1101(group61),1102(group62) user61$ ssh -v -o PubkeyAuthentication=no -o HostbasedAuthentication=yes localhost hostname ... debug1: Next authentication method: hostbased debug1: permanently_drop_suid: 1101 debug1: Remote: Accepted for localhost [::1] by /etc/ssh/shosts.equiv. debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,hostbased debug1: permanently_drop_suid: 1101 debug1: Remote: Accepted for localhost [::1] by /etc/ssh/shosts.equiv. debug1: Authentication succeeded (hostbased). ... mic ... debug1: Exit status 0 ok, forget about the previous comment. It is going through different code paths. Here is a debug3 log as I reproduced it with the latest openssh: debug3: authmethod_is_enabled hostbased debug1: Next authentication method: hostbased debug3: userauth_hostbased: trying key type ecdsa-sha2-nistp256-cert-v01 debug3: userauth_hostbased: trying key type ecdsa-sha2-nistp384-cert-v01 debug3: userauth_hostbased: trying key type ecdsa-sha2-nistp521-cert-v01 debug3: userauth_hostbased: trying key type ssh-ed25519-cert-v01 debug3: userauth_hostbased: trying key type ssh-rsa-cert-v01 debug3: userauth_hostbased: trying key type ecdsa-sha2-nistp256 debug1: userauth_hostbased: trying hostkey ecdsa-sha2-nistp256 SHA256:OyN0FVZ1BiQ5cgEY8L7+jrEMuWRXarBBGs7Faw1mDgA debug2: userauth_hostbased: chost f26. debug3: ssh_msg_send: type 2 debug3: ssh_msg_recv entering debug1: permanently_drop_suid: 1001 debug3: ssh_keysign: [child] pid=14766, exec /usr/libexec/openssh/ssh-keysign setresgid 1002: Operation not permitted ssh_keysign: no reply sign using hostkey ecdsa-sha2-nistp256 SHA256:OyN0FVZ1BiQ5cgEY8L7+jrEMuWRXarBBGs7Faw1mDgA failed debug2: we did not send a packet, disable method The error is not coming from the ssh process, but from the exec-ed ssh-keysign, which does one of the first things permanently_set_uid(pw). This call was there quite much ever since (2004) so I don't think it could be something that changed in OpenSSH. The problem is that ssh-keysign is a setgid binary, so it is already running as "ssh_keys" group, but RHEL6 and upstream is the root account and the binary is setuid. This was changed in RHEL7 to harden SSHD daemon. I can not find Fedora/RHEL bugs, but there is an upstream bug which was closed as wontfix even though it is in Fedora: https://bugzilla.mindrot.org/show_bug.cgi?id=1893 What I remember, this was the first and only issue with this change over the years. Workaround is probably to revert from setgit to setuid and some related downstream changes, but I am not sure if we want to go down this road at this moment. If this issue is critical or in any way time sensitive, please raise a ticket through the regular Red Hat support channels to ensure it receives the proper attention and prioritization to assure a timely resolution. For information on how to contact the Red Hat production support team, please visit: https://www.redhat.com/support/process/production/#howto Thank you for your suggestion. But now I understand what caused this problem and how to get around it, so it's no longer emergency for me. I've decided to add setuid permission to the ssh-keysign binary, and that actually is preventing the problem. I don't know this method - to add setuid permission - should be best or not though, I'd like RHEL/Fedora or upstream to apply this or some other correction, or at least, to add some explanation to man or some document. because it's a bit confusing behavior that newgrp'ed ssh fails hostbased-auth while ssh which is not newgrp'ed succeeds. Thank you for the confirmation that setuid bit helped. The setuid bit was there until RHEL6, so it should be quite safe to restore it in your case. I am not sure if we will be able to change this in RHEL7 timeframe (unless it shows as a bigger issue -- this is probably the first problem we found with this approach since 2011 [1]). This change was no significant security improvement and was never accepted in upstream openssh so I believe we could switch back in the next major release to avoid differences from upstream OpenSSH. Until that time, the easiest and probably best solution where to document this issue would be a Knowledge base on customer portal, which is written by the support guys and used by them and customers. They are usually created based on the customer issues so filling a ticket on customer portal would be the fastest way there. [1] https://src.fedoraproject.org/rpms/openssh/c/1ddd0ee5 Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug. This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there. Due to differences in account names between systems, some fields were not replicated. Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information. To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer. You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like: "Bugzilla Bug" = 1234567 In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. |