Red Hat Bugzilla – Bug 1097775
ftp_home_dir set to off allows FTP login to user home directory
Last modified: 2016-11-03 22:17:20 EDT
+++ This bug was initially created as a clone of Bug #1066124 +++ Description of problem: Setting selinux boolean ftp_home_dir to off allows login for users to their home directory with proftpd server. Version-Release number of selected component (if applicable): # rpm -qa | grep selinux libselinux-2.2.2-6.el7.x86_64 libselinux-utils-2.2.2-6.el7.x86_64 selinux-policy-targeted-3.12.1-153.el7.noarch selinux-policy-3.12.1-153.el7.noarch libselinux-python-2.2.2-6.el7.x86_64 # rpm -q vsftpd vsftpd-3.0.2-9.el7.x86_64 How reproducible: # getsebool -a | grep ftp ftp_home_dir --> off ftpd_anon_write --> off ftpd_connect_all_unreserved --> off ftpd_connect_db --> off ftpd_full_access --> off ftpd_use_cifs --> off ftpd_use_fusefs --> off ftpd_use_nfs --> off ftpd_use_passive_mode --> off httpd_can_connect_ftp --> off httpd_enable_ftp_server --> off sftpd_anon_write --> off sftpd_enable_homedirs --> off sftpd_full_access --> off sftpd_write_ssh_home --> off tftp_anon_write --> off tftp_home_dir --> off # lftp -d -e 'set net:max-retries 1; set ftp:passive-mode on;ls;quit' -u ftptest,redhat 127.0.0.1 ---- Connecting to 127.0.0.1 (127.0.0.1) port 21 <--- 220 (vsFTPd 3.0.2) ---> FEAT <--- 211-Features: <--- EPRT <--- EPSV <--- MDTM <--- PASV <--- REST STREAM <--- SIZE <--- TVFS <--- UTF8 <--- 211 End ---> OPTS UTF8 ON <--- 200 Always in UTF8 mode. ---> USER ftptest <--- 331 Please specify the password. ---> PASS redhat <--- 230 Login successful. ---> PWD <--- 257 "/home/ftptest" ---> PASV <--- 227 Entering Passive Mode (127,0,0,1,71,115). ---- Connecting data socket to (127.0.0.1) port 18291 ---- Data connection established ---> LIST <--- 150 Here comes the directory listing. ---- Got EOF on data connection ---- Closing data socket -rw-r--r-- 1 0 0 0 May 07 09:16 testfile <--- 226 Directory send OK. ---> QUIT ---- Closing control socket Steps to Reproduce: 1. set ftp_home_dir to off, if it isn't off. 2. try to connect to home dir as user Actual results: User login to ftp server is possible. Expected results: No user login to ftp server possible.
Patch sent to Lukas
Problem here is this rule: [root@rhel7-virt ~]# sesearch -A -s ftpd_t -t user_home_t -C -c dir | grep -v DT Found 8 semantic av rules: allow userdom_filetrans_type user_home_t : dir { ioctl read write getattr lock add_name remove_name search open } ; This rule is part of following macro: userdom_filetrans_home_content(ftpd_t) Unfortunately, userdom_filetrans_home_content() cannot be part of any boolean block and filename transition rule cannot be part of any conditional block. This is caused by limiting m4 macro language. I incline to comment4, to remove this boolean.
I'm not really sure if removing that boolean is proper solution. If we cannot fix it properly using m4 will we be able to do it using CIL?
ftp access to home dir is disabled by default. To enable it "semanage boolean -m ftpd_full_access --on" instead of "setsebool ftp_home_dir on" have to be run. Please make sure that this is documented.
---- time->Wed Jul 20 15:41:02 2016 type=SYSCALL msg=audit(1469022062.310:232): arch=c000003e syscall=2 success=no exit=-13 a0=7f68b980f720 a1=800 a2=7f68b9805ff0 a3=578f7f6e items=0 ppid=5648 pid=5653 auid=4294967295 uid=1001 gid=1001 euid=1001 suid=1001 fsuid=1001 egid=1001 sgid=1001 fsgid=1001 tty=(none) ses=4294967295 comm="vsftpd" exe="/usr/sbin/vsftpd" subj=system_u:system_r:ftpd_t:s0-s0:c0.c1023 key=(null) type=AVC msg=audit(1469022062.310:232): avc: denied { read } for pid=5653 comm="vsftpd" name="file.txt" dev="dm-2" ino=81 scontext=system_u:system_r:ftpd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:user_home_t:s0 tclass=file ---- I have the same issue with tests for basics ftp scenarios in wget test suite. Not sure if enabling ftpd_full_access is not too "strong" way how to handle it. selinux-policy-3.13.1-89.el7
I'm also getting similar AVC regarding this issue in vsftpd smoke test. time->Thu Jul 21 04:36:18 2016 type=PROCTITLE msg=audit(1469090178.835:975): proctitle=2F7573722F7362696E2F767366747064002F6574632F7673667470642F7673667470642E636F6E66 type=SYSCALL msg=audit(1469090178.835:975): arch=c00000b7 syscall=56 success=no exit=-13 a0=ffffffffffffff9c a1=2aaf163c420 a2=841 a3=1b6 items=0 ppid=15028 pid=15033 auid=4294967295 uid=1001 gid=1001 euid=1001 suid=1001 fsuid=1001 egid=1001 sgid=1001 fsgid=1001 tty=(none) ses=4294967295 comm="vsftpd" exe="/usr/sbin/vsftpd" subj=system_u:system_r:ftpd_t:s0-s0:c0.c1023 key=(null) type=AVC msg=audit(1469090178.835:975): avc: denied { create } for pid=15033 comm="vsftpd" name="testfile.txt" scontext=system_u:system_r:ftpd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:user_home_t:s0 tclass=file permissive=0
Hello, we should describe this bug fix in 7.3 Release Notes - could you please provide CCFR (Doc Text)? (I will also update Security Guide.)
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. https://rhn.redhat.com/errata/RHBA-2016-2283.html