SlideShare a Scribd company logo
1 of 39
Download to read offline
Eric Smalling
So.
Many.
Vulnerabilities.
Why are containers such a
mess and what to do about
it.
Senior Developer Advocate, Snyk
@ericsmalling
WHAT ARE WE
GOING TO COVER?
• I’ve got a container with a bunch of
vulnerabilities. What do I get started?
• We have a bunch of teams using
containers, is there a good process we
can all use?
• Interesting ideas in the container world
(including some I’d avoid)
KEY
PRINCIPLES Repeatability Efficiency Don’t make me
read vulnerability
reports or learn
the art & science
of being a
sysadmin
OUR STARTING STATE
I’VE GOT A CONTAINER WITH A BUNCH
OF VULNERABILITIES.
WHERE DO I GET STARTED?
Base Image
Your added
layers
Your code &
code dependencies
1
2
3
Configuration
4
A SYSTEM FOR CLEANING UP CONTAINER
VULNERABILITIES
Base Image
Your added
layers
Your code &
code dependencies
1
2
3
Configuration
4
A SYSTEM FOR CLEANING UP CONTAINER
VULNERABILITIES
FIXING CONTAINERS IS ALSO NOT LIKE
FIXING VMS
Did I add
something
with an
issue…
…or did I
inherit this
problem?
The answer changes how we think about a “fix”
Base Image
Your added
layers
Your code &
code dependencies
1
2
3
Configuration
4
A SYSTEM FOR CLEANING UP CONTAINER
VULNERABILITIES
PICKING A BASE IMAGE ISN’T AS SIMPLE
AS IT SEEMS
ruby
850 MB
414 dependencies
257 vulnerabilities
35 high severity
ruby:3-slim
157 MB
107 dependencies
60 vulnerabilities
10 high severity
There are ~700 tags listed
in Docker Hub’s official ruby
repo…
...which one is “best”?
BASE IMAGE BEST PRACTICES
Generic is not what you
want!
• What framework version are you
coding against? Do these
containers match? Will they
match tomorrow?
• Generally: good for playing
around, but don’t use for ”real”
work
But -slim isn’t automatically
the right choice
• Vulns go away! 🥳
• BUT you “get to” manage all the
build dependencies 😒
docker pull [ruby | python | ubuntu...]
RUN apt-get update &&
apt-get install -y build-essential 
patch ruby-dev zlib1g-dev liblzma-dev 
libpq-dev libsqlite3-dev
probably
^
MULTI-STAGE TO THE RESCUE!!!
FROM python:3.8-buster as builder
.
.
.
FROM python:3.8-buster-slim
COPY –from=builder <app stuff> .
PICKING A BASE IMAGE ISN’T AS SIMPLE AS
IT SEEMS
ruby
850 MB
414 dependencies
257 vulnerabilities
35 high severity
ruby:3-slim
157 MB
107 dependencies
60 vulnerabilities
10 high severity
ruby:alpine
60 MB
36 dependencies
1 vulnerabilities
0 high severity
SO WHY NOT ALPINE
FOR ALL THE THINGS?!?
• Uses musl instead of gnu/libc
• Uses different packages, different package
manager
• They handle security a little differently
https://pythonspeed.com/articles/alpine-docker-python/
GENERAL RECOMMENDATIONS
General “make life easier” things:
• A little bit of Sysadmin knowledge is unavoidable - pick an OS
distribution and use it for everything
• Pin to versioned images (at least Major, probably minor)
Getting rid of vulnerabilities
• Learn & love multi-stage builds!
• Let Docker / Red Hat / VMware (Bitnami)… do the heavy lifting!
• Rebuild often (clear your cache or use --no-cache)
• Move your pins every once in a while 📌
Zero vulnerabilities in a container is almost impossible
WE HAVE A BUNCH OF TEAMS USING
CONTAINERS, IS THERE A GOOD PROCESS
WE CAN ALL USE?
Using base images
FROM ubuntu:latest
Standing on the shoulders of software giants
It’s common with container images to start
building on top of an existing base image that
already has software you want.
This might be an operating system like ubuntu,
alpine or debian or it could be a language like
python, ruby, node or really anything else.
OK, technically often a parent image but hey.
Libraries and underlying software
provided by someone else
Your software
Distinct responsibilities
Hardening, common configuration
Your organization might have some common hardening or
configuration changes or maybe metadata it wants to
apply to all images in use by other teams. This is often
intended to be common for all images used. Maybe you
have myorg/base
Libraries and underlying software
provided by someone else
Hardening, common configuration
Common software
Your application
Distinct responsibilities
Common software
Some organizations provide a layer of common software
or middleware. This might be language or framework
specific, say a separate image for Java (myorg/java) and
another for Python (myorg/python).
Libraries and underlying software
provided by someone else
Hardening, common configuration
Common software
Your application
Distinct responsibilities
Your application
Finally the specifics of your application, whether in source
or binary form. And metadata specific to the application.
Libraries and underlying software
provided by someone else
Hardening, common configuration
Common software
Your application
Can you fix vulnerabilities
once?
Base
image
Scale vulnerability management
When considering container
vulnerabilities, you want to be able
to reason about vulnerabilities in
images you’re running, but also
understand the overlap and source
of those vulnerabilities.
Can you address a vulnerability once,
and have it resolved everywhere?
Teams and responsibility
A worked example
Organizing into teams
Libraries and underlying
software provided by someone
else
Hardening, common
configuration
Common software
Your application
Libraries and underlying
software provided by someone
else
Hardening, common
configuration
Common software
Your application
Libraries and underlying
software provided by someone
else
Hardening, common
configuration
Common software
Your application
One team to rule them all
This could be the case when
teams are completely
independent, or when you
have one central image team.
A base image team
A team which provides a
standard set of approved
base images for application
teams to consume.
Separate base/security teams
Larger organizations might have
teams with more distinct
responsibilities, potentially with
even more layers.
Pros and cons
One team to rule them all
PROS
Simple to understand
responsibilities.
CONS
Potential for chaos if every
team can do their own thing.
One central team for ALL
images likely to become a
bottleneck.
A base image team
PROS
Able to build strong domain
expertise in the center,
ideally fix/triage issues once.
CONS
Needs some level of
governance in order to
ensure applications teams
benefit from central
expertise.
Separate base/security teams
PROS
Same as having a base image
team, with the added advantage
of deeper specialisms.
CONS
Coordination between
additional teams can slow down
the process.
Start with your own base image
$ cat base/Dockerfile
FROM python:3.6.0-slim
RUN apt-get update && apt-get install -y <all our critical hardening pkgs>
$ docker build -t myorg/base -f base/Dockerfile
Establish a baseline
What can downstream consumers ignore?
$ <container tool> --test myorg/base
...
Introduced by your base image (python:3.6.0-slim)
Fixed in: 5.28.1-6+deb10u1
✗ High severity vulnerability found in gnutls28/libgnutls30
Description: Out-of-bounds Write
Info: https://snyk.io/vuln/SNYK-DEBIAN10-GNUTLS28-609778
Introduced through: gnutls28/libgnutls30@3.6.7-4+deb10u4, apt@1.8.2.1
From: gnutls28/libgnutls30@3.6.7-4+deb10u4
From: apt@1.8.2.1 > gnutls28/libgnutls30@3.6.7-4+deb10u4
Introduced by your base image (python:3.6.0-slim)
Tested 111 dependencies for known issues, found 178 issues.
Watch out for new vulnerabilities
Generally, “fresh” images on Hub, RHT, etc have no FIXABLE vulns
• Your baseline establishes the things
you can ignore
• But things get fixed…
• …and things get broken…
• Rebuild & set a new baseline often!
A middleware image
$ cat middleware/Dockerfile
FROM myorg/base
RUN apt-get update && apt-get install -y 
gunicorn 
sqlite3 
&& rm -rf /var/lib/apt/lists/
$ docker build -t myorg/middleware -f middleware/Dockerfile
The sum of all vulnerabilities
$ <container tool> test myorg/middleware
...
Tested 127 dependencies for known issues, found 180 issues.
Vulnerabilities from the base image and the new instructions
But a different team is responsible for some of these, so let’s reason about those separately.
Where did the issue come from?
$ <container tool> test myorg/middleware
+------------------------------------------------------------------------------------------------------------------------------------------------------+
| Found 180 unique vulnerabilities for myorg/middleware |
+----------------------------------+---------------+------------------+------------------------------------+-------------------+-----------------------+
| Package | Severity | ID | Issue | Installed | Fixed in |
+----------------------------------+---------------+------------------+------------------------------------+-------------------+-----------------------+
| ncurses/libncurses5 | HIGH | CVE-2017-10684 | Out-of-Bounds | 5.9+20140913-1+b1 | 5.9+20140913-1+deb8u1 |
| ncurses/libncurses5 | HIGH | CVE-2017-10685 | Improper Input Validation | 5.9+20140913-1+b1 | 5.9+20140913-1+deb8u1 |
| sqlite3/libsqlite3-0 | HIGH | CVE-2020-9794 | Out-of-bounds Read | 3.8.7.1-1+deb8u6 | |
| sqlite3/libsqlite3-0 | HIGH | CVE-2019-8457 | Out-of-bounds Read | 3.8.7.1-1+deb8u6 | |
| ncurses/libncurses5 | MEDIUM | CVE-2017-16879 | Out-of-Bounds | 5.9+20140913-1+b1 | 5.9+20140913-1+deb8u3 |
| ncurses/libncurses5 | MEDIUM | CVE-2017-13729 | Out-of-Bounds | 5.9+20140913-1+b1 | 5.9+20140913-1+deb8u1 |
...
+------------------------------------------------------------------------------------------------------------------------------------------------------+
| Base image vulnerabilities from myorg/base |
+---------------------------+-------------+------------------+--------------------------------------+----------------------+---------------------------+
| Package | Severity | ID | Issue | Installed | Fixed in |
+---------------------------+-------------+------------------+--------------------------------------+----------------------+---------------------------+
| apt/libapt-pkg4.12 | HIGH | CVE-2019-3462 | Arbitrary Code Injection | 1.0.9.8.4 | 1.0.9.8.5 |
| bzip2/libbz2-1.0 | HIGH | CVE-2019-12900 | Out-of-bounds Write | 1.0.6-7+b3 | 1.0.6-7+deb8u1 |
| glibc/libc-bin | HIGH | CVE-2018-1000001 | Out-of-Bounds | 2.19-18+deb8u7 | |
| glibc/libc-bin | HIGH | CVE-2014-9761 | Out-of-Bounds | 2.19-18+deb8u7 | |
Middleware team
Base image team
There are really
only 2 new vulns in
middleware
Ignore what you can, but make
sure there’s an audit trail!
Your application images
$ cat app/Dockerfile
FROM myorge/middleware
EXPOSE 8080
WORKDIR /app
ADD app.py .
CMD ["gunicorn", "-w", "4", "app:app"]
$ docker build -t myorg/app -f app/Dockerfile
Visualising ownership
$ <container tool> test myorg/app
+-----------------------------------------------------------------------------------------+
| Found 180 unique vulnerabilities for myorg/app |
+--------------+--------------+--------------+--------------+--------------+--------------+
| Package | Severity | ID | Issue | Installed | Fixed in |
+--------------+--------------+--------------+--------------+--------------+--------------+
+------------------------------------------------------------------------------------------------------------------------------------------------------+
| Base image vulnerabilities from myorg/middleware |
+----------------------------------+--------------+------------------+------------------------------+----------------------+---------------------------+
| Package | Severity | ID | Issue | Installed | Fixed in |
+----------------------------------+--------------+------------------+------------------------------+----------------------+---------------------------+
| apt/libapt-pkg4.12 | HIGH | CVE-2019-3462 | Arbitrary Code Injection | 1.0.9.8.4 | 1.0.9.8.5 |
| bzip2/libbz2-1.0 | HIGH | CVE-2019-12900 | Out-of-bounds Write | 1.0.6-7+b3 | 1.0.6-7+deb8u1 |
| glibc/libc-bin | HIGH | CVE-2018-1000001 | Out-of-Bounds | 2.19-18+deb8u7 | |
...
Middleware team
App team 🎉 🍻
Conclusions
If all you remember is...
Observe
How are your teams using base
images today?
Orient
Who actually fixes vulnerabilities?
Do all teams bear the burden of
fixing the same issues?
Decide
How can you shift the
responsibilities of teams to make
base image management easier?
Act
Put in place the automation to scale.
Thanks for listening
Example app for the multi-team builds:
https://github.com/garethr/snykt
@ericsmalling

