| Summary: | SELinux doesn't prevent Apache, PHP and other httpd_t labeled processes to access remote 80/tcp | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 6 | Reporter: | Marko Uskokovic <marko> |
| Component: | selinux-policy | Assignee: | Miroslav Grepl <mgrepl> |
| Status: | CLOSED NOTABUG | QA Contact: | BaseOS QE Security Team <qe-baseos-security> |
| Severity: | high | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 6.1 | CC: | bosko.radivojevic, dwalsh, eparis, jorton, laurent.rineau__fedora, marko, mmalik, pmoore, ricardo.arguello, sdsmall, tis |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | 2011-12-09 09:56:13 UTC | Type: | --- |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
|
Description
Marko Uskokovic
2011-11-04 15:43:28 UTC
This is really not a bug, although we could do better. apachectl requires this access to shut down an apache server. We probably could tighten it do be only local host. Joe what do you think? "apachectl requires this access to shut down an apache server" Specifically, the requirement is that the httpd parent must be able to connect to port 80 on addresses bound to local interfaces by default. Yes, it is certainly desirable that php scripts cannot make outgoing connections to port 80 by default, that would help prevent e.g. canned attacks against bad PHP webapps etc - the first step is often to wget some toolkit from a remote site. Would it be possible for to have separate roles for httpd parent and children? Or else is there separation between making a TCP connection to the local host vs a remote address which can be expressed in the rule? (and is the distinction between "local" and "remote" more sophisticated than "::1 and 127.0.0.1" vs everything else?) Joe I don't understand what you mean by parent and child? Are there two different process here? Or is apachectl connecting to the httpd service via port 80? I would try this out on my F17 box but I have hosed it up trying to setup PrivateTmp for httpd. Currently in F16 we are not allowing httpd_t to connect to port 80 by default, and I want to know if that breaks apachectl. I am not sure why you keep refering to "apachectl" specifically. httpd runs a monitoring process, the parent, and a bunch of child processes which handle connections. The parent runs as root, the children all setuid() to uid/gid apache once forked, and only handle connections once running as that less-privileged user. When the httpd init script, or systemd, or apachectl want to gracefully restart httpd to load a new configuration, it works as following: a) the init script/apachectl/systemd send a signal to the httpd parent process b) the parent process sends signals to all running child processes c) the parent process sends dummy HTTP requests to address/port combinations on which it knows the children are listening. This ensures they pop out of accept() if they are blocked there. d) existing children all terminate, and new ones are started up using the new configuration (c) is the requirement to be able to connect to port 80 on the local host by default. Ok thanks for the explanation. Of course httpd is not forking and execing so we can not use program transitions to run the parent as a different context then the children. One option would be to add SELinux smarts to httpd to let it to a setexec() httpd_parent_t -> fork() setcur(httpd_t) Then just allow httpd_parent_t to connect to http_port_t by default. Or we turn on labelling of the localhost nodes/ethernet and only allow httpd_t to connect send/recv packets over localhost ether net or notes, and allow httpd_t to connect to http_port_t, But I am not sure we can block that since we have to allow httpd_t to send/recv packets for DNS name resolution. |