Question concerning proftpd exploit
Hello,
I have created a SELinux System running a vulnerable proftpd daemon (see
http://xforce.iss.net/xforce/alerts/id/154). My ps listing in enforcing mode looks like this:
PID CONTEXT COMMAND
1 system_u:system_r:init_t init
2 system_u:system_r:kernel_t [keventd]
3 system_u:system_r:kernel_t [ksoftirqd_CPU0]
4 system_u:system_r:kernel_t [kswapd]
5 system_u:system_r:kernel_t [bdflush]
6 system_u:system_r:kernel_t [kupdated]
9 system_u:system_r:kernel_t [kjournald]
828 system_u:system_r:syslogd_t syslogd -m 0
832 system_u:system_r:klogd_t klogd -x
869 system_u:system_r:ftpd_t proftpd: (acceptingconnections)
878 system_u:system_r:sshd_t /usr/sbin/sshd
900 system_u:system_r:sendmail_t sendmail: accepting
connections
909 system_u:system_r:sendmail_t sendmail: Queue
runner@01:00:00 f
921 system_u:system_r:httpd_t /usr/sbin/httpd
930 system_u:system_r:gpm_t gpm -t imps2 -m/dev/mouse
939 system_u:system_r:crond_t crond 947 system_u:system_r:local_login_t login -- root 948 system_u:system_r:local_login_t login -- root 949 system_u:system_r:getty_t /sbin/mingetty tty3 950 system_u:system_r:getty_t /sbin/mingetty tty4 951 system_u:system_r:getty_t /sbin/mingetty tty5 952 system_u:system_r:getty_t /sbin/mingetty tty6 953 system_u:system_r:httpd_t /usr/sbin/httpd 954 system_u:system_r:httpd_t /usr/sbin/httpd 955 system_u:system_r:httpd_t /usr/sbin/httpd 956 system_u:system_r:httpd_t /usr/sbin/httpd 957 system_u:system_r:httpd_t /usr/sbin/httpd 958 system_u:system_r:httpd_t /usr/sbin/httpd 959 system_u:system_r:httpd_t /usr/sbin/httpd 960 system_u:system_r:httpd_t /usr/sbin/httpd 961 root:sysadm_r:sysadm_t -bash 1012 root:sysadm_r:sysadm_t -bash 1064 root:sysadm_r:sysadm_t ps -e --context
The proftpd daemon runs in its own domain. ftpd_t
The open source proof of concept exploit code gains a root shell on my Red Hat 8.0 System without running in enforcing mode. I ran the system with a maintenance kernel. If I would switch to enforcing mode, what would happen? Does the exploit gain a root shell with privileges system_u:system_r:ftp_t? Is this possible?
Which security feature of SELinux handles such attacks? Which avc loggings should I see?
Best regards.
### Oliver Fritz
### Singerstrasse 80
### 10243 Berlin
Quoted 5 lines · sMoTo
The open source proof of concept exploit code gains a root shell on my Red Hat 8.0 System without running in enforcing mode. I ran the system with a maintenance kernel. If I would switch to enforcing mode, what would happen? Does the exploit gain a root shell with privileges system_u:system_r:ftp_t? Is this possible?
Yes. The exploit would be limited to the permissions granted to ftpd_t in the SELinux policy. And, since there are no transitions granted out of ftpd_t, there is no possibility of privilege escalation beyond those permissions.
If you wanted to prevent the exploit from even executing a shell (or other programs), you could remove the corresponding can_exec rules from ftpd.te. Note that some of those rules are simply to allow re-use of the ftpd_t domain for the proftpd cron script. That approach was introduced by Russell Coker, but I'd like to see a separate domain defined for such cron scripts rather than re-using the daemon domain, as it reduces our ability to tightly control code execution by the daemon and to truly limit it to least privilege.
Quoted 2 lines
Which security feature of SELinux handles such attacks? Which avc loggings should I see?
SELinux only provides one "security feature", the kernel mandatory access controls. You'll see avc denied messages whenever your exploit tries to do something in violation of the ftpd_t policy. Note that in permissive mode, each denial is only logged once (unless you perform a policy reload or toggle back and forth between permissive and enforcing mode to flush the cache), as you would otherwise often be flooded by repeat denials. In enforcing mode, the denial should be logged each time, although there is a rate limit mechanism to deal with the inability of the logging infrastructure to handle high load. In the long term, the avc auditing should be retargeted to a better logging framework once one becomes integrated into the mainline kernel.
Signature · 8 lines
Stephen Smalley <[email protected]> National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 12 lines · Stephen Smalley
Quoted 5 lines · sMoTo
The open source proof of concept exploit code gains a root shell on my Red Hat 8.0 System without running in enforcing mode. I ran the system with a maintenance kernel. If I would switch to enforcing mode, what would happen? Does the exploit gain a root shell with privileges system_u:system_r:ftp_t? Is this possible?
Yes. The exploit would be limited to the permissions granted to
ftpd_tin the SELinux policy. And, since there are no transitions granted out offtpd_t, there is no possibility of privilege escalation beyond those permissions.
Quoted 8 lines
If you wanted to prevent the exploit from even executing a shell (or other programs), you could remove the corresponding
can_execrules from ftpd.te. Note that some of those rules are simply to allow re-use of theftpd_tdomain for the proftpd cron script. That approach was introduced by Russell Coker, but I'd like to see a separate domain defined for such cron scripts rather than re-using the daemon domain, as it reduces our ability to tightly control code execution by the daemon and to truly limit it to least privilege.
One current issue with ftpd and many other domains is that they can read /etc/shadow to authenticate users. I have been working on PAM modules to use helper programs to authenticate users such that ftpd and other programs never need direct access to /etc/shadow.
So with policy changes to match only the following domains need direct access to /etc/shadow:
sysadm_chkpwd_t user_chkpwd_t staff_chkpwd_t system_chkpwd_t sysadm_passwd_t passwd_t backup_t quota_t setfiles_t useradd_t groupadd_t
When I fix the checkquota program quota_t won't need such access.
Signature · 11 lines
http://www.coker.com.au/selinux/ My NSA Security Enhanced Linux packages http://www.coker.com.au/bonnie++/ Bonnie++ hard drive benchmark http://www.coker.com.au/postal/ Postal SMTP/POP benchmark http://www.coker.com.au/~russell/ My home page -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Why don't you just try it in enforcing mode?
Then try some privilege escalation cracks, and see what gets logged.
Experience is the best teacher.
--Dean
Quoted 56 lines · sMoTo
Hello,
I have created a SELinux System running a vulnerable proftpd daemon (see
http://xforce.iss.net/xforce/alerts/id/154). My ps listing in enforcing mode looks like this:PID CONTEXT COMMAND
1 system_u:system_r:init_t init 2 system_u:system_r:kernel_t [keventd] 3 system_u:system_r:kernel_t [ksoftirqd_CPU0] 4 system_u:system_r:kernel_t [kswapd] 5 system_u:system_r:kernel_t [bdflush] 6 system_u:system_r:kernel_t [kupdated] 9 system_u:system_r:kernel_t [kjournald] 828 system_u:system_r:syslogd_t syslogd -m 0 832 system_u:system_r:klogd_t klogd -x 869 system_u:system_r:ftpd_t proftpd: (acceptingconnections)
878 system_u:system_r:sshd_t/usr/sbin/sshd
900 system_u:system_r:sendmail_t sendmail: accepting
connections
909 system_u:system_r:sendmail_t sendmail: Queue
runner@01:00:00 f
921 system_u:system_r:httpd_t/usr/sbin/httpd
930 system_u:system_r:gpm_t gpm -t imps2 -m/dev/mouse939 system_u:system_r:crond_t crond 947 system_u:system_r:local_login_t login -- root 948 system_u:system_r:local_login_t login -- root 949 system_u:system_r:getty_t /sbin/mingetty tty3 950 system_u:system_r:getty_t /sbin/mingetty tty4 951 system_u:system_r:getty_t /sbin/mingetty tty5 952 system_u:system_r:getty_t /sbin/mingetty tty6 953 system_u:system_r:httpd_t /usr/sbin/httpd 954 system_u:system_r:httpd_t /usr/sbin/httpd 955 system_u:system_r:httpd_t /usr/sbin/httpd 956 system_u:system_r:httpd_t /usr/sbin/httpd 957 system_u:system_r:httpd_t /usr/sbin/httpd 958 system_u:system_r:httpd_t /usr/sbin/httpd 959 system_u:system_r:httpd_t /usr/sbin/httpd 960 system_u:system_r:httpd_t /usr/sbin/httpd 961 root:sysadm_r:sysadm_t -bash 1012 root:sysadm_r:sysadm_t -bash 1064 root:sysadm_r:sysadm_t ps -e --contextThe proftpd daemon runs in its own domain.
ftpd_tThe open source proof of concept exploit code gains a root shell on my Red Hat 8.0 System without running in enforcing mode. I ran the system with a maintenance kernel. If I would switch to enforcing mode, what would happen? Does the exploit gain a root shell with privileges system_u:system_r:ftp_t? Is this possible?
Which security feature of SELinux handles such attacks? Which avc loggings should I see?
Quoted 7 lines
Best regards.
### Oliver Fritz
### Singerstrasse 80
### 10243 Berlin
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.