Product SiteDocumentation Site

Capítulo 2. Introducción

2.1. Beneficios de usar SELinux
2.2. Ejemplos
2.3. Arquitectura de SELinux
2.4. SELinux en otros Sistemas Operativos
Security-Enhanced Linux (SELinux) is an implementation of a mandatory access control mechanism in the Linux kernel, checking for allowed operations after standard discretionary access controls are checked. It was created by the National Security Agency and can enforce rules on files and processes in a Linux system, and on their actions, based on defined policy.
When using SELinux, files, including directories and devices, are referred to as objects. Processes, such as a user running a command or the Mozilla® Firefox® application, are referred to as subjects. Most operating systems use a Discretionary Access Control (DAC) system that controls how subjects interact with objects, and how subjects interact with each other. On operating systems using DAC, users control the permissions of files (objects) that they own. For example, on Linux® operating systems, users could make their home directories world-readable, giving users and processes (subjects) access to potentially sensitive information, with no further protection over this unwanted action.
Relying on DAC mechanisms alone is fundamentally inadequate for strong system security. DAC access decisions are only based on user identity and ownership, ignoring other security-relevant information such as the role of the user, the function and trustworthiness of the program, and the sensitivity and integrity of the data. Each user has complete discretion over their files, making it impossible to enforce a system-wide security policy. Furthermore, every program run by a user inherits all of the permissions granted to the user and is free to change access to the user's files, so no protection is provided against malicious software. Many system services and privileged programs must run with coarse-grained privileges that far exceed their requirements, so that a flaw in any one of these programs could be exploited to obtain further system access.[1]
The following is an example of permissions used on Linux operating systems that do not run Security-Enhanced Linux (SELinux). The permissions and output in these examples may differ from your system. Use the ls -l command to view file permissions:
$ ls -l file1
-rwxrw-r-- 1 user1 group1 0 2009-08-30 11:03 file1

Los primeros tres bits de permisos, rwx, controlan el acceso que el usuario Linux usuario1 (en este caso, el dueño) tiene para el archivo1. Los siguientes tres bits de permisos, rw-, controlan el acceso que el grupo Linux grupo1 tiene para el archivo1. Los últimos tres bits de permisos, r--, controlan el acceso que todo el mundo tiene para el archivo1, que incluyen a todos los usuarios y procesos.
Security-Enhanced Linux (SELinux) adds Mandatory Access Control (MAC) to the Linux kernel, and is enabled by default in Fedora. A general purpose MAC architecture needs the ability to enforce an administratively-set security policy over all processes and files in the system, basing decisions on labels containing a variety of security-relevant information. When properly implemented, it enables a system to adequately defend itself and offers critical support for application security by protecting against the tampering with, and bypassing of, secured applications. MAC provides strong separation of applications that permits the safe execution of untrustworthy applications. Its ability to limit the privileges associated with executing processes limits the scope of potential damage that can result from the exploitation of vulnerabilities in applications and system services. MAC enables information to be protected from legitimate users with limited authorization as well as from authorized users who have unwittingly executed malicious applications.[2]
The following is an example of the labels containing security-relevant information that are used on processes, Linux users, and files, on Linux operating systems that run SELinux. This information is called the SELinux context, and is viewed using the ls -Z command:
$ ls -Z file1
-rwxrw-r--  user1 group1 unconfined_u:object_r:user_home_t:s0      file1

In this example, SELinux provides a user (unconfined_u), a role (object_r), a type (user_home_t), and a level (s0). This information is used to make access control decisions. With DAC, access is controlled based only on Linux user and group IDs. It is important to remember that SELinux policy rules are checked after DAC rules. SELinux policy rules are not used if DAC rules deny access first.
Linux y los Usuarios SELinux
On Linux operating systems that run SELinux, there are Linux users as well as SELinux users. SELinux users are part of SELinux policy. Linux users are mapped to SELinux users. To avoid confusion, this guide uses "Linux user" and "SELinux user" to differentiate between the two.

2.1. Beneficios de usar SELinux

  • Todos los procesos y archivos se etiquetan con un tipo. Un tipo define un dominio para los procesos y un tipo para los archivos. Los procesos se separan entre sí corriéndolos en sus propios dominios, y las reglas de políticas de SELinux define cómo interactúan los procesos con los archivos, así como la forma en que interactúan entre sí. El acceso sólo se permite si existe una regla de política de SELinux que específicamente lo permita.
  • Control de acceso más fino. Yendo un paso más alla de los permisos tradicionales de UNIX® que se controlan a discreción del usuario y se basa en los IDs de usuario y de grupos de Linux, las decisiones de accesos de SELinux se basan en toda la información disponible, tales como un usuario SELinux, el rol, el tipo y, opcionalmente, un nivel.
  • La política de SELinux se define administrativamente, obligando a todo el sistema, y no se pone a discreción del usuario.
  • Reduced vulnerability to privilege escalation attacks. One example: since processes run in domains, and are therefore separated from each other, and because SELinux policy rules define how processes access files and other processes, if a process is compromised, the attacker only has access to the normal functions of that process, and to files the process has been configured to have access to. For example, if the Apache HTTP Server is compromised, an attacker can not use that process to read files in user home directories, unless a specific SELinux policy rule was added or configured to allow such access.
  • Se linux se puede usar para asegurar la confidencialidad e integridad de los datos, así como proteger los procesos de entradas no confiables.
SELinux no es:
  • software antivirus.
  • un reemplazo para las contraseñas, cortafuegos y otros sistemas de seguridad.
  • una solución todo en uno.
SELinux está diseñado para mejorar las soluciones de seguridad existentes, no reemplazarlas. Aún cuando corra SELinux, siga las buenas prácticas de seguridad, tales como mantener el software actualizado, usar contraseñas difíciles de adivinar, cortafuegos y demás.


[1] "Integrating Flexible Support for Security Policies into the Linux Operating System", by Peter Loscocco and Stephen Smalley. This paper was originally prepared for the National Security Agency and is, consequently, in the public domain. Refer to the original paper for details and the document as it was first released. Any edits and changes were done by Murray McAllister.

[2] "Meeting Critical Security Objectives with Security-Enhanced Linux", by Peter Loscocco and Stephen Smalley. This paper was originally prepared for the National Security Agency and is, consequently, in the public domain. Refer to the original paper for details and the document as it was first released. Any edits and changes were done by Murray McAllister.