Check my containers for security issues.. Trivy can help


Userlevel 7
Badge +22

I posted a couple of weeks ago in the general section of the Hub about how I leveraged Keycloack to setup authentication into my Kasten backup setup. However, what if my Keycloak is not secure. First off we would want to check if there are any vulnerabilities with the containers. For that I will use Trivy.

The installation instructions can be found here https://aquasecurity.github.io/trivy/v0.18.3/installation/ 

I am using ubuntu so I did the following:

sudo apt-get install wget apt-transport-https gnupg lsb-release
wget -qO - https://aquasecurity.github.io/trivy-repo/deb/public.key | sudo apt-key add -
echo deb https://aquasecurity.github.io/trivy-repo/deb $(lsb_release -sc) main | sudo tee -a /etc/apt/sources.list.d/trivy.list
sudo apt-get update
sudo apt-get install trivy

Now I need to get the name of my container, I am using alias k=kubectl so only need to type k get and then can just type po instead of pods:

k get po

Next what is the exact image and version:

k get po -oyaml |grep -w image

Lets plug this into trivy and see what comes out, first for CRITICAL then for HIGH vulnerabilities:

trivy image quay.io/keycloak/keycloak:14.0.0 |grep -w CRITICAL

Ok, this could be a problem there are 4 Critical vulnerabilities

ober@kube1:~$ trivy image quay.io/keycloak/keycloak:14.0.0 |grep -w HIGH

3 High vulnerabilities as well

 

You can also filter the output of the command directly:

 

trivy image --severity HIGH,CRITICAL image-name:tag

 

Lets head over to the Keycloak website and check what is the current version:

Might be time to upgrade.


6 comments

Userlevel 7
Badge +10

This is great, Geoff - I’m going to try this later this week in my Kubernetes Klassroom (My own learning journey)!

Userlevel 7
Badge +22

This is great, Geoff - I’m going to try this later this week in my Kubernetes Klassroom (My own learning journey)!

I am studying intensely for the CKS so I have now started dreaming about this stuff :). Might be time for me to visit a psychotherapist.. Or kubers anonymous. “Hi my name is Geoff, I am a Kubeaholic!!”

Userlevel 7
Badge +22

By the way you can do this for any image. Just scan the default nginx will pull stuff up as well 

trivy image nginx

 

Userlevel 7
Badge +20

Excellent article.  Will add it to my list for when I start playing with Kubernetes. :smiley:

Userlevel 7
Badge +4

@Geoff Burke : Good one !

Userlevel 7
Badge +17

Very interesting.  Thank you 😎👍🏼

Comment