Classification: Confidential 2
Willkommen
zur SBA Live Academy
#bleibdaheim #remotelearning
After the Exploit – Linux Self-defense
by Reinhard Kugler
This talk will be recorded as soon as the presentation starts!
Please be sure to turn off your video in your control panel.
Classification: Confidential 4SBA Research gGmbH, 2020 https://www.martialtribes.com/defend-against-multiple-attackers/
CVE-2018-1260
CVE-2014-6271
CVE-2018-11776CVE-2019-11043
CVE-2020-?
Classification: Confidential 5
Remote Code Exection Attacks
SBA Research gGmbH, 2020
apache
/bin/sh
php
Classification: Confidential 7SBA Research gGmbH, 2020
SelfdefenseTip0:
Don‘t breakyourownstuff.
Classification: ConfidentialSBA Research gGmbH, 2020
SelfdefenseTip1:
Reducetheattacksurface
Classification: Confidential 9
Example: Apache HTTP Server
SBA Research gGmbH, 2020
apache (root)
Underlying operating system
apache (www-data)
tcp/80
tcp/443
Things we do not like
✓ Don‘t run as root
✓ Don‘t permit access to
files of the operating
system
✓ Don‘t run arbitrary
programs
Classification: Confidential 10
Capabilities
• CAP_CHOWN
• CAP_DAC_OVERRIDE
• CAP_NET_ADMIN
• CAP_NET_BIND_SERVICE
• CAP_NET_RAW
• CAP_SYS_ADMIN
• CAP_SYS_BOOT
• CAP_SYS_CHROOT
• …
expressed as bitmask in
/proc/$$/status
SBA Research gGmbH, 2018
https://www.andreasch.com/2018/01/13/capabilities/
[Service]
...
AmbientCapabilities=CAP_NET_BIND_SERVICE
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
...
http://man7.org/linux/man-pages/man5/systemd.exec.5.html
# setcap cap_net_bind_service+ep
/usr/sbin/apache
Systemd configuration
Extended attribute
Classification: Confidential 11
Example: Apache HTTP Server
SBA Research gGmbH, 2020
Underlying operating system
tcp/80
tcp/443
Rogue process
apache (www-data)
apache (www-data)
Things we do not like
✓ Don‘t run as root
✓ Don‘t permit access to
files of the operating
system
✓ Don‘t run arbitrary
programs
Classification: ConfidentialSBA Research gGmbH, 2020
SelfdefenseTip2:
ContaintheAttack
https://commons.wikimedia.org/wiki/File:Strikeforce_cage_2011-01-07.jpg
Classification: Confidential 13
Example: Apache HTTP Server
SBA Research gGmbH, 2020
Underlying operating system
Rogue process
container
(limited) container filesystem
tcp/80
tcp/443
apache (www-data)
apache (www-data)
Classification: Confidential 15SBA Research gGmbH, 2020
Classification: ConfidentialSBA Research gGmbH, 2020
SelfdefenseTip3:
EnsureMandatoryAccess
https://en.wikipedia.org/wiki/File:Goshin_jujitsu_head_arm_lock_med.JPG
Classification: Confidential 18
Mandatory Access Control
SBA Research gGmbH, 2020
AppArmor SELinux
process /etc/passwd
/bin/sh
1.1.1.1:80
Classification: Confidential 19
Quick Fix with AppArmor
• /etc/apparmor.d/usr.sbin.apache2
SBA Research gGmbH, 2018
/usr/sbin/apache2 {
...
deny /bin/dash x,
...
}
read (r), write (w),
append (a)
link (l)
lock (k)
mmap (m)
execute (ix)
child profile (Cx)
profile (Px)
unconfined (Ux)
/** recursive
# apparmor_parser -r -W /etc/apparmor.d/usr.sbin.apache2
# aa-complain apache2
# docker run --rm -it --security-opt "apparmor=apache2" -p 8000:80 apache2
# aa-enforce apache2
Classification: Confidential 22
Remote Code Exection Attacks
SBA Research gGmbH, 2020
tcp/80
tcp/443
apache (www-data)
Classification: Confidential 23
Syscall Interface
SBA Research gGmbH, 2020
Kernel
syscall
apache2
files
memory
process
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0
openat(AT_FDCWD, "/etc/passwd", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2431, ...}) = 0
fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL) = 0
mmap(NULL, 139264, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f60e0a40000
read(3, "root:x:0:0:root:/root:/bin/bashn"..., 131072) = 2431
write(1, "root:x:0:0:root:/root:/bin/bashn"..., 2431) = 2431
read(3, "", 131072) = 0
close(3) = 0
# /bin/cat /etc/passwd
Classification: ConfidentialSBA Research gGmbH, 2020
SelfdefenseTip4:
ReducetheKernelSurface
Classification: Confidential 25SBA Research gGmbH, 2020
http://man7.org/linux/man-pages/man2/syscalls.2.html
Classification: Confidential 26
Seccomp BPF (filter syscalls)
• Create a BPF script via macros
• Load it via a syscall into the Kernel
SBA Research gGmbH, 2020
/* Allow system calls other than open() and openat() */
struct sock_filter filter[] = {
...
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_open, 2, 0),
BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_openat, 1, 0),
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW),
BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS)
}
struct sock_fprog prog = { .filter=filter, .len=... };
syscall(__NR_seccomp, SECCOMP_SET_MODE_FILTER, 0, &prog);
Classification: Confidential 29
Example: BPF to kill proceses using syscalls
SBA Research gGmbH, 2020
[Service]
...
SystemCallFilter =~ bind
SystemCallFilter =~ chroot
...
# docker run -it --security-opt
seccomp=profile.json ...
{
"defaultAction":"SCMP_ACT_ALLOW",
"syscalls":[
{
"names":[
"bind",
"connect",
"mkdir"
],
"action":"SCMP_ACT_KILL",
Systemd configurationDocker
Classification: ConfidentialSBA Research gGmbH, 2020
“Ifyoutakeabus,youshouldknow whentogetoff!“
― MasterIainArmstrong
Classification: Confidential 32
Final Remarks
SBA Research gGmbH, 2020
0)Don‘tbreakyourownstuff
1)Reduce theattacksurface
2)Contain theAttack
3)Ensure Mandatory Access
4) Reducethe Kernel Surface
https://github.com/netblue30/firejail
https://github.com/flatpak/flatpak
https://github.com/containers/bubblewrap
https://source.android.com/security/app-sandbox
Classification: Confidential 33
Professional Services
Penetration Testing
Architecture Reviews
Security Audit
Security Trainings
Incident Response Readiness
ISMS & ISO 27001 Consulting
Forschung & Beratung unter einem Dach
Applied Research
Industrial Security | IIoT Security |
Mathematics for Security Research |
Machine Learning | Blockchain | Network
Security | Sustainable Software Systems |
Usable Security
SBA Research
Knowhow Transfer
SBA Live Academy | sec4dev | Trainings |
Events | Teaching | sbaPRIME
Kontaktieren Sie uns: anfragen@sba-research.org
Reinhard Kugler
rkugler@sba-research.org
Classification: Confidential 34
#bleibdaheim #remotelearning
Coming up @ SBA Live Academy
13.05.2020, 13.00 Uhr, live:
„Die COVID-19 Krise und
Simulationsmodelle. Was kann
man sagen? Und was nicht? “
by „Niki Popper (CSO und
Mitgründer der dwh GmbH)“
Treten Sie unserer MeetUp Gruppe bei!
https://www.meetup.com/Security-Meetup-by-SBA-
Research/
Classification: Confidential 35
Reinhard Kugler
SBA Research gGmbH
Floragasse 7, 1040 Wien
rkugler@sba-research.org
SBA Research gGmbH, 2020

