Writing SELinux Policy | Permissive Domains | Real bugs

Slides:



Advertisements
Similar presentations
Microsoft Windows Server 2008 Software Deployment Chris Rutherford EKU Technology: CEN/CET.
Advertisements

By: Arpit Pandey SELINUX (SECURITY-ENHANCED LINUX)
SELinux (Security Enhanced Linux) By: Corey McClurg.
Shane Jahnke CS591 December 7,  What is SELinux?  Changing SELinux Policies  What is SLIDE?  Reference Policy  SLIDE  Installation and Configuration.
SELinux For Dummies Gary Smith, EMSL, Pacific Northwest National Laboratory.
ADVANCED LINUX SECURITY. Abstract : Using mandatory access control greatly increases the security of an operating system. SELinux, which is an implementation.
Security-Enhanced Linux & Linux Security Module The George Washington University CS297 Programming Language & Security YU-HAO HU.
Security Enhanced Linux (SELinux)
Operating System Program 5 I/O System DMA Device Driver.
1 Integrated Development Environment Building Your First Project (A Step-By-Step Approach)
Secure Operating Systems
Database Security and Auditing: Protecting Data Integrity and Accessibility Chapter 3 Administration of Users.
SELinux US/Fedora/13/html/Security-Enhanced_Linux/
Firewall Dave Grizzanti Steve Curti. What is an Internet Firewall? An Internet firewall is most often installed at the point where your protected internal.
Linux kernel security Professor: Mahmood Ranjbar Authors: mohammad Heydari Mahmood ZafarArjmand Zohre Alihoseyni Maryam Sabaghi.
Security Enhanced Linux David Quigley. History SELinux Timeline 1985:LOCK (early Type Enforcement) 1990: DTMach / DTOS 1995: Utah Fluke / Flask 1999:
Security-Enhanced Linux. References  Implementation of Security-Enhanced Linux by Yue Cui, Xiang Sha, Li Song  Security Enhanced Linux by David Quigley.
FOSS Security through SELinux (Security Enhanced Linux) M.B.G. Suranga De Silva Information Security Specialist TECHCERT c/o Department of Computer Science.
1 Implementation of Security-Enhanced Linux Yue Cui Xiang Sha Li Song CMSC 691X Project 2—Summer 02.
CIS 290 Linux Security Program Authentication Module and Security Enhanced LINUX.
Writing macros and programs for Voyager cataloging Kathryn Lybarger ELUNA 2013 May 3, #ELUNA2013.
Guide to Linux Installation and Administration, 2e1 Chapter 11 Using Advanced Administration Techniques.
SELinux. The need for secure OS Increasing risk to valuable information Dependence on OS protection mechanisms Inadequacy of mainstream operating systems.
NetTech Solutions Troubleshooting Office Applications Lesson Seven.
Mandatory Access Control and SE Linux CS 460 Cyber Security Lab Spring ‘10.
The SELinux of First Look. Prologue After many discussions with a lot of Linux users, I’ve come to realize that most of them seem to disable SELinux rather.
Security-Enhanced Linux Eric Harney CPSC 481. What is SELinux? ● Developed by NSA – Released in 2000 ● Adds additional security capabilities to Linux.
5/7/2007CoreMcClug/SELinux 1 By: Corey McClurg. Outline A History of SELinux What is SELinux and how do I get it? Getting Started Mandatory Access Control.
Security-Enhanced Linux Stephanie Stelling Center for Information Security Department of Computer Science University of Tulsa, Tulsa, OK
System initialization Unit objectives A.Outline steps necessary to boot a Linux system, configure LILO and GRUB boot loaders, and dual boot Linux with.
GROUP POLICY. Group Policy is a hierarchical infrastructure which allows systems administrators to configure computer and user settings from a central.
C Copyright © 2006, Oracle. All rights reserved. Oracle Secure Backup Additional Installation Topics.
Chapter 2 Build Your First Project A Step-by-Step Approach 2 Exploring Microsoft Visual Basic 6.0 Copyright © 1999 Prentice-Hall, Inc. By Carlotta Eaton.
Dan Walsh May 5, 2011 Red Hat Enterprise Linux 6 Writing SELinux Policy.
1 Introduction to SELinux David P. Quigley National Security Agency National Information Assurance Research Laboratory (NIARL)
How to live with SELinux
SELinux Overview ● Permissions historically – Why is unix or ACL permissions not good enough? ● DAC vs. MAC ● SELinux ID, objects, roles and types ● Policy.
Linux Kernel Security (SELinux vs AppArmor vs Grsecurity)
SELinux Sandbox Daniel Walsh Red Hat. What is a sandbox ➔ Run general applications in a locked down environment. ➔ Less privileged then other processes.
Server Security 1 SE Linux, Systrace Lars Noodén March – April 2009.
SELinux Overview Dan Walsh SELinux for Dummies Dan Walsh
Red Hat Enterprise Linux 5 Security April Red Hat Development Model Collaboration with partners and open source contributors to develop technology.
Writing SELinux Policy Daniel Walsh Red Hat. Language M4 Macros Name ● module rwhod 1.0; ● policy_module(rwhod,1.0)
SELinux: Best Practices and What's New in Red Hat Enterprise Linux 5 Name Dan Walsh Date Wednesday May 9 th 2007.
Introduction to Python for System Administrators Toshio Kuratomi May 2011.
What is SELinux trying to tell me? The 4 key causes of SELinux errors.
SELinux Overview DAC vs MAC Discretionary Access Control Mandatory
Migrating to LDAP What is LDAP? Fedora Directory Server LdapImport
Managing SELinux in the Enterprise
Demystifying SELinux Part II: Who’s Policy Is It Anyway
Multi-Category Security (MCS)
OpenShift & SELinux Dan Walsh Twitter: #rhatdan
Start-SPPowerShell – Introduction to PowerShell for SharePoint Admins and Developers Paul BAker.
Secure Operating System
Architecture Review 10/11/2004
Linux Security Presenter: Dolev Farhi |
Chapter 11 Command-Line Master Class
SELinux for Dummies Dan Walsh.
Secure Operating System Example: SELinux
Demystifying SELinux: WTF is it saying?
SELinux Daniel J Walsh SELinux Lead Engineer.
SELinux in 20 Minutes LCA Miniconf Jan. 28th, Canberra AU
SELinux RHEL5: A benchmark
New Features in Fedora Core 5
IS3440 Linux Security Unit 6 Using Layered Security for Access Control
SharePoint Saturday Omaha April 2016
SELinux (Security Enhanced Linux)
SELinux
Convergence IT Services Pvt. Ltd
Presentation transcript:

