SlideShare a Scribd company logo
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 ...
Ad

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
A Developer's Guide to Kubernetes Security
PDF
Pentesting111111 Cheat Sheet_OSCP_2023.pdf
PDF
A Developer’s Guide to Kubernetes Security
PDF
theVIVI-AD-Security-Workshop_AfricaHackon2019.pdf
PDF
Engineering Challenges Doing Intrusion Detection in the Cloud
PPTX
DevOOPS: Attacks and Defenses for DevOps Toolchains
PDF
OSCP Preparation Guide @ Infosectrain
PDF
Postgres the hardway
PDF
PGCon 2014 - What Do You Mean my Database Server Core Dumped? - How to Inspec...
PDF
Securing Cassandra for Compliance
PDF
Hardening cassandra q2_2016
PDF
Intrusion Techniques
PPTX
Blue Teamin' on a Budget [of zero]
PDF
Kubernetes Summit 2019 - Harden Your Kubernetes Cluster
PDF
HARDENING IN APACHE WEB SERVER
PDF
One-Man Ops
PPTX
04 - I love my OS, he protects me (sometimes, in specific circumstances)
PPTX
Minio ♥ Go
ODP
Ceph Day Melbourne - Troubleshooting Ceph
SBA Security Meetup: I want to break free - The attacker inside a Container
A Developer's Guide to Kubernetes Security
Pentesting111111 Cheat Sheet_OSCP_2023.pdf
A Developer’s Guide to Kubernetes Security
theVIVI-AD-Security-Workshop_AfricaHackon2019.pdf
Engineering Challenges Doing Intrusion Detection in the Cloud
DevOOPS: Attacks and Defenses for DevOps Toolchains
OSCP Preparation Guide @ Infosectrain
Postgres the hardway
PGCon 2014 - What Do You Mean my Database Server Core Dumped? - How to Inspec...
Securing Cassandra for Compliance
Hardening cassandra q2_2016
Intrusion Techniques
Blue Teamin' on a Budget [of zero]
Kubernetes Summit 2019 - Harden Your Kubernetes Cluster
HARDENING IN APACHE WEB SERVER
One-Man Ops
04 - I love my OS, he protects me (sometimes, in specific circumstances)
Minio ♥ Go
Ceph Day Melbourne - Troubleshooting Ceph
Ad

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
Unlocking AI with Model Context Protocol (MCP)
PDF
Approach and Philosophy of On baking technology
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPT
Teaching material agriculture food technology
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Encapsulation theory and applications.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Electronic commerce courselecture one. Pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
Unlocking AI with Model Context Protocol (MCP)
Approach and Philosophy of On baking technology
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Teaching material agriculture food technology
Spectral efficient network and resource selection model in 5G networks
Encapsulation_ Review paper, used for researhc scholars
MYSQL Presentation for SQL database connectivity
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Understanding_Digital_Forensics_Presentation.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Review of recent advances in non-invasive hemoglobin estimation
Encapsulation theory and applications.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Electronic commerce courselecture one. Pdf
20250228 LYD VKU AI Blended-Learning.pptx
Chapter 3 Spatial Domain Image Processing.pdf

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: anfragen@sba-research.org Reinhard Kugler rkugler@sba-research.org
  • 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 rkugler@sba-research.org SBA Research gGmbH, 2020