Este conteúdo não está disponível no idioma selecionado.
4.2. Unconfined Processes
Unconfined processes run in unconfined domains, for example, init programs run in the unconfined
initrc_t domain, unconfined kernel processes run in the kernel_t domain, and unconfined Linux users run in the unconfined_t domain. For unconfined processes, SELinux policy rules are applied, but policy rules exist that allow processes running in unconfined domains almost all access. Processes running in unconfined domains fall back to using DAC rules exclusively. If an unconfined process is compromised, SELinux does not prevent an attacker from gaining access to system resources and data, but of course, DAC rules are still used. SELinux is a security enhancement on top of DAC rules – it does not replace them.
To ensure that SELinux is enabled and the system is prepared to perform the following example, complete the Procedure 4.1, “How to Verify SELinux Status” described in Section 4.1, “Confined Processes”.
The following example demonstrates how the Apache HTTP Server (
httpd) can access data intended for use by Samba, when running unconfined. Note that in Red Hat Enterprise Linux, the httpd process runs in the confined httpd_t domain by default. This is an example, and should not be used in production. It assumes that the httpd, wget, dbus and audit packages are installed, that the SELinux targeted policy is used, and that SELinux is running in enforcing mode.
Procedure 4.3. An Example of Unconfined Process
- The
chconcommand relabels files; however, such label changes do not survive when the file system is relabeled. For permanent changes that survive a file system relabel, use thesemanagecommand, which is discussed later. As the Linux root user, run the following command to change the type to a type used by Samba:chcon -t samba_share_t /var/www/html/testfile
~]# chcon -t samba_share_t /var/www/html/testfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow Run thels -Z /var/www/html/testfilecommand to view the changes:ls -Z /var/www/html/testfile
~]$ ls -Z /var/www/html/testfile -rw-r--r-- root root unconfined_u:object_r:samba_share_t:s0 /var/www/html/testfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Run the
service httpd statuscommand to confirm that thehttpdprocess is not running:service httpd status
~]$ service httpd status httpd is stoppedCopy to Clipboard Copied! Toggle word wrap Toggle overflow If the output differs, run theservice httpd stopcommand as the Linux root user to stop thehttpdprocess:service httpd stop
~]# service httpd stop Stopping httpd: [ OK ]Copy to Clipboard Copied! Toggle word wrap Toggle overflow - To make the
httpdprocess run unconfined, run the following command as the Linux root user to change the type of/usr/sbin/httpd, to a type that does not transition to a confined domain:chcon -t unconfined_exec_t /usr/sbin/httpd
~]# chcon -t unconfined_exec_t /usr/sbin/httpdCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Run the
ls -Z /usr/sbin/httpdcommand to confirm that/usr/sbin/httpdis labeled with theunconfined_exec_ttype:ls -Z /usr/sbin/httpd
~]$ ls -Z /usr/sbin/httpd -rwxr-xr-x root root system_u:object_r:unconfined_exec_t:s0 /usr/sbin/httpdCopy to Clipboard Copied! Toggle word wrap Toggle overflow - As the Linux root user, run the
service httpd startcommand to start thehttpdprocess. The output is as follows ifhttpdstarts successfully:service httpd start
~]# service httpd start Starting httpd: [ OK ]Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Run the
ps -eZ | grep httpdcommand to view thehttpdrunning in theunconfined_tdomain:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Change into a directory where your Linux user has write access to, and run the
wget http://localhost/testfilecommand. Unless there are changes to the default configuration, this command succeeds:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Although thehttpdprocess does not have access to files labeled with thesamba_share_ttype,httpdis running in the unconfinedunconfined_tdomain, and falls back to using DAC rules, and as such, thewgetcommand succeeds. Hadhttpdbeen running in the confinedhttpd_tdomain, thewgetcommand would have failed. - The
restoreconcommand restores the default SELinux context for files. As the Linux root user, run therestorecon -v /usr/sbin/httpdcommand to restore the default SELinux context for/usr/sbin/httpd:restorecon -v /usr/sbin/httpd
~]# restorecon -v /usr/sbin/httpd restorecon reset /usr/sbin/httpd context system_u:object_r:unconfined_exec_t:s0->system_u:object_r:httpd_exec_t:s0Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run thels -Z /usr/sbin/httpdcommand to confirm that/usr/sbin/httpdis labeled with thehttpd_exec_ttype:ls -Z /usr/sbin/httpd
~]$ ls -Z /usr/sbin/httpd -rwxr-xr-x root root system_u:object_r:httpd_exec_t:s0 /usr/sbin/httpdCopy to Clipboard Copied! Toggle word wrap Toggle overflow - As the Linux root user, run the
service httpd restartcommand to restarthttpd. After restarting, run theps -eZ | grep httpdcommand to confirm thathttpdis running in the confinedhttpd_tdomain:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - As the Linux root user, run the
rm -i /var/www/html/testfilecommand to removetestfile:rm -i /var/www/html/testfile
~]# rm -i /var/www/html/testfile rm: remove regular empty file `/var/www/html/testfile'? yCopy to Clipboard Copied! Toggle word wrap Toggle overflow - If you do not require
httpdto be running, as the Linux root user, run theservice httpd stopcommand to stophttpd:service httpd stop
~]# service httpd stop Stopping httpd: [ OK ]Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The examples in these sections demonstrate how data can be protected from a compromised confined-process (protected by SELinux), as well as how data is more accessible to an attacker from a compromised unconfined-process (not protected by SELinux).