More Related Content

PDF
SBA Live Academy - Angriffe auf Windows Domains und Delegation by Reinhard Ku...
PDF
SBA Live Academy - Secure Containers for Developer by Mathias Tausig
PDF
SBA Live Academy - CRLite – Revocation for X.509 certificates in the browser ...
PDF
SBA Security Meetup - Deploying and managing azure sentinel as code by Bojan ...
PDF
CONFidence 2018: Defense-in-depth techniques for modern web applications and ...
PPTX
Breaking the cyber kill chain!
PDF
Case Studies and Lessons Learned from SSL/TLS Certificate Verification Vulner...
PPTX
Detection Rules Coverage
SBA Live Academy - Angriffe auf Windows Domains und Delegation by Reinhard Ku...
SBA Live Academy - Secure Containers for Developer by Mathias Tausig
SBA Live Academy - CRLite – Revocation for X.509 certificates in the browser ...
SBA Security Meetup - Deploying and managing azure sentinel as code by Bojan ...
CONFidence 2018: Defense-in-depth techniques for modern web applications and ...
Breaking the cyber kill chain!
Case Studies and Lessons Learned from SSL/TLS Certificate Verification Vulner...
Detection Rules Coverage

What's hot (20)

PPTX
BlueHat v17 || “_____ Is Not a Security Boundary." Things I Have Learned and...
PDF
Preventing XSS with Content Security Policy
PDF
CrowdStrike CrowdCast: Is Ransomware Morphing Beyond The Ability Of Standard ...
PDF
"Giving the bad guys no sleep"
PDF
[OPD 2019] Top 10 Security Facts of 2020
PDF
MITRE ATT&CKcon 2018: From Technique to Detection, Paul Ewing and Ross Wolf, ...
PPTX
Standardizing and Strengthening Security to Lower Costs
PPTX
【HITCON Hackathon 2017】 TrendMicro Datasets
PDF
Offensive malware usage and defense
PDF
Cryptography In The Browser Using JavaScript
PDF
MITRE ATT&CKcon 2018: Building an Atomic Testing Program, Brian Beyer, Red Ca...
PPTX
BlueHat v17 || You Are Making Application Whitelisting Difficult
PDF
Secure Coding for Java - An Introduction
PDF
Adaptive Defense - Understanding Cyber Attacks
PDF
Testing Android Security Codemotion Amsterdam edition
PPTX
Database Firewall from Scratch
PDF
Хакеро-машинный интерфейс
ODP
Introduction to OWASP & Web Application Security
PDF
Introduction to Mod security session April 2016
PPTX
BlueHat v17 || Wannacrypt + Smbv1.0 Vulnerability = One of the Most Damaging ...
BlueHat v17 || “_____ Is Not a Security Boundary." Things I Have Learned and...
Preventing XSS with Content Security Policy
CrowdStrike CrowdCast: Is Ransomware Morphing Beyond The Ability Of Standard ...
"Giving the bad guys no sleep"
[OPD 2019] Top 10 Security Facts of 2020
MITRE ATT&CKcon 2018: From Technique to Detection, Paul Ewing and Ross Wolf, ...
Standardizing and Strengthening Security to Lower Costs
【HITCON Hackathon 2017】 TrendMicro Datasets
Offensive malware usage and defense
Cryptography In The Browser Using JavaScript
MITRE ATT&CKcon 2018: Building an Atomic Testing Program, Brian Beyer, Red Ca...
BlueHat v17 || You Are Making Application Whitelisting Difficult
Secure Coding for Java - An Introduction
Adaptive Defense - Understanding Cyber Attacks
Testing Android Security Codemotion Amsterdam edition
Database Firewall from Scratch
Хакеро-машинный интерфейс
Introduction to OWASP & Web Application Security
Introduction to Mod security session April 2016
BlueHat v17 || Wannacrypt + Smbv1.0 Vulnerability = One of the Most Damaging ...

