Selinux: Security Enhanced Linux
Selinux: Security Enhanced Linux
DAC
• A traditional permission model
• The owner of a particular file can change
the permissions of an object.
• Can be changed at the discretionary of
the owner.
• Inherent security flaws
Access Control Philosophies
DAC
Ex: ls –l
-rw-rw-r– 1 vmware vmware 2645 May 05 08:48 personnel.txt
Access Control Philosophies
MAC
• Acess control decisions are not at the descretion of individual users or even
system administrators.
• allows you to define permissions for how all processes (called subjects) interact
with other parts of the system such as files, devices, sockets, ports, and other
processes (called objects in SELinux).
• This is done through an administratively-defined security policy over all
processes and object .
• MACs cannot be overridden by the owner of the object.
LSM architecture
SELinux Complete Diagram
SELinux Complete Diagram
1. The policy server gathers the security context from the subject and
object, and sends the pair of labels to the security server, which is
responsible for policy decision making.
2. The policy server first checks the AVC, and returns a decision to the
enforcement server.
3. If the AVC does not have a policy decision cached, it turns to the
security server, which uses the binary policy that is loaded into the kernel
during initialization. The AVC caches the decision, and returns the
decision to the policy server.
4. If the policy permits the subject to perform the desired operation on
the object, the operation is allowed to proceed.
5. If the policy does not permit the subject to perform the desired
operation, the action is denied, and one or more avc: denied messages
are logged to $AUDIT_LOG, which is typically /var/log/messages.
SELinux Complete Diagram
• Object management includes labeling objects with a security context,
managing object labels in memory.
• Object managers are there to obtain security policy decisions from
the security server and to apply the decisions to label and control
access to their objects
SELinux Complete Diagram
• Object management includes labeling
objects with a security context, managing
object labels in memory.
• Object managers are there to obtain
security policy decisions from the security
server and to apply the decisions to label
and control access to their objects
Type Enforcement
• Certain attributes are applied to all objects
and subjects.
• These attributes are termed as Security
Contexts.
• Each process and file/directory/port on the
system is assigned a Security Context
based on which the Type Enforcement
policy allow/disallow access.
Type Enforcement
• Security context are stored in Extended Attributes(xattrs) on
ext2/ext3 filesystem.
• A typical SELinux security context is of the form:
User Identity:Role:Type/Domain
• Users ( 3 in number)
• Roles ( 6 in number)
• Types(1,513 in number)
# seinfo –r
Roles:6
Staff_r
User_r
Object_r
secadm_r
Sysadm_r
System_r
SELinux Modes
• Disabled
SELinux is not implemented on the host
A Common choice during the installation,
• Permissive
Similar to Debugging Mode
Policies and Rules are applied to objects and subjects, but actions are not effected.
Examples:
If SELInux policy would prevent the httpd subject from accessing the object folder
/webdata on my system,implementing SELinux in Permissive mode would let Apache
WebServer access the folder /webdata but log a denial in the log files.
• Enforcing
SELinux in action
All the production servers ,when hardened, should enable SELinux in Enforcing Mode
SELinux Modes
• Enforcing
SELinux in action
All the production servers ,when hardened, should enable SELinux in Enforcing
Mode.
Controlling SELinux
getenforce:
gets the current mode of SELinux.
Example:
#getenforce
Disabled
Setenforce:
modifes the mode SELinux is running in.
It toggles in between Permissive and Enforcing mode when SELinux is enabled.
Example:
#setenforce 0
It activates Permissive SELinux Mode
#setenforce 1
It activates Enforcing SELinux Mode.
Controlling SELinux
• Sestatus:
Used to get the status of a system running SELinux.
Displays more information about SELinux Policy
Example:
#sestatus
#seinfo
Understanding the targeted policy
• Default policy loaded in my system:
access defined by
• Access permission – read, write,execute