Writing SELinux Policy | Permissive Domains | Real bugs Fun with SELinux Writing SELinux Policy | Permissive Domains | Real bugs Presented by Miroslav Grepl mgrepl@redhat.com

Today's Topics Show process of writing a policy Real examples - understanding basics of SELinux == labels - using SELinux tools - Permissive Domains Real examples - creating & testing portreserve policy - how to solve real bug (Bip – IRC proxy) - creating a new policy???

Known basics? the most important part of SELinux type enforcement language everything on a SELinux system has a type - processes, files security context system_u:object_r:etc_t:s0 policy decision security context labels are used to make access control decisions between processes and objects

Known basics? SELinux decision

Known basics? using security context audit log records the following: # id -Z root:staff_r:staff_t # cat /etc/shadow cat: /etc/shadow: Permission denied # sesearch -A -s staff_t -t shadow_t -c file -p read ... what does it return?? audit log records the following: avc: denied { read } for pid=13653 exe=/bin/cat name=shadow dev=hda6 ino=1361441 scontext=root:staff_r:staff_t tcontext=system_u:object_r:shadow_t tclass=file

Policy rules type field each subject (process), object (file) has a type declaration type portreserve_t; # Process Type (Domain) type portreserve_exec_t; # File Type

Policy rules policy rules statement COMMAND COMMAND SOURCETYPE TARGETTYPE:CLASS PERMS; COMMAND allow, dontaudit, audit2allow, neverallow allow staff_t etc_t:file { open read getattr ioctl lock}; dontaudit staff_t shadow_t:file { open read getattr ioctl lock};

