Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Jorge Salamero Sanz
@bencerillo
WTF my
container just
spawned a shell!
Sysdig
Open Source system troubleshooting
with native container support
(htop, vmstat, netstat, lsof, tcpdump…)
Monitoring...
Securing Microservices
Defense in depth Microservices
Single responsibility principle:
• Principle of least privileges
• P...
Container Security Techniques
• New workflows (docker pull vs previous apt update/yum update)
• CI/CD Pipeline (Jenkins, O...
Docker Security Techniques
• Drop privileges
• Limit capabilities
• Do not run as root! containers are not VMs!
• cgroups
...
Scanning
What are my containers doing?
• Static scanning
• Dynamic scanning
Static Scanning
Yay, this was soo easy to deploy! I Docker Hub!
(your developers too, actually they were already using it ...
Image Vulnerability Scanning
• Scan contents of images looking for software versions with
known defects
• Container image ...
Image Vulnerability Scanning
• Scan contents of images looking for software versions with
known defects
• Container image ...
Image Vulnerability Scanning
• Scan contents of images looking for software versions with
known defects
• Container image ...
Image Vulnerability Scanning
• Scan contents of images looking for software versions with
known defects
• Container image ...
Container Security Techniques
OK, no known vulnerabilities, still secure?
Containers are black boxes exposing a behaviour,...
Tools
• Basic sandboxing: seccomp
• Sandboxing with policies: seccomp-bpf
• Mandatory access control systems: SELinux, App...
Seccomp
• Seccomp: application system call “sandboxing”
• One-way transition to a restricted state
• Limited set of system...
Seccomp-bpf
• Security profiles per application/container:
• Create filter (BPF program ) with lists of allowed syscalls
•...
Mandatory Access Control
• SELinux or AppArmor
• Same mechanisms: kernel-level interception/filtering
• features++ && comp...
Auditd
• Access monitoring system
• Logger for SELinux
• Rules based on files and syscalls:
# Alert whenever anyone perfor...
Sysdig Falco
An anomaly detection system built on
top of the sysdig engine
Sysdig
Kernel
Docker
Container
1
Container
2
Container
3
App App
rkt LXC
Kernel module
Instrumentation
Event stream
Open
Read
Close
Connect
Read
Write
Read
Read
Write
Close
Dump to Disk
Filter
Analyze
Events context
• Syscalls are turned into events with context:
• the process name performing the system call
• the process...
What is Sysdig Falco?
• Detects suspicious activity defined by a set of easy
rules
• Uses sysdig’s flexible and powerful f...
Quick Examples
A shell is run in a container container.id != host and proc.name = bash
Overwrite system binaries
fd.direct...
Falco Rules
• .yaml file containing Macros, Lists, and Rules
- macro: bin_dir
condition: fd.directory in (/bin, /sbin, /us...
Alerts and Outputs
• Events that match filter expression (rule) result in alerts
• output field used to format event into ...
Falco Demo
Further reading
● Documentation:
○ https://sysdig.com/blog/selinux-seccomp-falco-technical-dis
cussion/
○ https://sysdig.c...
Thank You!
Upcoming SlideShare
Loading in …5
×

WTF my container just spawned a shell!

22,602 views

Published on

Comparison of security tools for dynamic scanning Docker container with a focus on Sysdig Falco

Published in: Software
  • Be the first to comment

WTF my container just spawned a shell!

  1. 1. Jorge Salamero Sanz @bencerillo WTF my container just spawned a shell!
  2. 2. Sysdig Open Source system troubleshooting with native container support (htop, vmstat, netstat, lsof, tcpdump…) Monitoring, alerting, troubleshooting tool for Docker, Kubernetes, Mesos, RancherOS, GCE, ECS
  3. 3. Securing Microservices Defense in depth Microservices Single responsibility principle: • Principle of least privileges • Principle of least surprise • Principle of least access
  4. 4. Container Security Techniques • New workflows (docker pull vs previous apt update/yum update) • CI/CD Pipeline (Jenkins, Openshift, etc: rebuilds, rolling updates) • Access management, logging & auditing (Kubernetes, Openshift: user roles, namespaces, centralized logging, authn & authz, etc) • Trust boundaries (do you trust entire Docker Hub? Image signing, Docker Notary) • Simplify container OS, tons of useless stuff (RancherOS, Atomic, CoreOS, Alpine Linux, etc) • Network security (Weave, etc) • Secret management (Vaults instead of environment vars, etc)
  5. 5. Docker Security Techniques • Drop privileges • Limit capabilities • Do not run as root! containers are not VMs! • cgroups • Limit resources share, not access restriction • namespaces • Useful for not complete security model • User namespaces • Kubernetes/Openshift security contexts • Host security and access (Docker bench, RO access, etc)
  6. 6. Scanning What are my containers doing? • Static scanning • Dynamic scanning
  7. 7. Static Scanning Yay, this was soo easy to deploy! I Docker Hub! (your developers too, actually they were already using it :P) uhm… wait, is someone maintaining this image? RUN apt-get install -y wget build-essential python python-dev python-pip python-virtualenv RUN wget http://nodejs.org/dist/node-latest.tar.gz RUN tar xvzf node-latest.tar.gz RUN cd node-v* && ./configure && CXX="g++ -Wno-unused-local-typedefs" make && CXX="g++ -Wno-unused-local-typedefs" make install • Static Scanning: • CoreOS Clair, Docker Nautilus, Red Hat CloudForms, etc
  8. 8. Image Vulnerability Scanning • Scan contents of images looking for software versions with known defects • Container image layering can make this efficient (exploits immutable nature of images) Ubuntu: 14.04 Apache: 2.2 Wordpress: 4.6 PHP: 7.0
  9. 9. Image Vulnerability Scanning • Scan contents of images looking for software versions with known defects • Container image layering can make this efficient (exploits immutable nature of images) • Ubuntu: 14.04 Apache: 2.2 Wordpress: 4.6 PHP: 7.0
  10. 10. Image Vulnerability Scanning • Scan contents of images looking for software versions with known defects • Container image layering can make this efficient (exploits immutable nature of images) • Ubuntu: 14.04 Apache: 2.2 Wordpress: 4.6 PHP: 7.0
  11. 11. Image Vulnerability Scanning • Scan contents of images looking for software versions with known defects • Container image layering can make this efficient (exploits immutable nature of images) • Ubuntu: 14.04 Apache: 2.2 Wordpress: 4.6 PHP: 7.0
  12. 12. Container Security Techniques OK, no known vulnerabilities, still secure? Containers are black boxes exposing a behaviour, is something misbehaving? • Dynamic Scanning: • Enforcement • Auditing
  13. 13. Tools • Basic sandboxing: seccomp • Sandboxing with policies: seccomp-bpf • Mandatory access control systems: SELinux, AppArmor • System auditing: Auditd • Behavioral monitoring: Falco
  14. 14. Seccomp • Seccomp: application system call “sandboxing” • One-way transition to a restricted state • Limited set of system calls • SECCOMP_MODE_STRICT: read(), write(), _exit(), and sigreturn() • Process SIGKILLed when doing anything else • No wide real use
  15. 15. Seccomp-bpf • Security profiles per application/container: • Create filter (BPF program ) with lists of allowed syscalls • Each syscall matched against filter • Multiple actions: SIGKILL, SIGSYS, failing the syscall, notify an attached tracer process to skip/change it, allow it • Docker runs containerized process under a seccomp profile, multiple available • Notable disallowed syscalls: • clone (creating new namespaces) • reboot (reboot the host) • setns (change namespaces)
  16. 16. Mandatory Access Control • SELinux or AppArmor • Same mechanisms: kernel-level interception/filtering • features++ && complexity++ • Above syscalls: • Actors (process) • Actions (read/write on files/sockets) • Targets (files, IPs, ports) • Mandatory while seccomp is voluntary • But what if I only want to put some surveillance in?
  17. 17. Auditd • Access monitoring system • Logger for SELinux • Rules based on files and syscalls: # Alert whenever anyone performs an unlink() for a file below /usr/bin -a always,exit -S unlink -S unlinkat -F dir=/usr/bin -F success=1 # Watch any invocation of /usr/bin/passwd -w /usr/bin/passwd -p x -k passwd_mgmt
  18. 18. Sysdig Falco An anomaly detection system built on top of the sysdig engine
  19. 19. Sysdig Kernel Docker Container 1 Container 2 Container 3 App App rkt LXC Kernel module Instrumentation
  20. 20. Event stream Open Read Close Connect Read Write Read Read Write Close Dump to Disk Filter Analyze
  21. 21. Events context • Syscalls are turned into events with context: • the process name performing the system call • the process’s parents, grandparents, etc • the remote IP address to which the process is communicating • the directory of the file being read/written • the current memory usage of the process
  22. 22. What is Sysdig Falco? • Detects suspicious activity defined by a set of easy rules • Uses sysdig’s flexible and powerful filtering expressions (in userspace -single point of failure-) • Container support (Docker, Kubernetes, Mesos, etc) • Flexible notification methods • Open Source
  23. 23. Quick Examples A shell is run in a container container.id != host and proc.name = bash Overwrite system binaries fd.directory in (/bin, /sbin, /usr/bin, /usr/sbin) and write Container namespace change evt.type = setns and not proc.name in (docker, sysdig) Non-device files written in /dev (evt.type = creat or evt.arg.flags contains O_CREAT) and proc.name != blkid and fd.directory = /dev and fd.name != /dev/null Process tries to access camera evt.type = open and fd.name = /dev/video0 and not proc.name in (skype, webex)
  24. 24. Falco Rules • .yaml file containing Macros, Lists, and Rules - macro: bin_dir condition: fd.directory in (/bin, /sbin, /usr/bin, /usr/sbin) - list: package_mgmt_binaries items: [dpkg, dpkg-preconfigu, rpm, rpmkey, yum, frontend] - rule: write_binary_dir desc: an attempt to write to any file below a set of binary directories condition: bin_dir and evt.dir = < and open_write and not package_mgmt_procs output: "File below a known binary directory opened for writing (user=%user.name command=%proc.cmdline file=%fd.name)" priority: WARNING
  25. 25. Alerts and Outputs • Events that match filter expression (rule) result in alerts • output field used to format event into alert message • Sending to: • syslog • file • stdout • shell (e.g. mail -s "Falco Notification" alerts@example.com) • Sysdig Cloud
  26. 26. Falco Demo
  27. 27. Further reading ● Documentation: ○ https://sysdig.com/blog/selinux-seccomp-falco-technical-dis cussion/ ○ https://sysdig.com/blog/friends-dont-let-friends-curl-bash/ ● http://www.sysdig.org/falco/ ● https://github.com/draios/falco
  28. 28. Thank You!

×