Similar to SBA Live Academy - After the overflow: self-defense techniques (Linux Kernel) by Reinhard Kugler (20)

PDF
SBA Security Meetup: I want to break free - The attacker inside a Container
PDF
Linux Security Crash Course
PDF
CentOS Linux Server Hardening
PDF
Alexander Reelsen - Seccomp for Developers
ODP
Linux Capabilities - eng - v2.1.5, compact
PDF
Linux Hardening - nullhyd
PDF
CS 626 - March : Capsicum: Practical Capabilities for UNIX
PPTX
Linux 开源操作系统发展新趋势
PDF
Linux security quick reference guide
PDF
Linux internet server security and configuration tutorial
PDF
Hardening Linux and introducing Securix Linux
PPTX
Server hardening
PDF
CONFidence 2017: Escaping the (sand)box: The promises and pitfalls of modern ...
PDF
Hardening Linux, introducing Securix GNU/Linux
PPT
bh-us-02-murphey-freebsd
PPTX
Creating "Secure" PHP applications, Part 2, Server Hardening
PDF
BSides Algiers - Linux Kernel and Recent Security Protections - Djallal Harouni
TXT
Linuxserver harden
PPTX
Your Inner Sysadmin - MidwestPHP 2015
PPT
Unix Security
SBA Security Meetup: I want to break free - The attacker inside a Container
Linux Security Crash Course
CentOS Linux Server Hardening
Alexander Reelsen - Seccomp for Developers
Linux Capabilities - eng - v2.1.5, compact
Linux Hardening - nullhyd
CS 626 - March : Capsicum: Practical Capabilities for UNIX
Linux 开源操作系统发展新趋势
Linux security quick reference guide
Linux internet server security and configuration tutorial
Hardening Linux and introducing Securix Linux
Server hardening
CONFidence 2017: Escaping the (sand)box: The promises and pitfalls of modern ...
Hardening Linux, introducing Securix GNU/Linux
bh-us-02-murphey-freebsd
Creating "Secure" PHP applications, Part 2, Server Hardening
BSides Algiers - Linux Kernel and Recent Security Protections - Djallal Harouni
Linuxserver harden
Your Inner Sysadmin - MidwestPHP 2015
Unix Security

