SlideShare a Scribd company logo
HOWTOUSE
SELINUX
CHUCK REEVES @MANCHUCK
NO I DON'T MEAN
TURN IT OFF
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
ABOUT
▸ Built using Kernel Modules
▸ More permissions than CRUD and Access
▸ Allows Multi-Level Security using BLP and Biba Models
▸ Permissions set on the inode instead of the file
▸ Mandatory Access Control (MAC)
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
WHAT YOU NEED TO KNOW
▸ Each iNode is given a single context
▸ Each context identifies a user, role, type and level
▸ SELINUX then allows (or denies) access using the context with a policy
▸ Decision is cached in the Access Vector Cache (AVC)
▸ Decisions is made after the DAC access is checked
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
WHAT YOU NEED TO KNOW
▸ SELINUX manages:
▸ Users
▸ Sockets
▸ Memory
▸ Directories
▸ TCP/UDP connections
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
PROCESS TYPES
▸ Confined
▸ Runs in own domain (role)
▸ Resources are limited to the roles and policy
▸ Un-Confined
▸ fallback to the DAC policies
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
CONTEXTS
▸ Policy checks context of inode for access
▸ "If a process is running with <context_foo> then anything with
<context_foo_type> is allowed access"
▸ Four parts: user, role, type and level (optional)
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
CONTEXTS
▸ Set automatically based on the parent context (mostly)
▸ RPM
▸ Management tools (ansible, chef, puppet)
▸ When a File transitions (moving an uploaded file)
▸ By the sysadmin with chcon, restorecon
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
FINDING CONTEXT
ls -alZ /home
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
FINDING CONTEXT
ps -Z
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
BOOLEANS
▸ On off settings for policies
▸ Allow HTTPD to make network connections
▸ Allow FTP to access home directories
▸ Overcomes issues with over labeling contexts
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
TURNING IT BACK ON
▸ TARGETED
▸ PERMISSIVE
▸ DISABLED (You already know this one)
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
TURNING IT BACK ON
<edit> /etc/selinux/config
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
TURNING IT BACK ON
sudo yum install setroubleshoot setroubleshoot-server
sudo service auditd restart
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
TURNING IT BACK ON
ls -alZ
sudo touch /.autorelabel
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
TURNING IT BACK ON
ls -alZ
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
ZendCon 2016
TEXT
TROUBLESHOOTING EXAMPLE: DATABASE
tail -f /var/log/audit/audit.log
ZendCon 2016
TEXT
TROUBLESHOOTING EXAMPLE: DATABASE
tail -f /var/log/messages
ZendCon 2016
TEXT
TROUBLESHOOTING EXAMPLE: DATABASE
sealert -l <message id>
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
BOOLEANS
setsebool -P httpd_can_network_connect 1
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
BOOLEANS
semanage boolean -l | grep httpd_enable_ftp_server
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
BOOLEANS
getsebool -a
getsebool <boolean>
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
BOOLEANS
semanage boolean -l | grep httpd_enable_ftp_server
ZendCon 2016
TEXT
TROUBLESHOOTING EXAMPLE: FILE UPLOAD
ls -Z
ZendCon 2016
TEXT
TROUBLESHOOTING EXAMPLE: FILE UPLOAD
sealert -l <message id>
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
SETTING CONTEXT
chcon -R -t httpd_sys_content_t web/
ls -Z web
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
SETTING CONTEXT
mkdir web/
touch web/file{1,2,3}
ls -Z web
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
ZendCon 2016
HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
RESOURCES
▸ RedHat Documentation for SELINUX: https://access.redhat.com/
documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security-
Enhanced_Linux/index.html
▸ Servers for Hackers, Batteling SELINUX: https://serversforhackers.com/video/
battling-selinux-cast
▸ SELinux For Mere Mortals: https://www.youtube.com/watch?v=MxjenQ31b70
THANKS
CHUCK REEVES @MANCHUCK

More Related Content

PPT
Introduction To SELinux
PPTX
ODP
SELinux Basic Usage
PDF
SELinux introduction
PDF
Understanding SELinux For the Win
PDF
Selinux
PDF
MR201406 A Re-introduction to SELinux
ODP
Introduction to Selinux
Introduction To SELinux
SELinux Basic Usage
SELinux introduction
Understanding SELinux For the Win
Selinux
MR201406 A Re-introduction to SELinux
Introduction to Selinux

What's hot (20)

