SlideShare a Scribd company logo
What have
syscalls done
for you lately?
Liz Rice
@lizrice
Aqua Security
Agenda
● What are syscalls?
● Syscalls, seccomp & containers
● Shellshock exploit
What is a syscall?
What Have Syscalls Done for you Lately?
When do you need syscalls?
● Files
● Devices
● Processes
● Communications
● Time & date
And creating
containers
Let’s see some syscalls
strace
Using strace
How do you make a syscall?
Language-specific library
● C - libc
● Golang - syscall package
func Write(fd int, p []byte) (n int, err error)
What Have Syscalls Done for you Lately?
~ 330 of them
Syscall codes
syscall() saves CPU registers before making the system call,
restores the registers upon return from the system call, and
stores any error code returned by the system call in errno(3) if
an error occurs.
Making a syscall
Syscall parameters
x86 64 table from blog.rchapman.org
ENTRY (syscall)
movq %rdi, %rax /* Syscall number -> rax. */
movq %rsi, %rdi /* shift arg1 - arg5. */
movq %rdx, %rsi
movq %rcx, %rdx
movq %r8, %r10
movq %r9, %r8
movq 8(%rsp),%r9 /* arg6 is on the stack. */
Syscall /* Do the system call. */
cmpq $-4095, %rax /* Check %rax for error. */
jae SYSCALL_ERROR_LABEL /* Jump to error handler if error. */
Ret /* Return to caller. */
PSEUDO_END (syscall)
Syscall in assembler
GNU C library
Transition to kernel
● Execute in privileged mode
● Look up kernel code to run
○ syscall code from %rax
Portability
Different CPUs,
same approach
vDSO
● Avoid expensive kernel transitions
● Architecture-specific
● Typical: get time, CPU
strace(1) and the vDSO
When tracing systems calls with strace(1), symbols (system calls)
that are exported by the vDSO will not appear in the trace output.
Syscalls and seccomp
Seccomp
{
"defaultAction": "SCMP_ACT_ERRNO",
"architectures": [
"SCMP_ARCH_X86_64",
"SCMP_ARCH_X86",
"SCMP_ARCH_X32"
],
"syscalls": [
{
"name": "accept",
"action": "SCMP_ACT_ALLOW",
"args": []
},
{
"name": "accept4",
"action": "SCMP_ACT_ALLOW",
"args": []
Restrict the
syscalls a
process can
use
Seccomp
...
{
"names": [
"reboot"
],
"action": "SCMP_ACT_ALLOW",
"args": [],
"comment": "",
"includes": {
"caps": [
"CAP_SYS_BOOT"
]
},
"excludes": {}
},
...
Can I reboot
the host?
Stracing Docker
containers
Share PID namespace
docker run -it
--pid=container:<target> 
--cap-add sys_ptrace
<image_w_strace> /bin/bash
So you’ve got your syscalls
● Creating a seccomp profile
● Portability?
○ Kernel / architecture
AppArmor
(Not specifically to do with syscalls)
AppArmor profiles
Define what a program can do
● File access (read, write, execute…)
● Capabilities
● Network access
● ...
Generating AppArmor profiles
● aa-autodep - blank profile
● aa-complain - Generate logs
● aa-logprof - Review logs
● Manual edits?
● Zzzzzzzzz
#include <tunables/global>
/usr/sbin/nginx {
#include <abstractions/apache2-common>
#include <abstractions/base>
#include <abstractions/nis>
capability dac_override,
capability dac_read_search,
capability net_bind_service,
capability setgid,
capability setuid,
/data/www/safe/* r,
deny /data/www/unsafe/* r,
/etc/group r,
/etc/nginx/conf.d/ r,
/etc/nginx/mime.types r,
/etc/nginx/nginx.conf r,
/etc/nsswitch.conf r,
/etc/passwd r,
/etc/ssl/openssl.cnf r,
/run/nginx.pid rw,
/usr/sbin/nginx mr,
/var/log/nginx/access.log w,
/var/log/nginx/error.log w,
}
Typical profile
Container AppArmor profiles
● Generate profile on host
● Or install apparmor inside container
○ Requires --security-opt
apparmor:unconfined
--cap-add sys_admin
Runtime profiles are HARD
But...
● Can stop unexpected behaviour
● Microservice behaviour is easier
to reason about
Powerful with good tooling
Shellshock example
Runtime
profile tools
Recap & more info
● How syscalls work
○ Tycho’s kernel talk
● Runtime profiles
○ Powerful in theory, hard in practice
● More on strace
○ Julia Evans strace-zine
○ github.com/lizrice/strace-from-scratch
Thank you
Come say hi at Booth G10
@lizrice | @aquasecteam

More Related Content

PDF
Small, Simple, and Secure: Alpine Linux under the Microscope
PDF
Containers: What are they, Really?
PDF
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
PDF
CoreOS: Control Your Fleet
PDF
CoreOS intro
ODP
Testing Wi-Fi with OSS Tools
PDF
How and Why Prometheus' New Storage Engine Pushes the Limits of Time Series D...
PDF
Docker n co
Small, Simple, and Secure: Alpine Linux under the Microscope
Containers: What are they, Really?
2017-03-11 02 Денис Нелюбин. Docker & Ansible - лучшие друзья DevOps
CoreOS: Control Your Fleet
CoreOS intro
Testing Wi-Fi with OSS Tools
How and Why Prometheus' New Storage Engine Pushes the Limits of Time Series D...
Docker n co

What's hot (20)

PDF
Using linuxKit to build custom rancherOS systems
PDF
Declare your infrastructure: InfraKit, LinuxKit and Moby
PDF
CoreOS + Kubernetes @ All Things Open 2015
PPTX
CoreOS Intro
PDF
CoreOS introduction - Johann Romefort
PDF
Wordpress y Docker, de desarrollo a produccion
PDF
Docker / Ansible
ODP
LinuxKit Swarm Nodes
PDF
Docker 1.11 @ Docker SF Meetup
PPTX
Container Torture: Run any binary, in any container
PDF
Docker Runtime Security
PPTX
OpenShift4 Installation by UPI on kvm
PDF
Quay 3.3 installation
PDF
Docker Swarm 0.2.0
DOCX
Ansible ex407 and EX 294
PDF
CoreOS @Codetalks Hamburg
ODP
Continuous Security
PPTX
Container & kubernetes
PPTX
CoreOS in a Nutshell
PDF
Ansible docker
Using linuxKit to build custom rancherOS systems
Declare your infrastructure: InfraKit, LinuxKit and Moby
CoreOS + Kubernetes @ All Things Open 2015
CoreOS Intro
CoreOS introduction - Johann Romefort
Wordpress y Docker, de desarrollo a produccion
Docker / Ansible
LinuxKit Swarm Nodes
Docker 1.11 @ Docker SF Meetup
Container Torture: Run any binary, in any container
Docker Runtime Security
OpenShift4 Installation by UPI on kvm
Quay 3.3 installation
Docker Swarm 0.2.0
Ansible ex407 and EX 294
CoreOS @Codetalks Hamburg
Continuous Security
Container & kubernetes
CoreOS in a Nutshell
Ansible docker
Ad

Similar to What Have Syscalls Done for you Lately? (20)

PDF
A Brief History of System Calls
PDF
7 strace examples to debug the execution of a program in linux
PDF
CNIT 127: Ch 3: Shellcode
PDF
CNIT 127 Ch 3: Shellcode
PPTX
Debug generic process
PDF
CNIT 127 Ch 3: Shellcode
PDF
CNIT 127: 3: Shellcode
ODP
Linux kernel tracing superpowers in the cloud
PDF
CONFidence 2017: Escaping the (sand)box: The promises and pitfalls of modern ...
PDF
Rootkit on Linux X86 v2.6
PDF
Solaris Kernel Debugging V1.0
PPTX
A brief history of system calls
PDF
Solaris DTrace, An Introduction
PDF
CNIT 127 Ch 3: Shellcode
PDF
zine.pdf
PDF
dtrace_topics_intro.pdf
PDF
System Calls
PDF
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
PDF
DTrace Topics: Introduction
PPTX
OS SERVICES.pptxJGHHHHHHHHHHHHHHHHGGGGGGGG
A Brief History of System Calls
7 strace examples to debug the execution of a program in linux
CNIT 127: Ch 3: Shellcode
CNIT 127 Ch 3: Shellcode
Debug generic process
CNIT 127 Ch 3: Shellcode
CNIT 127: 3: Shellcode
Linux kernel tracing superpowers in the cloud
CONFidence 2017: Escaping the (sand)box: The promises and pitfalls of modern ...
Rootkit on Linux X86 v2.6
Solaris Kernel Debugging V1.0
A brief history of system calls
Solaris DTrace, An Introduction
CNIT 127 Ch 3: Shellcode
zine.pdf
dtrace_topics_intro.pdf
System Calls
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
DTrace Topics: Introduction
OS SERVICES.pptxJGHHHHHHHHHHHHHHHHGGGGGGGG
Ad

More from Docker, Inc. (20)

PDF
Containerize Your Game Server for the Best Multiplayer Experience
PDF
How to Improve Your Image Builds Using Advance Docker Build
PDF
Build & Deploy Multi-Container Applications to AWS
PDF
Securing Your Containerized Applications with NGINX
PDF
How To Build and Run Node Apps with Docker and Compose
PDF
Hands-on Helm
PDF
Distributed Deep Learning with Docker at Salesforce
PDF
The First 10M Pulls: Building The Official Curl Image for Docker Hub
PDF
Monitoring in a Microservices World
PDF
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
PDF
Predicting Space Weather with Docker
PDF
Become a Docker Power User With Microsoft Visual Studio Code
PDF
How to Use Mirroring and Caching to Optimize your Container Registry
PDF
Monolithic to Microservices + Docker = SDLC on Steroids!
PDF
Kubernetes at Datadog Scale
PDF
Labels, Labels, Labels
PDF
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
PDF
Build & Deploy Multi-Container Applications to AWS
PDF
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
PDF
Developing with Docker for the Arm Architecture
Containerize Your Game Server for the Best Multiplayer Experience
How to Improve Your Image Builds Using Advance Docker Build
Build & Deploy Multi-Container Applications to AWS
Securing Your Containerized Applications with NGINX
How To Build and Run Node Apps with Docker and Compose
Hands-on Helm
Distributed Deep Learning with Docker at Salesforce
The First 10M Pulls: Building The Official Curl Image for Docker Hub
Monitoring in a Microservices World
COVID-19 in Italy: How Docker is Helping the Biggest Italian IT Company Conti...
Predicting Space Weather with Docker
Become a Docker Power User With Microsoft Visual Studio Code
How to Use Mirroring and Caching to Optimize your Container Registry
Monolithic to Microservices + Docker = SDLC on Steroids!
Kubernetes at Datadog Scale
Labels, Labels, Labels
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
Build & Deploy Multi-Container Applications to AWS
From Fortran on the Desktop to Kubernetes in the Cloud: A Windows Migration S...
Developing with Docker for the Arm Architecture

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Modernizing your data center with Dell and AMD
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Cloud computing and distributed systems.
PDF
Advanced IT Governance
PDF
Advanced Soft Computing BINUS July 2025.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Big Data Technologies - Introduction.pptx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Unlocking AI with Model Context Protocol (MCP)
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Modernizing your data center with Dell and AMD
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
NewMind AI Weekly Chronicles - August'25 Week I
Advanced methodologies resolving dimensionality complications for autism neur...
Cloud computing and distributed systems.
Advanced IT Governance
Advanced Soft Computing BINUS July 2025.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Big Data Technologies - Introduction.pptx
Review of recent advances in non-invasive hemoglobin estimation
Chapter 3 Spatial Domain Image Processing.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Empathic Computing: Creating Shared Understanding
The Rise and Fall of 3GPP – Time for a Sabbatical?
Mobile App Security Testing_ A Comprehensive Guide.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Unlocking AI with Model Context Protocol (MCP)

What Have Syscalls Done for you Lately?