More from SBA Research (20)

PDF
CyberResilienceAct_sec4devDialogues2025pdf
PDF
SBATop10 Vulnerabilities_sec4devDialogues2025
PDF
Passkeys & 2FA/MFA_sec4dev_Dialogues2025
PDF
Gefahren von Prompt-Injection Angriffen_sec4devDialogues.pdf
PDF
NDSS 2021 RandRunner: Distributed Randomness from Trapdoor VDFs with Strong U...
PDF
SBA Security Meetup – Security Requirements Management 101 by Daniel Schwarz ...
PDF
SBA Security Meetup: Building a Secure Architecture – A Deep-Dive into Securi...
PDF
"Rund um die ISO27001 Zertifizierung – Nähkästchentalk" by Thomas Kopeinig
PPTX
Secure development on Kubernetes by Andreas Falk
PDF
SBA Live Academy - "BIG BANG!" Highlights & key takeaways of 24 security talks
PDF
SBA Live Academy, Rechtliche Risiken mit externen Mitarbeitern
PDF
SBA Live Academy, What the heck is secure computing
PDF
Tools & techniques, building a dev secops culture at mozilla sba live a...
PDF
HydRand: Efficient Continuous Distributed Randomness. IEEE S&P 2020 by Philip...
PDF
SBA Live Academy - Passwords: Policy and Storage with NIST SP800-63b by Jim M...
PDF
SBA Live Academy - Threat Modeling 101 – eine kurze aber praxisnahe Einführun...
PDF
SBA Live Academy - Angriffe gegen das Stromnetz – Wenn der Strom nicht mehr a...
PDF
SBA Live Academy - Physical Attacks against (I)IoT-Devices, Embedded Devices,...
PDF
SBA Live Academy: Cyber Resilience - Failure is not an option by Simon Tjoa
PDF
SBA Live Academy: Datenschutz Teil 1: Wozu Datenschutzgesetze? by Gerald Sendera
CyberResilienceAct_sec4devDialogues2025pdf
SBATop10 Vulnerabilities_sec4devDialogues2025
Passkeys & 2FA/MFA_sec4dev_Dialogues2025
Gefahren von Prompt-Injection Angriffen_sec4devDialogues.pdf
NDSS 2021 RandRunner: Distributed Randomness from Trapdoor VDFs with Strong U...
SBA Security Meetup – Security Requirements Management 101 by Daniel Schwarz ...
SBA Security Meetup: Building a Secure Architecture – A Deep-Dive into Securi...
"Rund um die ISO27001 Zertifizierung – Nähkästchentalk" by Thomas Kopeinig
Secure development on Kubernetes by Andreas Falk
SBA Live Academy - "BIG BANG!" Highlights & key takeaways of 24 security talks
SBA Live Academy, Rechtliche Risiken mit externen Mitarbeitern
SBA Live Academy, What the heck is secure computing
Tools & techniques, building a dev secops culture at mozilla sba live a...
HydRand: Efficient Continuous Distributed Randomness. IEEE S&P 2020 by Philip...
SBA Live Academy - Passwords: Policy and Storage with NIST SP800-63b by Jim M...
SBA Live Academy - Threat Modeling 101 – eine kurze aber praxisnahe Einführun...
SBA Live Academy - Angriffe gegen das Stromnetz – Wenn der Strom nicht mehr a...
SBA Live Academy - Physical Attacks against (I)IoT-Devices, Embedded Devices,...
SBA Live Academy: Cyber Resilience - Failure is not an option by Simon Tjoa
SBA Live Academy: Datenschutz Teil 1: Wozu Datenschutzgesetze? by Gerald Sendera