More Related Content

What's hot

DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing EnvironmentDCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
Docker, Inc.
 
20+ ways to bypass your mac os privacy mechanisms
20+ ways to bypass your mac os privacy mechanisms20+ ways to bypass your mac os privacy mechanisms
20+ ways to bypass your mac os privacy mechanisms
Csaba Fitzl
 
2013 10-28 php ug presentation - ci using phing and hudson
2013 10-28 php ug presentation - ci using phing and hudson2013 10-28 php ug presentation - ci using phing and hudson
2013 10-28 php ug presentation - ci using phing and hudson
Shreeniwas Iyer
 

What's hot (20)

Securing jenkins
Securing jenkinsSecuring jenkins
Securing jenkins
 
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
IBM Index 2018 Conference Workshop: Modernizing Traditional Java App's with D...
 
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing EnvironmentDCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
DCSF19 Transforming a 15+ Year Old Semiconductor Manufacturing Environment
 
DevSecCon Singapore 2018 - System call auditing made effective with machine l...
DevSecCon Singapore 2018 - System call auditing made effective with machine l...DevSecCon Singapore 2018 - System call auditing made effective with machine l...
DevSecCon Singapore 2018 - System call auditing made effective with machine l...
 
Immutable Infrastructure Security
Immutable Infrastructure SecurityImmutable Infrastructure Security
Immutable Infrastructure Security
 
