$30 off During Our Annual Pro Sale. View Details »

Testing Docker Security LinuxLab 2017

jmortegac
December 07, 2017

Testing Docker Security LinuxLab 2017

Testing Docker Security LinuxLab 2017

jmortegac

December 07, 2017
Tweet

More Decks by jmortegac

Other Decks in Technology

Transcript

  1. Testing Docker Security
    LinuxLab 2017
    José Manuel Ortega

    View Slide

  2. @jmortegac

    View Slide

  3. Agenda
    ● Introduction to docker security
    ● Security best practices
    ● Tools for auditing docker host
    ● Tools for auditing docker images
    ● Demo

    View Slide

  4. Virtualization vs containers

    View Slide

  5. Container pipeline

    View Slide

  6. 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

    View Slide

  7. 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.

    View Slide

  8. 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

    View Slide

  9. Docker images

    View Slide

  10. Docker images

    View Slide

  11. Dockerfile

    View Slide

  12. View Slide

  13. View Slide

  14. View Slide

  15. View Slide

  16. Docker Content Trust

    View Slide

  17. 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

    View Slide

  18. View Slide

  19. View Slide

  20. 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

    View Slide

  21. View Slide

  22. View Slide

  23. View Slide

  24. --cap-drop all
    --cap-add

    View Slide

  25. Docker security is
    about limiting and
    controlling the attack
    surface on the kernel.

    View Slide

  26. Run filesystems as read-only
    so that attackers can not
    overwrite data or save
    malicious scripts to the image.

    View Slide

  27. 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.

    View Slide

  28. DockerFile security
    ● Set a specific user.
    ● Don’t run your applications as root in containers.

    View Slide

  29. Read only containers & volumes

    View Slide

  30. Privileged vs non-privileged

    View Slide

  31. Privileged vs non-privileged

    View Slide

  32. 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

    View Slide

  33. View Slide

  34. Audit Docker Host

    View Slide

  35. 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-securit
    y

    View Slide

  36. Docker bench security

    View Slide

  37. 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

    View Slide

  38. 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

    View Slide

  39. View Slide

  40. Demo time

    View Slide

  41. Audit Docker Images

    View Slide

  42. ● 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

    View Slide

  43. Docker security scanning

    View Slide

  44. Docker security scanning

    View Slide

  45. View Slide

  46. OWASP Dependency checker

    View Slide

  47. Anchore

    View Slide

  48. Anchore

    View Slide

  49. Anchore

    View Slide

  50. View Slide

  51. Dagda

    View Slide

  52. Tenable.io container security

    View Slide

  53. View Slide

  54. View Slide

  55. View Slide

  56. Docker images for malware analysis

    View Slide

  57. 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

    View Slide

  58. View Slide

  59. Thanks!
    Contact:
    @jmortegac
    jmortega.github.io
    about.met/jmortegac

    View Slide