Recently uploaded (20)

PDF
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
PDF
Co-training pseudo-labeling for text classification with support vector machi...
PPTX
How to use fields_get method in Odoo 18
PDF
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
PPTX
Blending method and technology for hydrogen.pptx
PDF
NewMind AI Weekly Chronicles – August ’25 Week IV
PDF
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
PDF
substrate PowerPoint Presentation basic one
PPTX
How to Convert Tickets Into Sales Opportunity in Odoo 18
PDF
Build Real-Time ML Apps with Python, Feast & NoSQL
PDF
Streamline Vulnerability Management From Minimal Images to SBOMs
PDF
EIS-Webinar-Regulated-Industries-2025-08.pdf
PDF
Connector Corner: Transform Unstructured Documents with Agentic Automation
PDF
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
PDF
Advancing precision in air quality forecasting through machine learning integ...
PDF
Data Virtualization in Action: Scaling APIs and Apps with FME
PPTX
Report in SIP_Distance_Learning_Technology_Impact.pptx
PDF
The AI Revolution in Customer Service - 2025
PDF
CCUS-as-the-Missing-Link-to-Net-Zero_AksCurious.pdf
PDF
NewMind AI Journal Monthly Chronicles - August 2025
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
Co-training pseudo-labeling for text classification with support vector machi...
How to use fields_get method in Odoo 18
5-Ways-AI-is-Revolutionizing-Telecom-Quality-Engineering.pdf
Blending method and technology for hydrogen.pptx
NewMind AI Weekly Chronicles – August ’25 Week IV
CXOs-Are-you-still-doing-manual-DevOps-in-the-age-of-AI.pdf
substrate PowerPoint Presentation basic one
How to Convert Tickets Into Sales Opportunity in Odoo 18
Build Real-Time ML Apps with Python, Feast & NoSQL
Streamline Vulnerability Management From Minimal Images to SBOMs
EIS-Webinar-Regulated-Industries-2025-08.pdf
Connector Corner: Transform Unstructured Documents with Agentic Automation
The-2025-Engineering-Revolution-AI-Quality-and-DevOps-Convergence.pdf
Advancing precision in air quality forecasting through machine learning integ...
Data Virtualization in Action: Scaling APIs and Apps with FME
Report in SIP_Distance_Learning_Technology_Impact.pptx
The AI Revolution in Customer Service - 2025
CCUS-as-the-Missing-Link-to-Net-Zero_AksCurious.pdf
NewMind AI Journal Monthly Chronicles - August 2025