20+ ways to bypass your mac os privacy mechanisms
20+ ways to bypass your mac os privacy mechanisms20+ ways to bypass your mac os privacy mechanisms
20+ ways to bypass your mac os privacy mechanisms
 
Automated Infrastructure Security: Monitoring using FOSS
Automated Infrastructure Security: Monitoring using FOSSAutomated Infrastructure Security: Monitoring using FOSS
Automated Infrastructure Security: Monitoring using FOSS
 
Exploiting XPC in AntiVirus
Exploiting XPC in AntiVirusExploiting XPC in AntiVirus
Exploiting XPC in AntiVirus
 
Drupal Continuous Integration with Jenkins - The Basics
Drupal Continuous Integration with Jenkins - The BasicsDrupal Continuous Integration with Jenkins - The Basics
Drupal Continuous Integration with Jenkins - The Basics
 
Node.js vs Play Framework
Node.js vs Play FrameworkNode.js vs Play Framework
Node.js vs Play Framework
 
2013 10-28 php ug presentation - ci using phing and hudson
2013 10-28 php ug presentation - ci using phing and hudson2013 10-28 php ug presentation - ci using phing and hudson
2013 10-28 php ug presentation - ci using phing and hudson
 
Who *is* Jenkins?
Who *is* Jenkins?Who *is* Jenkins?
Who *is* Jenkins?
 
