The Selinux Notebook - the Foundations
Total Page:16
File Type:pdf, Size:1020Kb
The SELinux Notebook - The Foundations The SELinux Notebook The Foundations Page 1 The SELinux Notebook - The Foundations 0. Notebook Information 0.1 Copyright Information Copyright © 2009 Richard Haines. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNUFree Documentation License”. The scripts and source code in this Notebook are covered by the GNU General Public License. The scripts and code are free source: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. These are distributed in the hope that they will be useful in researching SELinux, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with scripts and source code. If not, see <http://www.gnu.org/licenses/>. 0.2 Revision History Version Date Description of Change Changed By 1.0 20th Nov ‘09 First release. Richard Haines 0.3 Acknowledgements Logo designed by Máirín Duffy 0.4 Abbreviations Term Definition apol Policy analysis tool AV Access Vector AVC Access Vector Cache BLP Bell-La Padula CC Common Criteria CMW Compartmented Mode Workstation DAC Discretionary Access Control Page 2 The SELinux Notebook - The Foundations Term Definition F-10 Fedora 10 FLASK Flux Advanced Security Kernel - A security-enhanced version of the Fluke kernel and OS developed by the Utah Flux team and the US Department of Defence. Fluke Flux µ-kernel Environment - A specification and implementation of a micro kernel and Operating System architecture. Flux The Flux Research Group (http://www.cs.utah.edu/flux/) ID Identification LSM Linux Security Module LSPP Labeled Security Protection Profile MAC Mandatory Access Control MCS Multi-Category Security MLS Multi-Level Security NSA National Security Agency OM Object Manager PAM Pluggable Authentication Module RBAC Role-based Access Control rpm Red Hat Package Manager SELinux Security-Enhanced Linux SID Security Identifier SL Security Level SLIDE SELinux Integrated Development Environment SMACK Simplified Mandatory Access Control Kernel SUID Super-user Identifier TE Type Enforcement UID User Identifier 0.5 Index 0. NOTEBOOK INFORMATION .............................................................................. 2 0.1 COPYRIGHT INFORMATION .......................................................................................... 2 0.2 REVISION HISTORY ................................................................................................... 2 0.3 ACKNOWLEDGEMENTS ................................................................................................ 2 0.4 ABBREVIATIONS ........................................................................................................ 2 0.5 INDEX ..................................................................................................................... 3 0.5.1 Tables .......................................................................................................... 11 0.5.2 Figures ........................................................................................................ 12 1. THE SELINUX NOTEBOOK .............................................................................. 16 1.1 INTRODUCTION ........................................................................................................ 16 1.1.1 Sample Policy Source ................................................................................. 16 Page 3 The SELinux Notebook - The Foundations 1.2 HEALTH WARNING ................................................................................................. 16 1.3 ROOT LOGIN REQUIREMENTS .................................................................................... 17 1.4 RELEVANT F-10 PACKAGES ..................................................................................... 17 1.5 NOTEBOOK SECTIONS .............................................................................................. 18 2. SELINUX OVERVIEW ........................................................................................ 20 2.1 INTRODUCTION ........................................................................................................ 20 2.2 CORE SELINUX COMPONENTS .................................................................................. 20 2.3 MANDATORY ACCESS CONTROL (MAC) ................................................................... 23 2.4 TYPE ENFORCEMENT (TE) ....................................................................................... 24 2.4.1 Constraints .................................................................................................. 25 2.5 ROLE-BASED ACCESS CONTROL (RBAC) ................................................................ 26 2.6 SECURITY CONTEXT ................................................................................................ 26 2.7 SUBJECTS ............................................................................................................... 28 2.8 OBJECTS ................................................................................................................ 29 2.8.1 Object Classes and Permissions ................................................................. 29 2.8.2 Allowing a Process Access to an Object ..................................................... 30 2.8.3 Labeling Objects ......................................................................................... 31 2.8.3.1 Labeling Extended Attribute Filesystems ............................................ 32 2.8.3.1.1 Copying and Moving Files ............................................................ 32 2.8.3.2 Labeling Subjects ................................................................................. 34 2.8.4 Object Reuse ............................................................................................... 34 2.9 DOMAIN AND OBJECT TRANSITIONS ........................................................................... 34 2.9.1 Domain Transition ...................................................................................... 35 2.9.1.1 Type Enforcement Rules ...................................................................... 36 2.9.2 Object Transition ........................................................................................ 38 2.10 MULTI-LEVEL SECURITY AND MULTI-CATEGORY SECURITY ....................................... 39 2.10.1 Security Levels .......................................................................................... 41 2.10.1.1 MLS / MCS Range Format ................................................................ 41 2.10.1.2 Translating Levels .............................................................................. 42 2.10.2 Managing Security Levels via Dominance Rules ...................................... 42 2.10.3 MLS Labeled Network and Database Support .......................................... 44 2.10.4 Common Criteria Certification ................................................................. 44 2.11 TYPES OF SELINUX POLICY ................................................................................... 45 2.11.1 Example Policy ......................................................................................... 45 2.11.2 Reference Policy ....................................................................................... 45 2.11.2.1 Policy Functionality Type .................................................................. 46 2.11.3 Custom Policy ........................................................................................... 46 2.11.4 Monolithic Policy ...................................................................................... 47 2.11.5 Loadable Module Policy ........................................................................... 47 2.11.5.1 Optional Policy ................................................................................... 47 2.11.6 Conditional Policy .................................................................................... 47 2.11.7 Binary Policy ............................................................................................ 48 2.11.8 Policy Versions ......................................................................................... 48 2.12 SELINUX PERMISSIVE AND ENFORCING MODES ........................................................ 49 2.13 AUDIT LOGS ........................................................................................................ 50 2.13.1 SELinux-aware Application Envents ........................................................ 50 2.13.2 AVC Audit Events ...................................................................................... 52 2.14 POLYINSTANTIATION .............................................................................................. 54 2.14.1 Polyinstantiation support in PAM ............................................................ 54 Page 4 The SELinux Notebook - The Foundations 2.14.1.1 namespace.conf Configuration File ...................................................