SlideShare a Scribd company logo
Soumettre la recherche
Mettre en ligne
S’identifier
S’inscrire
SELinux workshop
Signaler
johseg
Suivre
27 May 2023
•
0 j'aime
•
39 vues
1
sur
31
SELinux workshop
27 May 2023
•
0 j'aime
•
39 vues
Télécharger maintenant
Télécharger pour lire hors ligne
Signaler
Technologie
SELinux workshop for openSUSE conference
johseg
Suivre
Recommandé
selinuxbasicusage.pptx
Pandiya Rajan
6 vues
•
88 diapositives
SELinux Basic Usage
Dmytro Minochkin
935 vues
•
88 diapositives
2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview
Shawn Wells
617 vues
•
83 diapositives
SELinux_@gnu_group_meetup
Jayant Chutke
367 vues
•
30 diapositives
Selinux
Ankit Raj
741 vues
•
14 diapositives
Unix Security
replay21
6.3K vues
•
47 diapositives
Contenu connexe
Similaire à SELinux workshop
SELinux for Everyday Users
PaulWay
12.9K vues
•
66 diapositives
Introduction To SELinux
Rene Cunningham
12.6K vues
•
45 diapositives
Understanding SELinux For the Win
bmbouter
774 vues
•
39 diapositives
4 effective methods to disable se linux temporarily or permanently
chinkshady
865 vues
•
7 diapositives
CloudStack templates with OpenVM
ShapeBlue
1.2K vues
•
10 diapositives
Hardening Linux, introducing Securix GNU/Linux
Martin Holovský
774 vues
•
33 diapositives
Similaire à SELinux workshop
(20)
SELinux for Everyday Users
PaulWay
•
12.9K vues
Introduction To SELinux
Rene Cunningham
•
12.6K vues
Understanding SELinux For the Win
bmbouter
•
774 vues
4 effective methods to disable se linux temporarily or permanently
chinkshady
•
865 vues
CloudStack templates with OpenVM
ShapeBlue
•
1.2K vues
Hardening Linux, introducing Securix GNU/Linux
Martin Holovský
•
774 vues
Aquarium introduction-asia-summit-2021
Alex Lau
•
130 vues
Docker, Linux Containers, and Security: Does It Add Up?
Jérôme Petazzoni
•
9.3K vues
SUSE Expert Days Paris 2018 – SLE 15
SUSE
•
390 vues
LCJ2010-KaiGai-sepgsql
Kohei KaiGai
•
634 vues
Process behaviour modelling using lsm
iaemedu
•
395 vues
Module 17 (novell hacking)
Wail Hassan
•
180 vues
LXC, Docker, security: is it safe to run applications in Linux Containers?
Jérôme Petazzoni
•
22.7K vues
Rancher Rodeo 13 mai 2022
SUSE
•
240 vues
Red Hat Linux 5 Hardening Tips - National Security Agency
sanchetanparmar
•
937 vues
Security workflow with ansible
devanshdubey7
•
207 vues
Open stack meetup 2014 11-13 - 101 + high availability
Rick Ashford
•
763 vues
Se linux course1
OWASP (Open Web Application Security Project)
•
7K vues
2008 08-12 SELinux: A Key Component in Secure Infrastructures
Shawn Wells
•
191 vues
Hardening solaris
Femi Adeyemi
•
479 vues
Dernier
Die ultimative Anleitung für HCL Nomad Web Administratoren
panagenda
57 vues
•
71 diapositives
Data Formats: Reading and writing JSON – XML - YAML
CSUC - Consorci de Serveis Universitaris de Catalunya
54 vues
•
8 diapositives
Advancing Equity and Inclusion for Deaf Students in Higher Education
3Play Media
143 vues
•
24 diapositives
Cloud Composer workshop at Airflow Summit 2023.pdf
Leah Cole
77 vues
•
80 diapositives
Scaling out with WordPress
Konstantin Kovshenin
54 vues
•
55 diapositives
Google Cloud Study Jams Info Session
GDSCPCCE
29 vues
•
13 diapositives
Dernier
(20)
Die ultimative Anleitung für HCL Nomad Web Administratoren
panagenda
•
57 vues
Data Formats: Reading and writing JSON – XML - YAML
CSUC - Consorci de Serveis Universitaris de Catalunya
•
54 vues
Advancing Equity and Inclusion for Deaf Students in Higher Education
3Play Media
•
143 vues
Cloud Composer workshop at Airflow Summit 2023.pdf
Leah Cole
•
77 vues
Scaling out with WordPress
Konstantin Kovshenin
•
54 vues
Google Cloud Study Jams Info Session
GDSCPCCE
•
29 vues
UiPath Tips and Techniques for Error Handling - Session 2
DianaGray10
•
24 vues
Easy Salesforce CI/CD with Open Source Only - Dreamforce 23
NicolasVuillamy1
•
186 vues
Future of Skills
Alison B. Lowndes
•
38 vues
The Ultimate Administrator’s Guide to HCL Nomad Web
panagenda
•
51 vues
Unleashing Innovation: IoT Project with MicroPython
Vubon Roy
•
25 vues
Safe Community Call #12.pdf
LornyPfeifer
•
15 vues
Roottoo Innovation V24_CP.pdf
roottooinnovation
•
25 vues
Connecting Africa.docx
Eric Annan
•
13 vues
Keynote: Two years at the British Library... and counting / Alan Danskin (Bri...
CILIP MDG
•
24 vues
Orchestration, Automation and Virtualisation Maturity Model
CSUC - Consorci de Serveis Universitaris de Catalunya
•
51 vues
Metadata & Discovery Group Conference 2023 - Day 2
CILIP MDG
•
14 vues
Framing Few Shot Knowledge Graph Completion with Large Language Models
MODUL Technology GmbH
•
27 vues
Swiss Re Reinsurance Solutions - Claims Automated Rules Engine – Insurer Inno...
The Digital Insurer
•
19 vues
Improving Employee Experiences on Cisco RoomOS Devices, Webex, and Microsoft ...
ThousandEyes
•
63 vues
SELinux workshop
1.
2023-05-27, NUREMBERG SELinux introduction Johannes
Segitz <jsegitz@suse.com>
2.
Whoami Johannes Segitz, security
engineer at SUSE (Nuremberg, Germany) – code review – product pentesting – The SELinux guy (not the policy maintainer) Copyright © SUSE 2023 2
3.
Outline We will cover: –
Basic SELinux introduction – Install it on openSUSE tumbleweed Copyright © SUSE 2023 3
4.
Ressources needed Please have
an openSUSE Tumbleweed VM ready to play along Make sure you have internet connectivity Copyright © SUSE 2023 4
5.
Expectation management As always
it’s not possible to cover everything in one talk, so: – Mix between – higher level concepts (∼15 minutes) – practice (∼45 minutes) – You will not become a SELinux expert in an hour – We will go as far as possible with the examples. I can stick around afterwards, but we’ll stop officially after the slot ends Copyright © SUSE 2023 5
6.
Nomenclature How to read
the slides Shell: $ this is a root shell Default is root. If it’s a different user you’ll see it in the prompt. Listing: I'm the content of a file Copyright © SUSE 2023 6
7.
Mandatory access control Discretionary
access control (DAC) Usual form of access control in Linux – Typical example: root@workstation ~/ $ ls -l /etc/shadow -rw-r-----. 1 root shadow 1421 /etc/shadow – Discretionary: The owner of an object can control the access of the objects he owns Copyright © SUSE 2023 7
8.
Mandatory access control Discretionary
access control (DAC) Drawbacks: – Coarse: Basically 3 x rwx – Prone to (user) error johannes@workstation ~/ $ ls -lah ~/.ssh/id_rsa -rw-rw-rw-. 1 jsegitz users 1.7K ~/.ssh/id_rsa – Hard to analyze – root == God (- capabilities) But it’s familiar, easy to use and to understand Copyright © SUSE 2023 8
9.
Mandatory access control Mandatory
access control (MAC) Mandatory (in this context): – Access control decisions are not made by the owner – Access control rules are managed centrally Advantages: – Access control in the hand of people who know what they’re doing – Centralized control and review is easy – Often very fine grained → compartmentalization Drawbacks: – Harder to understand – Complex to administrate – Missing experience Copyright © SUSE 2023 9
10.
SELinux History Security Enhanced Linux –
Linux security module (LSM), developed by the National Security Agency (NSA) Don’t panic, it’s open source and reviewed thoroughly – First release 2000, since then integrated in the Linux kernel Didn’t play a big role at SUSE up to this point Will be the MAC system for ALP (and already is for SLE Micro) So very likely it’s also the future MAC system for openSUSE Copyright © SUSE 2023 10
11.
SELinux Basic idea – Type
Enforcement (TE). Every object has a – user: unconfined_u – role: unconfined_r – type: unconfined_t – sensitivity: s0-s0 – category: c0.c1023 – These form the Security Context (SC) unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 – In practice the type unconfined_t is all you need Copyright © SUSE 2023 11
12.
SELinux SELinux expert with
one character If you remember one thing: let it be this Copyright © SUSE 2023 12
13.
SELinux Basic idea (Almost) everything
has a SC. Sockets, packets, ... 134 security classes – Files root@workstation ~/ $ ls -lZ /etc/shadow ----------. root root system_u:object_r:shadow_t:s0 /etc/shadow – Processes root@workstation ~/ $ ps axZ | grep 'postfix/master' system_u:system_r:postfix_master_t:s0 1250 ? Ss 0:00 /usr/lib/ Copyright © SUSE 2023 13
14.
SELinux Basic idea – DAC
comes first – Then SELinux. Deny by default – Firewall for system calls Copyright © SUSE 2023 14
15.
SELinux SELinux log messages Found
in the audit.log type=AVC msg=audit(1416499522.810:77): avc: denied { transition } for pid=1282 comm="sshd" path="/usr/bin/zsh" dev="vda2" ino=40462 scontext=system_u:system_r:kernel_t:s0 tcontext=unconfined_u:unconfined_r:unconfined_t:s0 tclass=process Copyright © SUSE 2023 15
16.
Practice You’ll now change
an openSUSE installation to use SELinux. Please boot the machine Copyright © SUSE 2023 16
17.
Practice Initial setup Install packages: $
zypper in selinux-policy-targeted restorecond selinux-policy-devel policycoreutils setools-console policycoreutils-devel selinux-autorelabel podman Set SELinux to enforcing: $ sed -i -e 's/SELINUX=.*/SELINUX=enforcing/' /etc/selinux/config Main config file: /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=enforcing # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. # minimum - Modification of targeted policy. Only selected processes are protected. SELINUXTYPE=targeted Copyright © SUSE 2023 17
18.
Practice Initial setup Set the
necessary boot parameter: $ if ! egrep 'GRUB_CMDLINE_LINUX_DEFAULT.*security=selinux selinux=1' /etc/default/grub >/dev/null; then sed -i -E 's/(GRUB_CMDLINE_LINUX_DEFAULT=.*)"/1 security=selinux selinux=1"/' /etc/default/grub fi $ update-bootloader --refresh Remove audit log, reboot: $ rm /var/log/audit/audit.log $ reboot Copyright © SUSE 2023 18
19.
Practice Look around Current SELinux
status $ sestatus Have a look at the processes $ ps auxZ Check out the filesystem labels $ ls -laZ / $ ls -laZ /var Check for mislabeled files $ restorecon -Rvn /var $ restorecon -Rv /var Copyright © SUSE 2023 19
20.
Practice Look around Check your
identity $ id -Z Check denials: $ grep -i avc /var/log/audit/audit.log $ tail -f /var/log/audit/audit.log | grep -i avc Proper way to do this: $ ausearch -m avc,user_avc,selinux_err -ts boot -i Copyright © SUSE 2023 20
21.
Practice Linux users to
SELinux users: $ semanage login -l Port mappings: $ semanage port -l File label rules: $ semanage fcontext -l Copyright © SUSE 2023 21
22.
Practice Booleans: $ semanage boolean
-l Enable a boolean: $ semanage boolean -m --on httpd_enable_homedirs Copyright © SUSE 2023 22
23.
Practice audit2allow audit2allow: – Analyzes SELinux
denial messages – Generates rules to allow necessary access – Is aware of interfaces – Suggests booleans that would allow the access But don’t use it with every denial! Copyright © SUSE 2023 23
24.
Practice audit2allow Either pipe AVCs
into audit2allow or feed into STDIN and close it: $ audit2allow -R Build SELinux module you can load: $ audit2allow -R -M $NAMEMODULE Copyright © SUSE 2023 24
25.
Practice avcs.rb Small wrapper around
auserch. Makes reading AVCs easier $ podman run --privileged -v /var/log/audit:/var/log/audit registry.opensuse.org/home/jsegitz/containers/containers/avcs:latest Copyright © SUSE 2023 25
26.
Practice Lets cause problems Mislabel
some files: $ ls -laZ /usr/sbin/postfix $ chcon -t postfix_map_exec_t /usr/sbin/postfix Check it: $ restorecon -Rvn /usr/sbin/ Restart postfix: $ systemctl restart postfix Copyright © SUSE 2023 26
27.
Practice Lets cause problems Check
the status: $ systemctl status postfix Why does it fail? You’ll see something like postfix[3427]: fatal: chdir(/var/spool/postfix): Permission denied but no AVCs. How do we approach this? Copyright © SUSE 2023 27
28.
Practice How to debug
SELinux problems Does it happen in permissive mode? $ setenforce 0 Check for denials. If you don’t see any disable dontaudit rules with $ semodule -DB Enable dontaudit again with $ semodule -B Now give audit2allow a try with this ... Check for mislabled files – either because of unaware scripts/programs – policy paths don’t match Copyright © SUSE 2023 28
29.
Practice How to debug
SELinux problems Search engines/bugtrackers are your friends Howto report a bug: https://en.opensuse.org/openSUSE:Bugreport_SELinux Copyright © SUSE 2023 29
30.
Practice How to rescue
a system In grub change boot parameters: – Disable SELinux: selinux=0 – Make SELinux permissive: enforcing=0 Copyright © SUSE 2023 30
31.
Questions? Thank you for
your attention! Copyright © SUSE 2023 31