DevSecCon Tel Aviv 2018 - End2End containers SSDLC by Vitaly Davidoff
DevSecCon Tel Aviv 2018 - End2End containers SSDLC by Vitaly DavidoffDevSecCon Tel Aviv 2018 - End2End containers SSDLC by Vitaly Davidoff
DevSecCon Tel Aviv 2018 - End2End containers SSDLC by Vitaly Davidoff
 
Automated Infrastructure Testing
Automated Infrastructure TestingAutomated Infrastructure Testing
Automated Infrastructure Testing
 
OpenSCAP Overview(security scanning for docker image and container)
OpenSCAP Overview(security scanning for docker image and container)OpenSCAP Overview(security scanning for docker image and container)
OpenSCAP Overview(security scanning for docker image and container)
 
DevSecCon Tel Aviv 2018 - Integrated Security Testing by Morgan Roman
DevSecCon Tel Aviv 2018 - Integrated Security Testing by Morgan RomanDevSecCon Tel Aviv 2018 - Integrated Security Testing by Morgan Roman
DevSecCon Tel Aviv 2018 - Integrated Security Testing by Morgan Roman
 
Beefing Up AIR - FITC AMS 2012
Beefing Up AIR - FITC AMS 2012Beefing Up AIR - FITC AMS 2012
Beefing Up AIR - FITC AMS 2012
 
Seven Habits of Highly Effective Jenkins Users (2014 edition!)
Seven Habits of Highly Effective Jenkins Users (2014 edition!)Seven Habits of Highly Effective Jenkins Users (2014 edition!)
Seven Habits of Highly Effective Jenkins Users (2014 edition!)
 
Operating Docker
Operating DockerOperating Docker
Operating Docker
 
Continuous Integration/Deployment with Docker and Jenkins
Continuous Integration/Deployment with Docker and JenkinsContinuous Integration/Deployment with Docker and Jenkins
Continuous Integration/Deployment with Docker and Jenkins
 

Similar to So. many. vulnerabilities. Why are containers such a mess and what to do about it.

Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]
RootedCON
 
Virtualize and automate your development environment for fun and profit
Virtualize and automate your development environment for fun and profitVirtualize and automate your development environment for fun and profit
Virtualize and automate your development environment for fun and profit
Andreas Heim
 

Similar to So. many. vulnerabilities. Why are containers such a mess and what to do about it. (20)

Automated Scaling of Microservice Stacks for JavaEE Applications
Automated Scaling of Microservice Stacks for JavaEE ApplicationsAutomated Scaling of Microservice Stacks for JavaEE Applications
Automated Scaling of Microservice Stacks for JavaEE Applications
 
Docker presentasjon java bin
Docker presentasjon java binDocker presentasjon java bin
Docker presentasjon java bin
 
What is this "docker"
What is this  "docker" What is this  "docker"
What is this "docker"
 
Dock ir incident response in a containerized, immutable, continually deploy...
Dock ir   incident response in a containerized, immutable, continually deploy...Dock ir   incident response in a containerized, immutable, continually deploy...
Dock ir incident response in a containerized, immutable, continually deploy...
 
Containerizing legacy applications
Containerizing legacy applicationsContainerizing legacy applications
Containerizing legacy applications
 
Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]
 
Dev Environments: The Next Generation
Dev Environments: The Next GenerationDev Environments: The Next Generation
Dev Environments: The Next Generation
 
Code Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application MigrationsCode Coverage for Total Security in Application Migrations
Code Coverage for Total Security in Application Migrations
 
Opendaylight SDN Controller
Opendaylight SDN ControllerOpendaylight SDN Controller
Opendaylight SDN Controller
 
