Writing SELinux Policy Daniel Walsh Red Hat. Language M4 Macros Name ● module rwhod 1.0; ● policy_module(rwhod,1.0)

Slides:



Advertisements
Similar presentations
The Linux Audit Framework
Advertisements

By: Arpit Pandey SELINUX (SECURITY-ENHANCED LINUX)
Controlling Processes & Periodic Processes WeeSan Lee
SELinux (Security Enhanced Linux) By: Corey McClurg.
1 Case Study 1: UNIX and LINUX Chapter History of unix 10.2 Overview of unix 10.3 Processes in unix 10.4 Memory management in unix 10.5 Input/output.
Shane Jahnke CS591 December 7,  What is SELinux?  Changing SELinux Policies  What is SLIDE?  Reference Policy  SLIDE  Installation and Configuration.
Linux File Security. What is Permission ? Specifies what right are granting to users to access the resources available in the computer. So that important.
LERSAIS.  Access Control in Unix  Access Control in Windows  Port Redirection 2.
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.
Implementing SELinux as a Linux Security Module By Stephen Smalley Chris Vance & Wayne Salamon Presentation by: KASHIF HASAN
Security-Enhanced Linux & Linux Security Module The George Washington University CS297 Programming Language & Security YU-HAO HU.
Guide to Operating System Security Chapter 5 File, Directory, and Shared Resource Security.
Filesystem Hierarchy Standard (FHS) –Standard of outlining the location of set files and directories on a Linux system –Gives Linux software developers.
Secure Operating Systems
1 Guide to Novell NetWare 6.0 Network Administration Chapter 12.
SELinux US/Fedora/13/html/Security-Enhanced_Linux/
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.
File Permissions. What are the three categories of users that apply to file permissions? Owner (or user) Group All others (public, world, others)
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.
File Permission and Access. Module 6 File Permission and Access ♦ Introduction Linux is a multi-user system where users can assign different access permission.
G53SEC 1 Access Control principals, objects and their operations.
Week Six Agenda Announcements Link of the week Review week four lab assignment This week’s expected outcomes Next lab assignment Break-out problems Upcoming.
Guide to Linux Installation and Administration, 2e1 Chapter 11 Using Advanced Administration Techniques.
1 LINUX SECURITY. 2 Outline Introduction Introduction - UNIX file permission - UNIX file permission - SUID / SGID - SUID / SGID - File attributes - File.
SELinux. The need for secure OS Increasing risk to valuable information Dependence on OS protection mechanisms Inadequacy of mainstream operating systems.
Mandatory Access Control and SE Linux CS 460 Cyber Security Lab Spring ‘10.
Security-Enhanced Linux Eric Harney CPSC 481. What is SELinux? ● Developed by NSA – Released in 2000 ● Adds additional security capabilities to Linux.
Isecur1ty training center Presented by : Eng. Mohammad Khreesha.
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.
Microsoft ® Official Course Module 6 Managing Software Distribution and Deployment by Using Packages and Programs.
Unix System Administration Controlling Processes Chapter 5.
Security-Enhanced Linux Stephanie Stelling Center for Information Security Department of Computer Science University of Tulsa, Tulsa, OK
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
1 SELinux/RHEL5 Ken Rielly Dan Walsh BASE OS Engineering Red Hat Software, Inc. Company Confidential.
SELinux Overview ● Permissions historically – Why is unix or ACL permissions not good enough? ● DAC vs. MAC ● SELinux ID, objects, roles and types ● Policy.
SELinux Update Karl MacMillan, Tresys Dan Walsh, Red Hat.
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.
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.
SELinux: Best Practices and What's New in Red Hat Enterprise Linux 5 Name Dan Walsh Date Wednesday May 9 th 2007.
What is SELinux trying to tell me? The 4 key causes of SELinux errors.
SELinux Overview DAC vs MAC Discretionary Access Control Mandatory
Privileges: who can control what
Managing SELinux in the Enterprise
Demystifying SELinux Part II: Who’s Policy Is It Anyway
...looking a bit closer under the hood
Secure Operating System
Business rules.
Writing SELinux Policy | Permissive Domains | Real bugs
SELinux for Dummies Dan Walsh.
Secure Operating System Example: SELinux
Demystifying SELinux: WTF is it saying?
Case Study 1: UNIX and LINUX
Chapter 11: Managing Users
SELinux Daniel J Walsh SELinux Lead Engineer.
SELinux in 20 Minutes LCA Miniconf Jan. 28th, Canberra AU
SELinux RHEL5: A benchmark
IS3440 Linux Security Unit 6 Using Layered Security for Access Control
SELinux (Security Enhanced Linux)
Department of School of Computing and Engineering
Access Control and Audit
EASEAndroid: Automatic Analysis and Refinement for SEAndroid Policy
Presentation transcript:

Writing SELinux Policy Daniel Walsh Red Hat

Language M4 Macros Name ● module rwhod 1.0; ● policy_module(rwhod,1.0)

Type Field ● type rwhod_t; # Process Type (Domain) ● type rwhod_exec_t; # File Type gen_require(` type shadow_t; ')

Policy Rules COMMAND SOURCETYPE TARGETTYPE:CLASS PERMS; COMMANDS ● allow - Most common ● Dontaudit – Deny Access, but do not log ● auditallow – Allow access but log a message ● neverallow – Stop policy from building if allow rule added allow user_t etc_t:file { open read getattr ioctl lock}; allow sudo_t self:process setuid; dontaudit httpd_t krb5_conf_t:file write; auditallow user_t shadow_t:file write;

Policy Rules ➔ class ➔ file, dir, sock_file, tcp_socket, process, capability ➔ Permissions – Per Class ➔ read write ioctl ➔ setuid chown ➔ Macro definitions ➔ read_file_perms, manage_sock_file_perms; /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;

Interfaces ➔ Policy Function Calls ➔ Stored in if files /usr/share/selinux/devel/include/kernel/files.if ➔ files_type(shadow_t) ➔ init_system_domain(rwhod_t, rwhod_exec_t) ➔ corenet_tcp_connect_mssql_port(httpd_php_t)

SELinux Policy Modules Allows users to easily customize policy Allows third parties to ship policy with their rpms Similar to kernel Modules ● Recompile and reload

Policy Modules 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.

Building Policy Packages Makefile ● # make -f /usr/share/selinux/devel/Makefile Install ● # semodule -i rwhod.pp Setup file context ● # restorecon -R /var/run/rwhod

Building Policy Packages Lather Rince Repeat ● 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

Audit2allow time->Thu Apr 12 05:12: type=PATH msg=audit( :1514): item=0 name="/usr/games/vultureseye/vultureseye.#prelink#.m8SXxq" inode= dev=fd:00 mode= ouid=0 ogid=0 rdev=00:00 obj=system_u:object_r:usr_t:s0 type=CWD msg=audit( :1514): cwd="/" type=SYSCALL msg=audit( :1514): arch= syscall=5 success=no exit=-13 a0=bfe58b40 a1=80c2 a2=180 a3=180 items=1 ppid=1443 pid=1452 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) comm="prelink" exe="/usr/sbin/prelink" subj=user_u:system_r:prelink_t:s0 key=(null) type=AVC msg=audit( :1514): avc: denied { add_name } for pid=1452 comm="prelink" name="vultureseye.#prelink#.m8SXxq" scontext=user_u:system_r:prelink_t:s0 tcontext=system_u:object_r:usr_t:s0 tclass=dir # audit2allow -i /var/log/audit/audit.log allow prelink_t usr_t:dir add_name; # audit2allow -R -i /var/log/audit/audit.log require { type prelink_t; } files_rw_usr_dirs(prelink_t)

MOST IMPORTANT THING TO LEARN TODAY audit2allow – Just MAKE IT WORK????? # audit2allow -M myprelink -R -i /var/log/audit/audit.log ******************** IMPORTANT *********************** To make this policy package active, execute: semodule -i myprelink.pp # ls myprelink* myprelink.fc myprelink.if myprelink.pp myprelink.te

selinux-polgengui

Generates 4 files ● te, fc, if file ● sh file used to compile/load/set file context selinux-polgengui is not an editor. Required Fields ● Name ● Executable ● Application Type Important Fields ● What files/directories does application modify?

sepolgen > sepolgen /usr/sbin/rwhod Created the following files: Type Enforcement file./rwhod.te Interface file./rwhod.if File Contexts file./rwhod.fc Setup Script./rwhod.sh # sh rwhod.sh

TreSys Slide – Eclipse Policy Editor

Lets Start Generating Policy