Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Container Security Checklist

The Container Security Checklist

Are you running your containers securely?

This is based on the Container Security Checklist appendix in my book Container Security, published by O'Reilly.

Liz Rice

June 19, 2020
Tweet

More Decks by Liz Rice

Other Decks in Technology

Transcript

  1. © 2020 Aqua Security Software Ltd., All Rights Reserved Liz

    Rice VP Open Source Engineering, Aqua Security @lizrice | @aquasecteam The Container Security Checklist
  2. @lizrice Appendix: Security Checklist This appendix covers some important items

    you should at least think about when considering how best to secure your container deployments. In your environment it might well not make sense to apply every item, but if you have thought about them, you will be off to a good start. No doubt this list is not absolutely comprehensive!
  3. @lizrice Build Deploy Run Host machines Container images Build machines

    Container config Secrets Runtime & network security
  4. @lizrice Build Deploy Run Host machines Container images Build machines

    Container config Secrets Runtime & network security Are your builds running separately from your production cluster?
  5. @lizrice Don’t run builds in your production cluster Dockerfile …

    RUN blah blah … Kernel Build processes Applications Docker daemon /var/run/docker.sock
  6. @lizrice Don’t run builds in your production cluster* Dockerfile …

    RUN blah blah … Kernel Sandbox Build processes Applications Docker daemon /var/run/docker.sock * Unless you are very sure you know what you’re doing
  7. @lizrice Don’t run builds in your production cluster* Dockerfile …

    RUN blah blah … Kernel Rootless build processes Applications * Unless you are very sure you know what you’re doing
  8. @lizrice Build Deploy Run Host machines Container images Build machines

    Container config Secrets Runtime & network security Is all executable code added to a container image at build time?
  9. @lizrice Treat containers as immutable app Scan for vulnerable packages

    & dependencies app More code curl / apt / yum
  10. @lizrice Build Deploy Run Host machines Container images Build machines

    Container config Secrets Runtime & network security Are you avoiding –privileged?
  11. @lizrice More granular permissions than root Most containers don’t need

    to l Install Kernel modules (CAP_SYS_MODULE) l Change the system time (CAP_SYS_TIME) l Trace / modify arbitrary processes (CAP_SYS_PTRACE) Linux capabilities
  12. @lizrice $ docker run --rm -it --cap-add=ALL ubuntu /# more

    /proc/1/status | grep CapEff CapEff: 0000003fffffffff $ docker run --rm -it --cap-drop=ALL ubuntu /# more /proc/1/status | grep CapEff CapEff: 0000000000000000 $ docker run --rm -it ubuntu /# more /proc/1/status | grep CapEff CapEff: 00000000a80425fb $ docker run --rm -it --privileged ubuntu /# more /proc/1/status | grep CapEff CapEff: 0000003fffffffff All capabilities
  13. @lizrice $ docker run --rm -it ubuntu root@316a2ab0ddcb:/# ls /dev

    console core fd full mqueue null ptmx pts random shm stderr stdin stdout tty urandom zero $ docker run --rm -it --privileged ubuntu root@87c19bbc393a:/# ls /dev autofs loop-control ptmx tty14 tty33 tty52 ttyS13 ttyS4 vcsa bsg loop0 pts tty15 tty34 tty53 ttyS14 ttyS5 vcsa1 btrfs-control loop1 random tty16 tty35 tty54 ttyS15 ttyS6 vcsa2 console loop2 rfkill tty17 tty36 tty55 ttyS16 ttyS7 vcsa3 core loop3 rtc0 tty18 tty37 tty56 ttyS17 ttyS8 vcsa4 cpu_dma_latency loop4 sda tty19 tty38 tty57 ttyS18 ttyS9 vcsa5 cuse loop5 sda1 tty2 tty39 tty58 ttyS19 ttyprintk vcsa6 dm-0 loop6 sg0 tty20 tty4 tty59 ttyS2 udmabuf vcsu dm-1 loop7 shm tty21 tty40 tty6 ttyS20 uhid vcsu1 dri mapper snapshot tty22 tty41 tty60 ttyS21 uinput vcsu2 ecryptfs mcelog snd tty23 tty42 tty61 ttyS22 urandom vcsu3 fb0 mem stderr tty24 tty43 tty62 ttyS23 userio vcsu4 fd memory_bandwidth stdin tty25 tty44 tty63 ttyS24 vboxguest vcsu5 … All host devices
  14. @lizrice Build Deploy Run Host machines Container images Build machines

    Container config Secrets Runtime & network security Are you keeping hosts up to date with the latest security releases?
  15. @lizrice Build Deploy Run Host machines Container images Build machines

    Container config Secrets Runtime & network security Are your secrets encrypted at rest and in transit?
  16. @lizrice $ kubectl get secret my-secret -o jsonpath="{.data.password}" | base64

    --decode Keepthissecret $ sudo grep keepthissecret /var/lib/etcd/member/snap/db Binary file /var/lib/etcd/member/snap/db matches
  17. @lizrice l Encrypt etcd l Secrets injection: Hashicorp Vault, CyberArk

    Conjur, Aqua etc… Encrypting secrets apiVersion: apiserver.config.k8s.io/v1 kind: EncryptionConfiguration resources: - resources: - secrets providers: - aescbc: keys: - name: key1 secret: <BASE 64 ENCODED SECRET> - identity: {}
  18. @lizrice Build Deploy Run Host machines Container images Build machines

    Container config Secrets Runtime & network security Can you prevent container drift?
  19. @lizrice Are your builds running separately from your production cluster?

    Is all executable code added to a container image at build time? Are you avoiding –privileged? Are you keeping hosts up to date with the latest security releases? Are your secrets encrypted at rest and in transit? Can you prevent container drift?