Policy rules policy rules statement CLASS COMMAND SOURCETYPE TARGETTYPE:CLASS PERMS; CLASS file, dir, sock_file, tcp_socket, process PERMS read, open, write macros can be used define(`r_file_perms', `{ open read getattr lock ioctl } /usr/share/selinux/devel/include/support/obj_perm_sets.spt

Policy rules attribute group types attribute file_type type etc_t, file_type typeattribute etc_t, file_type allow rpm_t file_type:file manage_file_perms

Policy rules Attributes decrease size of policy on a Fedora 15 $ seinfo Allow: 282 444 Dontaudit: 184 516 on Fedora 16 Allow: 88 242 Dontaudit: 11 302

Policy module place where all policy statements are located allows users to easily customize policy allows third parties to ship policy with their rpms similar to kernel modules recompile and reload

Policy module Policy Package (pp) Three Components Type Enforcement (TE) File Contains all the rules used to confine your application File Context (FC) File Contains the regular expression mappings for on disk file contexts Interface (IF) Files Contains the interfaces defined for other confined applications, to interact with your confined application Policy Package (pp) Compiler/packager roles generates policy package to be installed on systems.

LET'S START GENERATING POLICY

Setup environment Disable portreserve policy # semodule -d portreserve.pp Fix labels # for i in `rpm -ql portreserve`;do restorecon -R -v $i;done # systemctl restart portreserve.service Default initrc_t domain unconfined domain for process started by init system process without policy

SELinux transition, labels Transitions without transition using service script initrc_t @bin_t -> initrc_t with transition using service script initrc_t @portreserve_exec_t -> portreserve_t run directly unconfined_t @portreserve_exec_t-> unconfined_t => SELINUX IS ALL ABOUT LABELS

Generating initial policy Using sepolgen or sepolgen-gui give you policy files # sepolgen -n myportreserve -t 0 `which portreserve` Created the following files in: ./ portreserve.te # Type Enforcement file Contains all the rules used to confine your application portreserve.fc # Interface file Contains the regular expression mappings for on disk file contexts portreserve.if # File Contexts file Contains the interfaces defined for other confined applications, to interact with your confined application

Generating initial policy Install policy using setup script # sh myportreserve.sh using Makefile # make -f /usr/share/selinux/deve/Makefile # semodule -i myportreserve.pp # for i in `rpm -ql portreserve`;do restorecon -R -v $i;done Do some checks # semodule -l | grep portreserve # ps -eZ | grep portre # ausearch -m avc -ts recent

Permissive Domains initial policies are running as permissive domains # permissive myportreserve_t checks are performed but not enforced users don't have to switch to permissive mode globally we can catch AVC messages # ausearch -m avc -ts recent | grep portreserve make domain permissive # semanage permissive -a httpd_t

Building policy loop until good policy test application generate avc messages audit2allow examines /var/log/audit/audit.log and /var/log/messages for AVC messages searches interface files for correct interface if no interface found generates allow rules

Building policy audit2allow in practise audit2allow -R require { type=AVC msg=audit(04/22/2011 11:53:51.194:49) : avc: denied { read } for pid=7695 comm=dictd scontext=unconfined_u:system_r:dictd_t:s0 tcontext=system_u:object_r:sysctl_kernel_t:s0 tclass=fil audit2allow -R require { type dictd_t; } #=========== dictd_t ============== kernel_read_kernel_sysctls(dictd_t)

Complete our policy ausearch, audit2allow tools # ausearch -m avc -ts today | grep portreserve | audit2allow -R compile and load rules # ausearch -m avc -ts today | grep portreserve | audit2allow -R >> myportreserve.te # make -f /usr/share/selinux/devel/Makefile # semodule -i myportreserve.pp test it without permissive domain sed -i s/^permissive/#permissive/ portreserve.te

Complete our policy MOST IMPORTANT THING TO LEARN TODAY audit2allow – Just MAKE IT WORK?????

Real bug – bip issue new policies for new unconfined services/apps? are not always necessary spamc_t domain type treat a lot of spam apps does not make sense creating new policy for each spam apps? policy has many types to use for example bip IRC proxy there was the following bug

Real bug – bip issue https://bugzilla.redhat.com/show_bug.cgi?id= 783693 avc: denied { name_bind } for pid=2897 comm="bip" src=6667 scontext=system_u:system_r:initrc_t:s0 tcontext=system_u:object_r:ircd_port_t:s0 tclass=tcp_socket runnig as initrc_t -> causes issues - add a custom module using audit2allow - create a new policy - use a current policy => which one ???

Real bug – bip issue use a current policy which one? => we know bitlbee is similar => does bitlbee policy exist? # seinfo -t |grep bitlbee which type will we use for bip binary? # chcon -t ???_t `which bip` # service bip restart

Real bug – unconfined services There are services without SELinux confinement => running as initrc_t bcfg2-server, glusterd rpc.rstatd, rpc.rusersd pacemaker, pkcsslotd, fence_virtd, openhpid, isnsd, sfcbd, svnserve, stap-serverd

Backup your environment load the default policy using semodule # semodule -r myportreserve -e portreserve fix labels using restorecon # for i in .. # systemctl restart portreserve.service remove permissive domain using semanage # semanage permissive -d httpd

Links http://danwalsh.livejournal.com/ http://dwalsh.fedorapeople.org/ http://mgrepl.wordpress.com/ http://mgrepl.fedorapeople.org/

Questions? Contact: mgrepl@redhat.com