Testing Docker Security Linuxlab 2017
-
Upload
jose-manuel-ortega-candel -
Category
Technology
-
view
113 -
download
1
Transcript of Testing Docker Security Linuxlab 2017
![Page 1: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/1.jpg)
Testing Docker SecurityLinuxLab 2017
José Manuel Ortega
![Page 2: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/2.jpg)
@jmortegac
![Page 3: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/3.jpg)
Agenda
● Introduction to docker security● Security best practices● Tools for auditing docker host● Tools for auditing docker images● Demo
![Page 4: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/4.jpg)
Virtualization vs containers
![Page 5: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/5.jpg)
Container pipeline
![Page 6: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/6.jpg)
Security mechanims
● Docker uses several mechanisms:○ Linux kernel namespaces○ Linux Control Groups (cgroups)○ The Docker daemon○ Linux capabilities (libcap)○ Linux security mechanisms like
AppArmor,SELinux,Seccomp
![Page 7: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/7.jpg)
Namespaces
● Provides an isolated view of the system where processes cannot see other processes in other containers
● Each container also gets its own network stack.
● A container doesn’t get privileged access to the sockets or interfaces of another container.
![Page 8: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/8.jpg)
Cgroups && capabilities
● Cgroups: kernel feature that limits and isolates the resource usage (CPU, memory, network) of a collection of processes.
● Linux Capabilities: divides the privileges of root into distinct units and smaller groups of privileges
![Page 9: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/9.jpg)
Docker images
![Page 10: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/10.jpg)
Docker images
![Page 11: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/11.jpg)
Dockerfile
![Page 12: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/12.jpg)
![Page 13: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/13.jpg)
![Page 14: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/14.jpg)
![Page 15: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/15.jpg)
![Page 16: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/16.jpg)
Docker Content Trust
![Page 17: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/17.jpg)
Docker Content Trust
● We can verify the integrity of the image● Checksum validation when pulling image
from docker hub● Pulling by digest to enforce consistent
![Page 18: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/18.jpg)
![Page 19: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/19.jpg)
![Page 20: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/20.jpg)
Docker Capabilites● A capability is a unix action a user can
perform● Goal is to restrict “capabilities”● Privileged process = all the capabilities!● Unprivileged process = check individual user
capabilities● Example Capabilities:
○ CAP_CHOWN○ CAP_NET_RAW
![Page 21: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/21.jpg)
![Page 22: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/22.jpg)
![Page 23: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/23.jpg)
![Page 24: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/24.jpg)
--cap-drop all--cap-add <specific_functionality>
![Page 25: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/25.jpg)
Docker security is about limiting and controlling the attack surface on the kernel.
![Page 26: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/26.jpg)
Run filesystems as read-only so that attackers can not overwrite data or save malicious scripts to the image.
![Page 27: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/27.jpg)
Least privilege principle
● Do not run processes in a container as root to avoid root access from attackers.
● Enable User-namespace
● Run filesystems as read-only so that attackers can not overwrite data or save malicious scripts to file.
● Cut down the kernel calls that a container can make to reduce the potential attack surface.
![Page 28: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/28.jpg)
DockerFile security
● Set a specific user.
● Don’t run your applications as root in containers.
![Page 29: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/29.jpg)
Read only containers & volumes
![Page 30: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/30.jpg)
Privileged vs non-privileged
![Page 31: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/31.jpg)
Privileged vs non-privileged
![Page 32: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/32.jpg)
Seccomp
● Restricts system calls based on a policy● Block/limit things like:
○ Kernel manipulation (init_module, finit_module, delete_module)
○ Executing mount options○ Change permissions○ Change owner and groups
![Page 33: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/33.jpg)
![Page 34: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/34.jpg)
Audit Docker Host
![Page 35: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/35.jpg)
Docker bench security
● Auditing docker environment and containers
● Open-source tool for running automated tests
● Inspired by the CIS Docker 1.11 benchmark
● Runs against containers currently running on same host
● Checks for AppArmor, read-only volumes, etc...https://github.com/docker/docker-bench-security
![Page 36: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/36.jpg)
Docker bench security
![Page 37: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/37.jpg)
Docker bench security
● The host configuration● The Docker daemon configuration● The Docker daemon configuration files● Container images and build files● Container runtime● Docker security operations
![Page 38: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/38.jpg)
Lynis
● https://github.com/CISOfy/lynis-docker● Lynis is a Linux, Mac and Unix security
auditing and system hardening tool that includes a module to audit Dockerfiles.
● lynis audit system● lynis audit dockerfile <file>
![Page 39: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/39.jpg)
![Page 40: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/40.jpg)
Demo time
![Page 41: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/41.jpg)
Audit Docker Images
![Page 42: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/42.jpg)
● You can scan your images for known vulnerabilities
● Find known vulnerable binaries○ Docker Security Scanning○ OWASP Dependency checker○ Anchore Cloud○ Dagda○ Tenable.io Container Security
●
![Page 43: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/43.jpg)
Docker security scanning
![Page 44: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/44.jpg)
Docker security scanning
![Page 45: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/45.jpg)
![Page 46: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/46.jpg)
OWASP Dependency checker
![Page 47: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/47.jpg)
Anchore
![Page 48: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/48.jpg)
Anchore
![Page 49: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/49.jpg)
Anchore
![Page 50: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/50.jpg)
![Page 51: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/51.jpg)
Dagda
![Page 52: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/52.jpg)
Tenable.io container security
![Page 53: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/53.jpg)
![Page 54: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/54.jpg)
![Page 55: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/55.jpg)
![Page 56: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/56.jpg)
Docker images for malware analysis
![Page 57: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/57.jpg)
References● https://docs.docker.com/engine/security● http://www.oreilly.com/webops-perf/free/files/docker-securi
ty.pdf● http://container-solutions.com/content/uploads/2015/06/15.0
6.15_DockerCheatSheet_A2.pdf● Docker Content Trust
https://docs.docker.com/engine/security/trust/content_trust● Docker Security Scanning● https://docs.docker.com/docker-cloud/builds/image-scan● https://blog.docker.com/2016/04/docker-security● http://softwaretester.info/docker-audit
●
![Page 58: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/58.jpg)
![Page 59: Testing Docker Security Linuxlab 2017](https://reader031.fdocuments.in/reader031/viewer/2022021922/5a65ad887f8b9a38648b4a19/html5/thumbnails/59.jpg)
Thanks!
Contact:
@jmortegac
jmortega.github.io
about.met/jmortegac