๐ SELinux#
Overview
Security-Enhanced Linux (SELinux) is a Linux kernel security module that provides a mechanism for supporting access control security policies, including mandatory access controls (MAC).
It is a set of kernel modifications and user-space tools added to various Linux distributions, designed to enforce strict access controls based on security policies.
SELinux implements a mandatory access control (MAC) system, which is a higher level of access control than the traditional discretionary access control (DAC) used in standard Linux systems.
This means that access decisions are enforced based on predefined security policies rather than user discretion.
SELinux operates by assigning a security contextโa three-part label consisting of a user, role, and domain (or type)โto every process, file, network port, and other system resource.
These contexts are used by the SELinux policy to determine whether a process can access a specific resource. By default, SELinux blocks all access attempts, allowing only those explicitly permitted by the security policy.
This approach confines user programs and system services, limiting their privileges to the minimum required to function, thereby reducing the potential damage from malicious or flawed applications.
Basic concepts#
A SELinux context consists of three required fields, and one optional field: user:role:type:range.
Every process and object in the system has a context.
แ
ls -Z /etc/shadow
system_u:object_r:shadow_t:s0 /etc/shadow
แ
ps -Z -L -C NetworkManager
LABEL PID LWP TTY TIME CMD
system_u:system_r:NetworkManager_t:s0 1328 1328 ? 00:00:00 NetworkManager
system_u:system_r:NetworkManager_t:s0 1328 1331 ? 00:00:00 gmain
system_u:system_r:NetworkManager_t:s0 1328 1332 ? 00:00:00 gdbus
Status#
# getting status
แ
getenforce
# getting status
แ
sestatus
# changing status (O disable, 1 enforcing)
แ
sudo setenforce 0
# list booleans
แ
getsebool -a
แ
sestatus -b
# list contexts
แ
semanage fcontext -l
/etc/selinux/config
SELINUX=enforcing
SELINUXTYPE=targeted
NetworkManager VPN#
แ
sudo setsebool -P openvpn_run_unconfined on
แ
sudo semanage fcontext -a -t home_cert_t "/home/guillaume/VPN(/.*)?"
แ
sudo restorecon -R -v /home/guillaume/VPN
