I'm trying to understand what permissions are allowed by some of the SELinux booleans for httpd domain, as it is my main source of concern, and the current policy of my organization is to give truly the least privilege required for getting an application working.
Reading with sesearch
what some booleans do, it's clear I don't really need some of them, so they we disabled them. In example, we don't need nginx being able to connect to squid, ftp, gopher and memcache ports, among other things the boolean httpd_can_network_relay
allows, because we pass our requests through sockets. Boolean httpd_can_network_connect
its too broad for us, as the only port we need open, it's already labeled for redis and we have a very easy to understand policy module for that: https://security.stackexchange.com/a/172569/162749
I've struggled a bit to get some PHP scripts working, even after labeling carefully some public paths, in order to just allow writes from the webapp on uploads and caches for captchas directories, but not letting that upgrade magically by itself or download from third parties scripts that could be executed. Also, just allowing execution of scripts in specific paths.
I've already got this goals working and people outside from IT are working without complains, but I can't quite understand completely yet what the booleans I've had to enable are allowing, because the man pages are useful for quickly enable something but not understanding how the magic works. And the output from sesearch
its just too confusing.
For example: sesearch -AC -b httpd_anon_write
lets understand that only is allowing writes in public_content_rw_t
labeled objects, but I still don't get why it was not working with httpd_sys_content_rw_t
.
But, output for booleans httpd_unified
and httpd_builtin_scripting
are conflicting, and I'm frankly worried to allowing without need too much things. Specially on httpd_sys_rw_content_t
labeled objects I couldn't get the writes to work without enabling both booleans, and I didn't enabled httpd_enable_cgi
because permissions seem to broad for me. See the most confusing part:
DT allow httpd_t httpd_sys_rw_content_t : file { ioctl read write create getattr setattr lock append unlink link rename open } ; [ httpd_enable_cgi httpd_unified && httpd_builtin_scripting && ]
ET allow httpd_t httpd_sys_rw_content_t : file { ioctl read write create getattr setattr lock append unlink link rename open } ; [ httpd_builtin_scripting ]
Maybe it's that I don't get where is the AND
and if there it is an OR
, but I don't get why all operations are allowed according to the former rule, just enabling httpd_builtin_scripting
, and why according the first rule, must be enabled that same boolean, AND httpd_unified
AND httpd_enable_cgi
.
Honestly I would be more than happy to not depend on any boolean that allow more than what it is strictly necessary, that's why I'd be grateful to get a hand helping me to understand the syntax of the booleans needed for a rule to be enabled.
FWIW, the webapp I'm securing is WordPress based, and the tutorials all around are depending on booleans without explaining why they are needed and what risks they introduce. My organization has a distaste for automatic upgrades for compatibility breaks too.