SEcurity Enhanced Linux Overview
SEcurity Enhanced Linux Overview
Frank Caviggia
Senior Consultant
June 4, 2015
1
Frank Caviggia
Overview
SELinux Concepts
- What is SELinux?
- DAC and MAC
- Polyinstantiation and Multitenancy
SELinux Utilities
- Commands
- Booleans
- Labeling
- Sandbox
- Troubleshooting
SELinux Implementations
- Multi-Category Security
- Multi-Level Security
More Information
Frank Caviggia
SELinux Concepts
Frank Caviggia
Frank Caviggia
SELinux Overview
Security-Enhanced Linux (SELinux) was a research project sponsored by the NSA to
provide Mandatory Access Controls (MAC) to the Linux kernel
SELinux mainlined into the Linux kernel in August 2003 (2.6.0-test3), it was first
enabled for general use in Red Hat Enterprise Linux 4
Kernel enforcement based on security context provided by policies rather than standard
permissions. Think of it like a chroot jail on steroids or watertight compartments in ship
design
Frank Caviggia
Frank Caviggia
Unix concept of everything is a file (devices, processes, files, directories, etc.) Thus,
everything is labeled with a Security Context
SELinux policy defines the watertight compartments the SELinux policy controls how
users, services, files, and binaries interact
Policy is generally developed with software vendor when possible. Otherwise,
developing policy can be achieved through testing and evaluation to give least
privilege to allow completion of a job function
Frank Caviggia
Frank Caviggia
Data written to these directories will be stored in an independent directory at the security
level that they were written, particularly important for shared temporary directories (/tmp,
/var/tmp, /dev/shm/)
User will not see the redirection to a secure folder, SELinux handles the transition
transparently. See the Private Tmp feature in RHEL 72
Multitenancy extends the concept of polyinstantiation with cgroups and Linux Containers
(LXC) to ensure that applications are securely separated from each other through Type
Enforcement (TE) and MCS (the c0.c1023 attributes of the security level)
Multitenancy in OpenShift
https://securityblog.redhat.com/2014/04/09/new-red-hat-enterprise-linux-7-security-feature-privatetmp/
Frank Caviggia
SELinux Utilities
10
Frank Caviggia
GUI Administration
SELinux Configuration
# system-config-selinux
SELinux Troubleshooting
# sealert b
11
Frank Caviggia
# sestatus
# getenforce
# setenforce [ Enforcing | Permissive | 1 | 0 ]
List files and their SELinux Security Context:
# ls -Z <file>
# getfattr -n security.selinux <file>
List processes and their SELinux Security Context:
# ps -efZ
Restore original SELinux Security Context:
# restorecon -v <file>
12
Frank Caviggia
SELinux Booleans
SELinux defines Booleans for often used settings in SELinux:
List SELinux Booleans:
# getsebool a
List SELinux Booleans related to httpd service:
Frank Caviggia
14
Frank Caviggia
15
Frank Caviggia
16
Frank Caviggia
SELinux Sandbox
Red Hat provides the sandbox utility to isolate a command using SELinux which is quite
useful for the security of a system:
# yum install y policycoreutils-sandbox
Firefox session using sandbox when browsing to untrusted sites:
# mkdir ~/.home; mkdir ~/.tmp
# sandbox -X -H ~/.home T ~/.tmp -t sandbox_web_t firefox
Using evince in the sandbox utility for an untrusted PDF document:
17
Frank Caviggia
Troubleshooting (Policy)
To help diagnose an issue there are the sealert and audit2why commands:
# sealert a /var/log/audit/audit.log
Analyze the output of the command to see if a policy can be created to fix the issues, use
the audit2allow utility to create a policy this may take multiple tries to develop a policy:
# grep avc /var/log/audit/audit.log | grep denied | grep userprog > out.txt
# audit2allow -i out.txt M userprog
# semodule -i userprog.pp
18
Frank Caviggia
Troubleshooting (relabel)
To relabel the entire filesystem (for example to re-enable SELinux after being disabled)
to the default SELinux contexts use the following commands:
# touch /.autorelabel
# reboot
19
Frank Caviggia
SELinux Implementations
20
Frank Caviggia
Using the SELinux targeted policies, each KVM instance has their own
container via SELinux Type Enforcement (TE) and Multi-Category Security
(MCS) which uses random compartments that are randomly assigned to keep
the VMs separate
21
Frank Caviggia
VS.
Compromised VM containment with KVM and sVirt (SELinux Labels)
SELinux policy prevented a buffer overflow in QEMU/KVM from attacking other VMs:
22
http://venom.crowdstrike.com/
https://access.redhat.com/articles/1444903
http://danwalsh.livejournal.com/71489.html
Frank Caviggia
Apache
Unclassified (s3)
Apache
Apache
Secret (s6)
Apache
TS
Apache
TS//SCI
Top Secret/SCI
(s10:c32,c43)
Multi-Level Security (MLS) uses all parts (user, role, type, security level, and
category) of the security context with strict enforcement. The details of this are
more complex than the scope of this presentation
23
Frank Caviggia
Questions?
24
Frank Caviggia
More Information
Dont Disable SELinux:
http://stopdisablingselinux.com/
Tresys SELinux Reference Policy:
https://github.com/TresysTechnology/refpolicy/wiki
Dan Walshs (Mr. SELinux) Blog:
http://danwalsh.livejournal.com/
25
Frank Caviggia