brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: trivy image scans a container image for known flaws

Security
~/tips/tip-security-trivy-image-scan

trivy image example/app:1.2

Scans a container image and shows only serious vulnerabilities that already have a fix.

Most of my containers run images somebody else built, and I rarely know what is inside. Trivy can tell me.

trivy image scans an image. By default it looks for vulnerabilities and secrets; licences and misconfigurations are off unless you ask with --scanners.

trivy image example/app:1.2

On a popular image that prints a long list, mostly low-severity entries. Two flags make it readable. --severity takes a comma-separated list from UNKNOWN, LOW, MEDIUM, HIGH and CRITICAL, and shows all five by default. --ignore-unfixed shows only vulnerabilities that already have a fix.

trivy image --severity HIGH,CRITICAL --ignore-unfixed example/app:1.2

What remains is a list you can act on: a fixed version exists, so pulling a newer image or rebuilding may help. With --exit-code 1 the command returns that exit code when it finds anything, so a script or CI job can stop on it.

A finding means the image contains a package with a known flaw. Whether your container can be attacked through it is another question, and a library the app never loads still shows up. An empty list only says nothing known turned up at that moment. I use the result to choose between two images or to decide when to update.

Further reading: Trivy: container image scanning, trivy image CLI reference

More Security tips tcpdump -nn -r capture.pcap port 53 mkcert -install Strict-Transport-Security: max-age=0 Referrer-Policy: strict-origin-when-cross-origin wp super-admin list All Security tips (79) All topics

Link