Symfony finally swiped right on envvars
Symfony finally swiped right on envvarsSymfony finally swiped right on envvars
Symfony finally swiped right on envvars
 
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh VariaCloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
Cloud-powered Continuous Integration and Deployment architectures - Jinesh Varia
 
Can I Contain This?
Can I Contain This?Can I Contain This?
Can I Contain This?
 
Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?Comment améliorer le quotidien des Développeurs PHP ?
Comment améliorer le quotidien des Développeurs PHP ?
 
A Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy SystemA Fabric/Puppet Build/Deploy System
A Fabric/Puppet Build/Deploy System
 
Introduction to JIB and Google Cloud Run
Introduction to JIB and Google Cloud RunIntroduction to JIB and Google Cloud Run
Introduction to JIB and Google Cloud Run
 
What is the Secure Supply Chain and the Current State of the PHP Ecosystem
What is the Secure Supply Chain and the Current State of the PHP EcosystemWhat is the Secure Supply Chain and the Current State of the PHP Ecosystem
What is the Secure Supply Chain and the Current State of the PHP Ecosystem
 
Virtualize and automate your development environment for fun and profit
Virtualize and automate your development environment for fun and profitVirtualize and automate your development environment for fun and profit
Virtualize and automate your development environment for fun and profit
 
TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...
TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...
TechMentor Fall, 2011 - Packaging Software for Automated Deployment with Wind...
 
Jbossworld Presentation
Jbossworld PresentationJbossworld Presentation
Jbossworld Presentation
 
Getting started with CFEngine - Webinar
Getting started with CFEngine - WebinarGetting started with CFEngine - Webinar
Getting started with CFEngine - Webinar
 

More from Eric Smalling

Simply your Jenkins Projects with Docker Multi-Stage Builds
Simply your Jenkins Projects with Docker Multi-Stage BuildsSimply your Jenkins Projects with Docker Multi-Stage Builds
Simply your Jenkins Projects with Docker Multi-Stage Builds
Eric Smalling
 

More from Eric Smalling (19)

DockerCon 2023 - Live Demo_Hardening Against Kubernetes Hacks.pdf
DockerCon 2023 - Live Demo_Hardening Against Kubernetes Hacks.pdfDockerCon 2023 - Live Demo_Hardening Against Kubernetes Hacks.pdf
DockerCon 2023 - Live Demo_Hardening Against Kubernetes Hacks.pdf
 
KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...
KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...
KubeHuddle NA 2023 - Why should devs care about container security - Eric Sma...
 
ATO 2022 - Why should devs care about container security.pdf
ATO 2022 - Why should devs care about container security.pdfATO 2022 - Why should devs care about container security.pdf
ATO 2022 - Why should devs care about container security.pdf
 
KubeCon NA 2022 - Hardening against Kubernetes Hacks.pdf
KubeCon NA 2022 - Hardening against Kubernetes Hacks.pdfKubeCon NA 2022 - Hardening against Kubernetes Hacks.pdf
KubeCon NA 2022 - Hardening against Kubernetes Hacks.pdf
 
DevOpsDays Chicago 2022 - Hands-on hacking containers and ways to prevent it
DevOpsDays Chicago 2022 - Hands-on hacking containers and ways to prevent itDevOpsDays Chicago 2022 - Hands-on hacking containers and ways to prevent it
DevOpsDays Chicago 2022 - Hands-on hacking containers and ways to prevent it
 
Look Ma' - Building Java and Go based container images without Dockerfiles
Look Ma' - Building Java and Go based container images without DockerfilesLook Ma' - Building Java and Go based container images without Dockerfiles
Look Ma' - Building Java and Go based container images without Dockerfiles
 
Container Stranger Danger - Why should devs care about container security
Container Stranger Danger - Why should devs care about container securityContainer Stranger Danger - Why should devs care about container security
Container Stranger Danger - Why should devs care about container security
 
SCaLE 19x - Eric Smalling - Hardening against Kubernetes Hacks
SCaLE 19x - Eric Smalling - Hardening against Kubernetes HacksSCaLE 19x - Eric Smalling - Hardening against Kubernetes Hacks
SCaLE 19x - Eric Smalling - Hardening against Kubernetes Hacks
 
DockerCon 2022 - From legacy to Kubernetes, securely & quickly
DockerCon 2022 - From legacy to Kubernetes, securely & quicklyDockerCon 2022 - From legacy to Kubernetes, securely & quickly
DockerCon 2022 - From legacy to Kubernetes, securely & quickly
 
Python Web Conference 2022 - Why should devs care about container security.pdf
Python Web Conference 2022 - Why should devs care about container security.pdfPython Web Conference 2022 - Why should devs care about container security.pdf
Python Web Conference 2022 - Why should devs care about container security.pdf
 
Why should developers care about container security?
Why should developers care about container security?Why should developers care about container security?
Why should developers care about container security?
 
