Bug 1398569 - sftp/ssh ignores group permissions
Summary: sftp/ssh ignores group permissions
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: openssh
Version: 7.3
Hardware: x86_64
OS: Linux
Target Milestone: rc
: ---
Assignee: Jakub Jelen
QA Contact: Stefan Dordevic
Mirek Jahoda
: 1388359 1398527 1404835 (view as bug list)
Depends On:
Blocks: 1399640
TreeView+ depends on / blocked
Reported: 2016-11-25 10:16 UTC by SHAURYA
Modified: 2021-04-23 04:33 UTC (History)
19 users (show)

Fixed In Version: openssh-6.6.1p1-32.el7
Doc Type: Bug Fix
Doc Text:
In Red Hat Enterprise Linux 7.3, the chroot setup in OpenSSH did not work properly. Secondary groups of users in chroot were not correctly initialized, and capabilities were trimmed for these users. The chroot setup was fixed to match earlier behavior, and groups and capabilities of users set up using OpenSSH chroot now work as expected.
Clone Of:
: 1399640 (view as bug list)
Last Closed: 2017-08-01 18:42:47 UTC
Target Upstream Version:

Attachments (Terms of Use)

System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 2780611 0 None None None 2016-11-28 14:07:17 UTC
Red Hat Product Errata RHSA-2017:2029 0 normal SHIPPED_LIVE Moderate: openssh security, bug fix, and enhancement update 2017-08-01 18:11:55 UTC

Description SHAURYA 2016-11-25 10:16:25 UTC
Description of problem:

I have this problem only on RHEL 7.3 servers, under RHEL 6.x and RHEL 7.2 it works:

Version-Release number of selected component (if applicable):

How reproducible:


Steps to Reproduce:

The sftp process uses this Chrootdirectory "/srv/test".  I will add the sosreport, so you can see the configuration in /etc/ssh/sshd_config.

[root@vihla098 test]# pwd
[root@vihla098 test]# ls -la
total 16
drwxr-xr-x  4 root root    4096 Nov 17 12:01 .
drwxr-xr-x. 3 root root    4096 Nov 17 10:53 ..
drwxrwx---  2 root yumftp  4096 Nov 17 12:01 test1
drwxrwx---  2 root ifxuser 4096 Nov 17 08:56 test2
[root@vihla098 test]# id thaller
uid=9824(thaller) gid=30000(ifxuser) groups=30000(ifxuser),18850(spt9_mod),11050(ezmdcad),17218(itosdsm),10061(obiwan),56789(yumftp),999929(j750),17235(psc)

Now I try to access the server using sftp:
-bash-4.1$ sftp thaller@vihla098
Connecting to vihla098...
sftp> ls
test1  test2  
sftp> cd test2
sftp> ls
sftp> put x
Uploading x to /test2/x
x                                                                              100%    0     0.0KB/s   00:00    
sftp> put z
Uploading z to /test2/z
z                                                                              100%    0     0.0KB/s   00:00    
sftp> ls
x  z  
sftp> cd ..
sftp> cd test1
sftp> ls
Couldn't get handle: Permission denied
sftp> put x
Uploading x to /test1/x
Couldn't get handle: Permission denied
sftp> cd ..
sftp> ls -l
drwxrwx---    2 0        yumftp       4096 Nov 17 11:01 test1
drwxrwx---    2 0        ifxuser      4096 Nov 17 11:31 test2

Actual results:

Permission denied to secondary group member

Expected results:

Should be allowed

Additional info:

Comment 10 Jakub Jelen 2016-11-28 15:55:15 UTC
*** Bug 1388359 has been marked as a duplicate of this bug. ***

Comment 14 Jakub Jelen 2016-12-08 07:51:29 UTC
*** Bug 1398527 has been marked as a duplicate of this bug. ***

Comment 15 David Gardner 2016-12-14 15:46:47 UTC
We have also encountered this since CentOS 7.3 has picked up this change and pushed it out.

It appears to be because the capng_change_id call in patch 941 has the "CAPNG_DROP_SUPP_GRP" flag included rather than the "CAPNG_INIT_SUPP_GRP" flag.
Changing this in the patch and rebuilding the RPM allows the secondary groups to work once more.

i.e. openssh-6.6p1/session.c line 1646
change CAPNG_DROP_SUPP_GRP to CAPNG_INIT_SUPP_GRP.  git diff is:

  diff --git a/SOURCES/openssh-6.6p1-chroot-capabilities.patch b/SOURCES/openssh-6.6p1-chroot-capabilities.patch
  index 4fb3f21..b89ba25 100644
  --- a/SOURCES/openssh-6.6p1-chroot-capabilities.patch
  +++ b/SOURCES/openssh-6.6p1-chroot-capabilities.patch
  @@ -69,7 +69,7 @@ diff -up openssh-6.6p1/session.c.chroot-cap openssh-6.6p1/session.c
   +                      /* drop suid soon, retain SYS_CHROOT capability */
   +                      capng_clear(CAPNG_SELECT_BOTH);
   +                      capng_update(CAPNG_ADD, CAPNG_EFFECTIVE|CAPNG_PERMITTED, CAP_SYS_CHROOT);
  -+                      if ((dropped_suid = capng_change_id(pw->pw_uid, pw->pw_gid, CAPNG_DROP_SUPP_GRP | CAPNG_CLEAR_BOUNDING)) != 0)
  ++                      if ((dropped_suid = capng_change_id(pw->pw_uid, pw->pw_gid, CAPNG_INIT_SUPP_GRP | CAPNG_CLEAR_BOUNDING)) != 0)
   +                              logit("capng_change_id() = %d (failure): Try to drop UID later", dropped_suid);
    #ifdef WITH_SELINUX

I've not investigated the possible repercussions (security or otherwise) of this change beyond that it appears to resolve this regression.

(I can't see the RedHat Solution to see what it shows as the solution)

Comment 16 Jakub Jelen 2016-12-15 11:31:41 UTC
*** Bug 1404835 has been marked as a duplicate of this bug. ***

Comment 19 errata-xmlrpc 2017-08-01 18:42:47 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.


Note You need to log in before you can comment on or make changes to this bug.