SlideShare a Scribd company logo
Enviar pesquisa
Carregar
Entrar
Cadastre-se
SELinux workshop
Denunciar
johseg
Seguir
27 de May de 2023
•
0 gostou
•
41 visualizações
1
de
31
SELinux workshop
27 de May de 2023
•
0 gostou
•
41 visualizações
Baixar agora
Baixar para ler offline
Denunciar
Tecnologia
SELinux workshop for openSUSE conference
johseg
Seguir
Recomendados
selinuxbasicusage.pptx
Pandiya Rajan
6 visualizações
•
88 slides
SELinux Basic Usage
Dmytro Minochkin
935 visualizações
•
88 slides
2009-08-11 IBM Teach the Teachers (IBM T3), Linux Security Overview
Shawn Wells
617 visualizações
•
83 slides
SELinux_@gnu_group_meetup
Jayant Chutke
367 visualizações
•
30 slides
Selinux
Ankit Raj
741 visualizações
•
14 slides
Unix Security
replay21
6.3K visualizações
•
47 slides
Mais conteúdo relacionado
Similar a SELinux workshop
SELinux for Everyday Users
PaulWay
12.9K visualizações
•
66 slides
Introduction To SELinux
Rene Cunningham
12.6K visualizações
•
45 slides
Understanding SELinux For the Win
bmbouter
775 visualizações
•
39 slides
4 effective methods to disable se linux temporarily or permanently
chinkshady
865 visualizações
•
7 slides
CloudStack templates with OpenVM
ShapeBlue
1.2K visualizações
•
10 slides
Hardening Linux, introducing Securix GNU/Linux
Martin Holovský
775 visualizações
•
33 slides
Similar a SELinux workshop
(20)
SELinux for Everyday Users
PaulWay
•
12.9K visualizações
Introduction To SELinux
Rene Cunningham
•
12.6K visualizações
Understanding SELinux For the Win
bmbouter
•
775 visualizações
4 effective methods to disable se linux temporarily or permanently
chinkshady
•
865 visualizações
CloudStack templates with OpenVM
ShapeBlue
•
1.2K visualizações
Hardening Linux, introducing Securix GNU/Linux
Martin Holovský
•
775 visualizações
Aquarium introduction-asia-summit-2021
Alex Lau
•
130 visualizações
Docker, Linux Containers, and Security: Does It Add Up?
Jérôme Petazzoni
•
9.3K visualizações
SUSE Expert Days Paris 2018 – SLE 15
SUSE
•
390 visualizações
LCJ2010-KaiGai-sepgsql
Kohei KaiGai
•
634 visualizações
Process behaviour modelling using lsm
iaemedu
•
395 visualizações
Module 17 (novell hacking)
Wail Hassan
•
180 visualizações
LXC, Docker, security: is it safe to run applications in Linux Containers?
Jérôme Petazzoni
•
22.7K visualizações
Rancher Rodeo 13 mai 2022
SUSE
•
242 visualizações
Red Hat Linux 5 Hardening Tips - National Security Agency
sanchetanparmar
•
937 visualizações
Security workflow with ansible
devanshdubey7
•
207 visualizações
Open stack meetup 2014 11-13 - 101 + high availability
Rick Ashford
•
763 visualizações
Se linux course1
OWASP (Open Web Application Security Project)
•
7K visualizações
2008 08-12 SELinux: A Key Component in Secure Infrastructures
Shawn Wells
•
191 visualizações
Hardening solaris
Femi Adeyemi
•
479 visualizações
Último
Webhook Testing Strategy
Dimpy Adhikary
82 visualizações
•
10 slides
Common WordPress APIs_ Settings API
Jonathan Bossenger
29 visualizações
•
10 slides
Accelerating Data Science through Feature Platform, Transformers and GenAI
FeatureByte
95 visualizações
•
44 slides
Meetup_adessoCamunda_2023-09-13_Part1&2_en.pdf
MariaAlcantara50
40 visualizações
•
31 slides
Chandrayaan 3.pptx
PrasunJha12
31 visualizações
•
41 slides
Google cloud Study Jam 2023.pptx
GDSCNiT
438 visualizações
•
56 slides
Último
(20)
Webhook Testing Strategy
Dimpy Adhikary
•
82 visualizações
Common WordPress APIs_ Settings API
Jonathan Bossenger
•
29 visualizações
Accelerating Data Science through Feature Platform, Transformers and GenAI
FeatureByte
•
95 visualizações
Meetup_adessoCamunda_2023-09-13_Part1&2_en.pdf
MariaAlcantara50
•
40 visualizações
Chandrayaan 3.pptx
PrasunJha12
•
31 visualizações
Google cloud Study Jam 2023.pptx
GDSCNiT
•
438 visualizações
9C Monthly Newsletter - SEPT 2023
PublishingTeam
•
234 visualizações
10 reasons to choose Galaxy Tab S9 for work on the go
Samsung Business USA
•
54 visualizações
Mastering Automation Quality: Exploring UiPath's Test Suite for Seamless Test...
DianaGray10
•
38 visualizações
Cloud Composer workshop at Airflow Summit 2023.pdf
Leah Cole
•
94 visualizações
h2 meet pdf test.pdf
JohnLee971654
•
64 visualizações
Framing Few Shot Knowledge Graph Completion with Large Language Models
MODUL Technology GmbH
•
44 visualizações
Product Research Presentation-Maidy Veloso.pptx
MaidyVeloso
•
22 visualizações
Salesforce Miami User Group Event - 3rd Quarter
SkyPlanner
•
23 visualizações
Solving today’s Traffic Problems with Sustainable Ride Hailing Solution
On Demand Clone
•
27 visualizações
"Building Asynchronous SOA for Modern Applications", Sai Pragna Etikyala
Fwdays
•
26 visualizações
GDSC Cloud Lead Presentation.pptx
AbhinavNautiyal8
•
72 visualizações
"From Orchestration to Choreography and Back", Yevhen Bobrov
Fwdays
•
48 visualizações
Navigating the Future
OnBoard
•
35 visualizações
CamundaCon NYC 2023 Keynote - Shifting into overdrive with process orchestration
Bernd Ruecker
•
40 visualizações
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