AWS live hack: Docker + Snyk Container on AWS
AWS live hack: Docker + Snyk Container on AWSAWS live hack: Docker + Snyk Container on AWS
AWS live hack: Docker + Snyk Container on AWS
 
AWS live hack: Atlassian + Snyk OSS on AWS
AWS live hack: Atlassian + Snyk OSS on AWSAWS live hack: Atlassian + Snyk OSS on AWS
AWS live hack: Atlassian + Snyk OSS on AWS
 
Hacking into your containers, and how to stop it!
Hacking into your containers, and how to stop it!Hacking into your containers, and how to stop it!
Hacking into your containers, and how to stop it!
 
DevSecCon Lightning 2021- Container defaults are a hackers best friend
DevSecCon Lightning 2021- Container defaults are a hackers best friendDevSecCon Lightning 2021- Container defaults are a hackers best friend
DevSecCon Lightning 2021- Container defaults are a hackers best friend
 
LFX Nov 16, 2021 - Find vulnerabilities before security knocks on your door
LFX Nov 16, 2021 - Find vulnerabilities before security knocks on your doorLFX Nov 16, 2021 - Find vulnerabilities before security knocks on your door
LFX Nov 16, 2021 - Find vulnerabilities before security knocks on your door
 
Best Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with DockerBest Practices for Developing & Deploying Java Applications with Docker
Best Practices for Developing & Deploying Java Applications with Docker
 
Docker 101 Workshop slides (JavaOne 2017)
Docker 101 Workshop slides (JavaOne 2017)Docker 101 Workshop slides (JavaOne 2017)
Docker 101 Workshop slides (JavaOne 2017)
 
Simply your Jenkins Projects with Docker Multi-Stage Builds
Simply your Jenkins Projects with Docker Multi-Stage BuildsSimply your Jenkins Projects with Docker Multi-Stage Builds
Simply your Jenkins Projects with Docker Multi-Stage Builds
 

Recently uploaded

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Recently uploaded (20)

%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 