SBA Live Academy - After the overflow: self-defense techniques (Linux Kernel) by Reinhard Kugler

  • 1. Classification: Confidential 2 Willkommen zur SBA Live Academy #bleibdaheim #remotelearning After the Exploit – Linux Self-defense by Reinhard Kugler This talk will be recorded as soon as the presentation starts! Please be sure to turn off your video in your control panel.
  • 2. Classification: Confidential 4SBA Research gGmbH, 2020 https://www.martialtribes.com/defend-against-multiple-attackers/ CVE-2018-1260 CVE-2014-6271 CVE-2018-11776CVE-2019-11043 CVE-2020-?
  • 3. Classification: Confidential 5 Remote Code Exection Attacks SBA Research gGmbH, 2020 apache /bin/sh php
  • 4. Classification: Confidential 7SBA Research gGmbH, 2020 SelfdefenseTip0: Don‘t breakyourownstuff.
  • 5. Classification: ConfidentialSBA Research gGmbH, 2020 SelfdefenseTip1: Reducetheattacksurface
  • 6. Classification: Confidential 9 Example: Apache HTTP Server SBA Research gGmbH, 2020 apache (root) Underlying operating system apache (www-data) tcp/80 tcp/443 Things we do not like ✓ Don‘t run as root ✓ Don‘t permit access to files of the operating system ✓ Don‘t run arbitrary programs
  • 7. Classification: Confidential 10 Capabilities • CAP_CHOWN • CAP_DAC_OVERRIDE • CAP_NET_ADMIN • CAP_NET_BIND_SERVICE • CAP_NET_RAW • CAP_SYS_ADMIN • CAP_SYS_BOOT • CAP_SYS_CHROOT • … expressed as bitmask in /proc/$$/status SBA Research gGmbH, 2018 https://www.andreasch.com/2018/01/13/capabilities/ [Service] ... AmbientCapabilities=CAP_NET_BIND_SERVICE CapabilityBoundingSet=CAP_NET_BIND_SERVICE ... http://man7.org/linux/man-pages/man5/systemd.exec.5.html # setcap cap_net_bind_service+ep /usr/sbin/apache Systemd configuration Extended attribute
  • 8. Classification: Confidential 11 Example: Apache HTTP Server SBA Research gGmbH, 2020 Underlying operating system tcp/80 tcp/443 Rogue process apache (www-data) apache (www-data) Things we do not like ✓ Don‘t run as root ✓ Don‘t permit access to files of the operating system ✓ Don‘t run arbitrary programs
  • 9. Classification: ConfidentialSBA Research gGmbH, 2020 SelfdefenseTip2: ContaintheAttack https://commons.wikimedia.org/wiki/File:Strikeforce_cage_2011-01-07.jpg
  • 10. Classification: Confidential 13 Example: Apache HTTP Server SBA Research gGmbH, 2020 Underlying operating system Rogue process container (limited) container filesystem tcp/80 tcp/443 apache (www-data) apache (www-data)
  • 11. Classification: Confidential 15SBA Research gGmbH, 2020
  • 12. Classification: ConfidentialSBA Research gGmbH, 2020 SelfdefenseTip3: EnsureMandatoryAccess https://en.wikipedia.org/wiki/File:Goshin_jujitsu_head_arm_lock_med.JPG
  • 13. Classification: Confidential 18 Mandatory Access Control SBA Research gGmbH, 2020 AppArmor SELinux process /etc/passwd /bin/sh 1.1.1.1:80
  • 14. Classification: Confidential 19 Quick Fix with AppArmor • /etc/apparmor.d/usr.sbin.apache2 SBA Research gGmbH, 2018 /usr/sbin/apache2 { ... deny /bin/dash x, ... } read (r), write (w), append (a) link (l) lock (k) mmap (m) execute (ix) child profile (Cx) profile (Px) unconfined (Ux) /** recursive # apparmor_parser -r -W /etc/apparmor.d/usr.sbin.apache2 # aa-complain apache2 # docker run --rm -it --security-opt "apparmor=apache2" -p 8000:80 apache2 # aa-enforce apache2
  • 15. Classification: Confidential 22 Remote Code Exection Attacks SBA Research gGmbH, 2020 tcp/80 tcp/443 apache (www-data)
  • 16. Classification: Confidential 23 Syscall Interface SBA Research gGmbH, 2020 Kernel syscall apache2 files memory process fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0), ...}) = 0 openat(AT_FDCWD, "/etc/passwd", O_RDONLY) = 3 fstat(3, {st_mode=S_IFREG|0644, st_size=2431, ...}) = 0 fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL) = 0 mmap(NULL, 139264, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f60e0a40000 read(3, "root:x:0:0:root:/root:/bin/bashn"..., 131072) = 2431 write(1, "root:x:0:0:root:/root:/bin/bashn"..., 2431) = 2431 read(3, "", 131072) = 0 close(3) = 0 # /bin/cat /etc/passwd
  • 17. Classification: ConfidentialSBA Research gGmbH, 2020 SelfdefenseTip4: ReducetheKernelSurface
  • 18. Classification: Confidential 25SBA Research gGmbH, 2020 http://man7.org/linux/man-pages/man2/syscalls.2.html
  • 19. Classification: Confidential 26 Seccomp BPF (filter syscalls) • Create a BPF script via macros • Load it via a syscall into the Kernel SBA Research gGmbH, 2020 /* Allow system calls other than open() and openat() */ struct sock_filter filter[] = { ... BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_open, 2, 0), BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_openat, 1, 0), BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_ALLOW), BPF_STMT(BPF_RET | BPF_K, SECCOMP_RET_KILL_PROCESS) } struct sock_fprog prog = { .filter=filter, .len=... }; syscall(__NR_seccomp, SECCOMP_SET_MODE_FILTER, 0, &prog);
  • 20. Classification: Confidential 29 Example: BPF to kill proceses using syscalls SBA Research gGmbH, 2020 [Service] ... SystemCallFilter =~ bind SystemCallFilter =~ chroot ... # docker run -it --security-opt seccomp=profile.json ... { "defaultAction":"SCMP_ACT_ALLOW", "syscalls":[ { "names":[ "bind", "connect", "mkdir" ], "action":"SCMP_ACT_KILL", Systemd configurationDocker
  • 21. Classification: ConfidentialSBA Research gGmbH, 2020 “Ifyoutakeabus,youshouldknow whentogetoff!“ ― MasterIainArmstrong
  • 22. Classification: Confidential 32 Final Remarks SBA Research gGmbH, 2020 0)Don‘tbreakyourownstuff 1)Reduce theattacksurface 2)Contain theAttack 3)Ensure Mandatory Access 4) Reducethe Kernel Surface https://github.com/netblue30/firejail https://github.com/flatpak/flatpak https://github.com/containers/bubblewrap https://source.android.com/security/app-sandbox
  • 23. Classification: Confidential 33 Professional Services Penetration Testing Architecture Reviews Security Audit Security Trainings Incident Response Readiness ISMS & ISO 27001 Consulting Forschung & Beratung unter einem Dach Applied Research Industrial Security | IIoT Security | Mathematics for Security Research | Machine Learning | Blockchain | Network Security | Sustainable Software Systems | Usable Security SBA Research Knowhow Transfer SBA Live Academy | sec4dev | Trainings | Events | Teaching | sbaPRIME Kontaktieren Sie uns: [email protected] Reinhard Kugler [email protected]
  • 24. Classification: Confidential 34 #bleibdaheim #remotelearning Coming up @ SBA Live Academy 13.05.2020, 13.00 Uhr, live: „Die COVID-19 Krise und Simulationsmodelle. Was kann man sagen? Und was nicht? “ by „Niki Popper (CSO und Mitgründer der dwh GmbH)“ Treten Sie unserer MeetUp Gruppe bei! https://www.meetup.com/Security-Meetup-by-SBA- Research/
  • 25. Classification: Confidential 35 Reinhard Kugler SBA Research gGmbH Floragasse 7, 1040 Wien [email protected] SBA Research gGmbH, 2020