SELinux

SELinux ( Security-Enhanced Linux — Linux with enhanced security) is an implementation of a mandatory access control system that can work in parallel with the classic discretionary access control system.

Description

Remaining within the discretionary access control system, an operating system has a fundamental limitation in terms of separating process access to resources — access to resources is based on the user's access rights.

These are the classic rwx rights at three levels — owner, owning group and others.

In SELinux access rights are defined by the system itself using specially defined policies.

Policies work at the level of system calls and are applied by the kernel itself (but they can also be implemented at the application level).

SELinux acts after the classic Linux security model. In other words, SELinux cannot allow what is forbidden through the access rights of users or groups. Policies are described using a special flexible language for describing access rules.

In most cases SELinux rules are «transparent» for applications, and no modification of them is required. Some distributions include ready-made policies in which rights can be determined on the basis of matching the types of a process (subject) and a file (object) — this is the main mechanism of SELinux.

Two other forms of access control — role-based access and multi-level security based access. For example, «for official use», «secret», «top secret», «special importance».

The simplest type of policy to work with and to support is the so-called «targeted» policy, developed within the Fedora project.

The policy describes more than 200 processes that can run in the operating system. Everything that is not described by the «targeted» policy runs in the domain (with the type) unconfined_t. Processes running in this domain are not protected by SELinux.

Thus, all third-party user applications will work without any problems in a system with the «targeted» policy within the classic permissions of the discretionary access control system.

Besides the «targeted» policy, some distributions include a policy with a multi-level security model (with support for the Bell — LaPadula model).

The third policy option is «strict». Here the principle «what is not allowed is forbidden» applies (the principle of least privilege). The policy is based on the Reference Policy from the Tresys company.

SELinux was developed by the US National Security Agency, and then its source code was made available for download.

Original text

From NSA Security-enhanced Linux Team:

«NSA Security-enhanced Linux is a set of patches to the Linux kernel and some utilities to incorporate a strong, flexible mandatory access control (MAC) architecture into the major subsystems of the kernel.

It provides a mechanism to enforce the separation of information based on confidentiality and integrity requirements, which allows threats of tampering and bypassing of application security mechanisms to be addressed and enables the confinement of damage that can be caused by malicious or flawed applications.

It includes a set of sample security policy configuration files designed to meet common, general-purpose security goals.»

SELinux is included in the Linux kernel (since version 2.6).

Also, the functioning of SELinux requires modified versions of some utilities (ps, ls and others) that provide support for the new kernel functions, and support from the file system.

Basic concepts

LSM overview

LSM ( Linux Security Modules) are an implementation in the form of loadable kernel modules. First of all, LSM are used to support access control.

By themselves, LSM do not provide the system with any additional security, but are merely a kind of interface for supporting it.

The LSM system provides the implementation of interceptor functions that are stored in the security policy structure covering the main operations whose protection must be ensured. Access control in the system is carried out thanks to the configured policies.

Access control methods

Most operating systems have means and methods of access control, which in turn determine whether a certain object at the operating system level (a user or a program) can gain access to a certain resource. The following access control methods are used:

Internal architecture of SELinux

At the very beginning of its appearance, SELinux was implemented as a patch. In this case it was not easy to configure the security policy. With the advent of LSM mechanisms, the configuration and management of security became much simpler (the policy and the security enforcement mechanisms were separated), and SELinux was implemented as loadable kernel modules.

Before access to the internal objects of the operating system, the kernel code is modified. This is implemented using special functions (system call interceptors), the so-called «hook» functions (English: hook functions). The interceptor functions are stored in a certain data structure; their purpose is to perform specific security actions based on a predefined policy. The module itself includes six main components: the security server; the access vector cache (English: Access Vector Cache, AVC); network interface tables; the network notification signal code; its own virtual file system (selinuxfs) and the implementation of the interceptor functions.

Article author: Andrei Olegovich