PDF
The SElinux Notebook :the foundations - Vol 1
PPTX
Security Enhanced Linux Overview
ODP
chroot and SELinux
PDF
SELinux basics
ODP
SELinux for Everyday Users
PDF
How to not disable SELinux
PDF
2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview
PDF
How Many Linux Security Layers Are Enough?
PDF
Kernel Recipes 2013 - Linux Security Modules: different formal concepts
PPTX
Linux security introduction
PPT
Linux Security
PPT
Threats, Vulnerabilities & Security measures in Linux
PPT
Linux Operating System Vulnerabilities
PPT
Basic Linux Security
PPT
Security and Linux Security
ODP
Security, Hack1ng and Hardening on Linux - an Overview
ODP
Introduction To Linux Security
PDF
2008 08-12 SELinux: A Key Component in Secure Infrastructures
ODP
Linux Network Security
PPTX
Ssh (The Secure Shell)
The SElinux Notebook :the foundations - Vol 1
Security Enhanced Linux Overview
chroot and SELinux
SELinux basics
SELinux for Everyday Users
How to not disable SELinux
2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview
How Many Linux Security Layers Are Enough?
Kernel Recipes 2013 - Linux Security Modules: different formal concepts
Linux security introduction
Linux Security
Threats, Vulnerabilities & Security measures in Linux
Linux Operating System Vulnerabilities
Basic Linux Security
Security and Linux Security
Security, Hack1ng and Hardening on Linux - an Overview
Introduction To Linux Security
2008 08-12 SELinux: A Key Component in Secure Infrastructures
Linux Network Security
Ssh (The Secure Shell)
Ad