So. many. vulnerabilities. Why are containers such a mess and what to do about it.

  • 1. Eric Smalling So. Many. Vulnerabilities. Why are containers such a mess and what to do about it. Senior Developer Advocate, Snyk @ericsmalling
  • 2. WHAT ARE WE GOING TO COVER? • I’ve got a container with a bunch of vulnerabilities. What do I get started? • We have a bunch of teams using containers, is there a good process we can all use? • Interesting ideas in the container world (including some I’d avoid)
  • 3. KEY PRINCIPLES Repeatability Efficiency Don’t make me read vulnerability reports or learn the art & science of being a sysadmin
  • 5. I’VE GOT A CONTAINER WITH A BUNCH OF VULNERABILITIES. WHERE DO I GET STARTED?
  • 6. Base Image Your added layers Your code & code dependencies 1 2 3 Configuration 4 A SYSTEM FOR CLEANING UP CONTAINER VULNERABILITIES
  • 7. Base Image Your added layers Your code & code dependencies 1 2 3 Configuration 4 A SYSTEM FOR CLEANING UP CONTAINER VULNERABILITIES
  • 8. FIXING CONTAINERS IS ALSO NOT LIKE FIXING VMS Did I add something with an issue… …or did I inherit this problem? The answer changes how we think about a “fix”
  • 9. Base Image Your added layers Your code & code dependencies 1 2 3 Configuration 4 A SYSTEM FOR CLEANING UP CONTAINER VULNERABILITIES
  • 10. PICKING A BASE IMAGE ISN’T AS SIMPLE AS IT SEEMS ruby 850 MB 414 dependencies 257 vulnerabilities 35 high severity ruby:3-slim 157 MB 107 dependencies 60 vulnerabilities 10 high severity There are ~700 tags listed in Docker Hub’s official ruby repo… ...which one is “best”?
  • 11. BASE IMAGE BEST PRACTICES Generic is not what you want! • What framework version are you coding against? Do these containers match? Will they match tomorrow? • Generally: good for playing around, but don’t use for ”real” work But -slim isn’t automatically the right choice • Vulns go away! 🥳 • BUT you “get to” manage all the build dependencies 😒 docker pull [ruby | python | ubuntu...] RUN apt-get update && apt-get install -y build-essential patch ruby-dev zlib1g-dev liblzma-dev libpq-dev libsqlite3-dev probably ^
  • 12. MULTI-STAGE TO THE RESCUE!!! FROM python:3.8-buster as builder . . . FROM python:3.8-buster-slim COPY –from=builder <app stuff> .
  • 13. PICKING A BASE IMAGE ISN’T AS SIMPLE AS IT SEEMS ruby 850 MB 414 dependencies 257 vulnerabilities 35 high severity ruby:3-slim 157 MB 107 dependencies 60 vulnerabilities 10 high severity ruby:alpine 60 MB 36 dependencies 1 vulnerabilities 0 high severity
  • 14. SO WHY NOT ALPINE FOR ALL THE THINGS?!? • Uses musl instead of gnu/libc • Uses different packages, different package manager • They handle security a little differently https://pythonspeed.com/articles/alpine-docker-python/
  • 15. GENERAL RECOMMENDATIONS General “make life easier” things: • A little bit of Sysadmin knowledge is unavoidable - pick an OS distribution and use it for everything • Pin to versioned images (at least Major, probably minor) Getting rid of vulnerabilities • Learn & love multi-stage builds! • Let Docker / Red Hat / VMware (Bitnami)… do the heavy lifting! • Rebuild often (clear your cache or use --no-cache) • Move your pins every once in a while 📌 Zero vulnerabilities in a container is almost impossible
  • 16. WE HAVE A BUNCH OF TEAMS USING CONTAINERS, IS THERE A GOOD PROCESS WE CAN ALL USE?
  • 17. Using base images FROM ubuntu:latest Standing on the shoulders of software giants It’s common with container images to start building on top of an existing base image that already has software you want. This might be an operating system like ubuntu, alpine or debian or it could be a language like python, ruby, node or really anything else. OK, technically often a parent image but hey. Libraries and underlying software provided by someone else Your software
  • 18. Distinct responsibilities Hardening, common configuration Your organization might have some common hardening or configuration changes or maybe metadata it wants to apply to all images in use by other teams. This is often intended to be common for all images used. Maybe you have myorg/base Libraries and underlying software provided by someone else Hardening, common configuration Common software Your application
  • 19. Distinct responsibilities Common software Some organizations provide a layer of common software or middleware. This might be language or framework specific, say a separate image for Java (myorg/java) and another for Python (myorg/python). Libraries and underlying software provided by someone else Hardening, common configuration Common software Your application
  • 20. Distinct responsibilities Your application Finally the specifics of your application, whether in source or binary form. And metadata specific to the application. Libraries and underlying software provided by someone else Hardening, common configuration Common software Your application
  • 21. Can you fix vulnerabilities once? Base image Scale vulnerability management When considering container vulnerabilities, you want to be able to reason about vulnerabilities in images you’re running, but also understand the overlap and source of those vulnerabilities. Can you address a vulnerability once, and have it resolved everywhere?
  • 22. Teams and responsibility A worked example
  • 23. Organizing into teams Libraries and underlying software provided by someone else Hardening, common configuration Common software Your application Libraries and underlying software provided by someone else Hardening, common configuration Common software Your application Libraries and underlying software provided by someone else Hardening, common configuration Common software Your application One team to rule them all This could be the case when teams are completely independent, or when you have one central image team. A base image team A team which provides a standard set of approved base images for application teams to consume. Separate base/security teams Larger organizations might have teams with more distinct responsibilities, potentially with even more layers.
  • 24. Pros and cons One team to rule them all PROS Simple to understand responsibilities. CONS Potential for chaos if every team can do their own thing. One central team for ALL images likely to become a bottleneck. A base image team PROS Able to build strong domain expertise in the center, ideally fix/triage issues once. CONS Needs some level of governance in order to ensure applications teams benefit from central expertise. Separate base/security teams PROS Same as having a base image team, with the added advantage of deeper specialisms. CONS Coordination between additional teams can slow down the process.
  • 25. Start with your own base image $ cat base/Dockerfile FROM python:3.6.0-slim RUN apt-get update && apt-get install -y <all our critical hardening pkgs> $ docker build -t myorg/base -f base/Dockerfile
  • 26. Establish a baseline What can downstream consumers ignore? $ <container tool> --test myorg/base ... Introduced by your base image (python:3.6.0-slim) Fixed in: 5.28.1-6+deb10u1 ✗ High severity vulnerability found in gnutls28/libgnutls30 Description: Out-of-bounds Write Info: https://snyk.io/vuln/SNYK-DEBIAN10-GNUTLS28-609778 Introduced through: gnutls28/libgnutls30@3.6.7-4+deb10u4, apt@1.8.2.1 From: gnutls28/libgnutls30@3.6.7-4+deb10u4 From: apt@1.8.2.1 > gnutls28/libgnutls30@3.6.7-4+deb10u4 Introduced by your base image (python:3.6.0-slim) Tested 111 dependencies for known issues, found 178 issues.
  • 27. Watch out for new vulnerabilities Generally, “fresh” images on Hub, RHT, etc have no FIXABLE vulns • Your baseline establishes the things you can ignore • But things get fixed… • …and things get broken… • Rebuild & set a new baseline often!
  • 28. A middleware image $ cat middleware/Dockerfile FROM myorg/base RUN apt-get update && apt-get install -y gunicorn sqlite3 && rm -rf /var/lib/apt/lists/ $ docker build -t myorg/middleware -f middleware/Dockerfile
  • 29. The sum of all vulnerabilities $ <container tool> test myorg/middleware ... Tested 127 dependencies for known issues, found 180 issues. Vulnerabilities from the base image and the new instructions But a different team is responsible for some of these, so let’s reason about those separately.
  • 30. Where did the issue come from? $ <container tool> test myorg/middleware +------------------------------------------------------------------------------------------------------------------------------------------------------+ | Found 180 unique vulnerabilities for myorg/middleware | +----------------------------------+---------------+------------------+------------------------------------+-------------------+-----------------------+ | Package | Severity | ID | Issue | Installed | Fixed in | +----------------------------------+---------------+------------------+------------------------------------+-------------------+-----------------------+ | ncurses/libncurses5 | HIGH | CVE-2017-10684 | Out-of-Bounds | 5.9+20140913-1+b1 | 5.9+20140913-1+deb8u1 | | ncurses/libncurses5 | HIGH | CVE-2017-10685 | Improper Input Validation | 5.9+20140913-1+b1 | 5.9+20140913-1+deb8u1 | | sqlite3/libsqlite3-0 | HIGH | CVE-2020-9794 | Out-of-bounds Read | 3.8.7.1-1+deb8u6 | | | sqlite3/libsqlite3-0 | HIGH | CVE-2019-8457 | Out-of-bounds Read | 3.8.7.1-1+deb8u6 | | | ncurses/libncurses5 | MEDIUM | CVE-2017-16879 | Out-of-Bounds | 5.9+20140913-1+b1 | 5.9+20140913-1+deb8u3 | | ncurses/libncurses5 | MEDIUM | CVE-2017-13729 | Out-of-Bounds | 5.9+20140913-1+b1 | 5.9+20140913-1+deb8u1 | ... +------------------------------------------------------------------------------------------------------------------------------------------------------+ | Base image vulnerabilities from myorg/base | +---------------------------+-------------+------------------+--------------------------------------+----------------------+---------------------------+ | Package | Severity | ID | Issue | Installed | Fixed in | +---------------------------+-------------+------------------+--------------------------------------+----------------------+---------------------------+ | apt/libapt-pkg4.12 | HIGH | CVE-2019-3462 | Arbitrary Code Injection | 1.0.9.8.4 | 1.0.9.8.5 | | bzip2/libbz2-1.0 | HIGH | CVE-2019-12900 | Out-of-bounds Write | 1.0.6-7+b3 | 1.0.6-7+deb8u1 | | glibc/libc-bin | HIGH | CVE-2018-1000001 | Out-of-Bounds | 2.19-18+deb8u7 | | | glibc/libc-bin | HIGH | CVE-2014-9761 | Out-of-Bounds | 2.19-18+deb8u7 | | Middleware team Base image team There are really only 2 new vulns in middleware
  • 31. Ignore what you can, but make sure there’s an audit trail!
  • 32. Your application images $ cat app/Dockerfile FROM myorge/middleware EXPOSE 8080 WORKDIR /app ADD app.py . CMD ["gunicorn", "-w", "4", "app:app"] $ docker build -t myorg/app -f app/Dockerfile
  • 33. Visualising ownership $ <container tool> test myorg/app +-----------------------------------------------------------------------------------------+ | Found 180 unique vulnerabilities for myorg/app | +--------------+--------------+--------------+--------------+--------------+--------------+ | Package | Severity | ID | Issue | Installed | Fixed in | +--------------+--------------+--------------+--------------+--------------+--------------+ +------------------------------------------------------------------------------------------------------------------------------------------------------+ | Base image vulnerabilities from myorg/middleware | +----------------------------------+--------------+------------------+------------------------------+----------------------+---------------------------+ | Package | Severity | ID | Issue | Installed | Fixed in | +----------------------------------+--------------+------------------+------------------------------+----------------------+---------------------------+ | apt/libapt-pkg4.12 | HIGH | CVE-2019-3462 | Arbitrary Code Injection | 1.0.9.8.4 | 1.0.9.8.5 | | bzip2/libbz2-1.0 | HIGH | CVE-2019-12900 | Out-of-bounds Write | 1.0.6-7+b3 | 1.0.6-7+deb8u1 | | glibc/libc-bin | HIGH | CVE-2018-1000001 | Out-of-Bounds | 2.19-18+deb8u7 | | ... Middleware team App team 🎉 🍻
  • 34. Conclusions If all you remember is...
  • 35. Observe How are your teams using base images today?
  • 36. Orient Who actually fixes vulnerabilities? Do all teams bear the burden of fixing the same issues?
  • 37. Decide How can you shift the responsibilities of teams to make base image management easier?
  • 38. Act Put in place the automation to scale.
  • 39. Thanks for listening Example app for the multi-team builds: https://github.com/garethr/snykt @ericsmalling