Similar to How to use SELINUX (No I don't mean turn it off) (20)

PDF
Null bhopal Sep 2016: What it Takes to Secure a Web Application
PPTX
drupal ci cd concept cornel univercity.pptx
PDF
Fosdem_Using_SELinux_with_container_runtimes.pdf
PDF
Securing Cassandra for Compliance
PDF
Hardening cassandra q2_2016
PPTX
Introduction to ansible
PDF
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
PDF
Installation guide
PDF
Avoid the Vendor Lock-in Trap (with App Deployment)
PDF
WordPress Security
PPT
Professional deployment
PDF
Big data Analytics hands-on sessions
PDF
4 effective methods to disable se linux temporarily or permanently
PPT
ZenPack Development with Jane Curry
PDF
Red Hat Linux 5 Hardening Tips - National Security Agency
ODP
Configuration Management and Salt
PDF
Introduction to WP-CLI: Manage WordPress from the command line
PDF
Real-World DevOps — 20 Practical Developers Tips for Tightening Your Operatio...
PPTX
Hadoop 2.4 installing on ubuntu 14.04
PDF
Lean Drupal Repositories with Composer and Drush
Null bhopal Sep 2016: What it Takes to Secure a Web Application
drupal ci cd concept cornel univercity.pptx
Fosdem_Using_SELinux_with_container_runtimes.pdf
Securing Cassandra for Compliance
Hardening cassandra q2_2016
Introduction to ansible
[Devconf.cz][2017] Understanding OpenShift Security Context Constraints
Installation guide
Avoid the Vendor Lock-in Trap (with App Deployment)
WordPress Security
Professional deployment
Big data Analytics hands-on sessions
4 effective methods to disable se linux temporarily or permanently
ZenPack Development with Jane Curry
Red Hat Linux 5 Hardening Tips - National Security Agency
Configuration Management and Salt
Introduction to WP-CLI: Manage WordPress from the command line
Real-World DevOps — 20 Practical Developers Tips for Tightening Your Operatio...
Hadoop 2.4 installing on ubuntu 14.04
Lean Drupal Repositories with Composer and Drush
Ad

More from Chuck Reeves (9)

PDF
Stop multiplying by 4 Laracon
PDF
Stop multiplying by 4 Lone Star PHP
PDF
Single page Apps with Angular and Apigility
PDF
Zend Framework Foundations
PPTX
Stop multiplying by 4 nyphp
PPTX
Stop multiplying by 4 PHP Tour 2014
PPTX
Stop multiplying by 4: Practical Software Estimation
PPTX
Software requirements and estimates
PPTX
How x debug restored partial sanity to the insane
Stop multiplying by 4 Laracon
Stop multiplying by 4 Lone Star PHP
Single page Apps with Angular and Apigility
Zend Framework Foundations
Stop multiplying by 4 nyphp
Stop multiplying by 4 PHP Tour 2014
Stop multiplying by 4: Practical Software Estimation
Software requirements and estimates
How x debug restored partial sanity to the insane

Recently uploaded (20)

PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
KodekX | Application Modernization Development
PDF
cuic standard and advanced reporting.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Encapsulation_ Review paper, used for researhc scholars
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Network Security Unit 5.pdf for BCA BBA.
20250228 LYD VKU AI Blended-Learning.pptx
Programs and apps: productivity, graphics, security and other tools
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Understanding_Digital_Forensics_Presentation.pptx
Electronic commerce courselecture one. Pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Machine learning based COVID-19 study performance prediction
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
The Rise and Fall of 3GPP – Time for a Sabbatical?
KodekX | Application Modernization Development
cuic standard and advanced reporting.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Encapsulation_ Review paper, used for researhc scholars
“AI and Expert System Decision Support & Business Intelligence Systems”
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Chapter 3 Spatial Domain Image Processing.pdf
Big Data Technologies - Introduction.pptx
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
MYSQL Presentation for SQL database connectivity
Network Security Unit 5.pdf for BCA BBA.

How to use SELINUX (No I don't mean turn it off)

  • 2. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF ABOUT ▸ Built using Kernel Modules ▸ More permissions than CRUD and Access ▸ Allows Multi-Level Security using BLP and Biba Models ▸ Permissions set on the inode instead of the file ▸ Mandatory Access Control (MAC)
  • 3. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
  • 4. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF WHAT YOU NEED TO KNOW ▸ Each iNode is given a single context ▸ Each context identifies a user, role, type and level ▸ SELINUX then allows (or denies) access using the context with a policy ▸ Decision is cached in the Access Vector Cache (AVC) ▸ Decisions is made after the DAC access is checked
  • 5. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF WHAT YOU NEED TO KNOW ▸ SELINUX manages: ▸ Users ▸ Sockets ▸ Memory ▸ Directories ▸ TCP/UDP connections
  • 6. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF PROCESS TYPES ▸ Confined ▸ Runs in own domain (role) ▸ Resources are limited to the roles and policy ▸ Un-Confined ▸ fallback to the DAC policies
  • 7. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF CONTEXTS ▸ Policy checks context of inode for access ▸ "If a process is running with <context_foo> then anything with <context_foo_type> is allowed access" ▸ Four parts: user, role, type and level (optional)
  • 8. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF CONTEXTS ▸ Set automatically based on the parent context (mostly) ▸ RPM ▸ Management tools (ansible, chef, puppet) ▸ When a File transitions (moving an uploaded file) ▸ By the sysadmin with chcon, restorecon
  • 9. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF FINDING CONTEXT ls -alZ /home
  • 10. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF FINDING CONTEXT ps -Z
  • 11. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF BOOLEANS ▸ On off settings for policies ▸ Allow HTTPD to make network connections ▸ Allow FTP to access home directories ▸ Overcomes issues with over labeling contexts
  • 12. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF TURNING IT BACK ON ▸ TARGETED ▸ PERMISSIVE ▸ DISABLED (You already know this one)
  • 13. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF TURNING IT BACK ON <edit> /etc/selinux/config
  • 14. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF TURNING IT BACK ON sudo yum install setroubleshoot setroubleshoot-server sudo service auditd restart
  • 15. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF TURNING IT BACK ON ls -alZ sudo touch /.autorelabel
  • 16. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF TURNING IT BACK ON ls -alZ
  • 17. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
  • 18. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
  • 19. ZendCon 2016 TEXT TROUBLESHOOTING EXAMPLE: DATABASE tail -f /var/log/audit/audit.log
  • 20. ZendCon 2016 TEXT TROUBLESHOOTING EXAMPLE: DATABASE tail -f /var/log/messages
  • 21. ZendCon 2016 TEXT TROUBLESHOOTING EXAMPLE: DATABASE sealert -l <message id>
  • 22. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF BOOLEANS setsebool -P httpd_can_network_connect 1
  • 23. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF BOOLEANS semanage boolean -l | grep httpd_enable_ftp_server
  • 24. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF BOOLEANS getsebool -a getsebool <boolean>
  • 25. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF BOOLEANS semanage boolean -l | grep httpd_enable_ftp_server
  • 27. ZendCon 2016 TEXT TROUBLESHOOTING EXAMPLE: FILE UPLOAD sealert -l <message id>
  • 28. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF SETTING CONTEXT chcon -R -t httpd_sys_content_t web/ ls -Z web
  • 29. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF SETTING CONTEXT mkdir web/ touch web/file{1,2,3} ls -Z web
  • 30. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
  • 31. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
  • 32. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF
  • 33. ZendCon 2016 HOW TO USE SELINUX - NO I DON'T MEAN TURN IT OFF RESOURCES ▸ RedHat Documentation for SELINUX: https://access.redhat.com/ documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security- Enhanced_Linux/index.html ▸ Servers for Hackers, Batteling SELINUX: https://serversforhackers.com/video/ battling-selinux-cast ▸ SELinux For Mere Mortals: https://www.youtube.com/watch?v=MxjenQ31b70