Skip to main content

Towards more secure containerized workloads –Part 2

Yesterday I introduced the concept of an SBOM, a Software Bill Of Materials. An SBOM lists all the components that make up the software , or were used to build it.

I showed you how to use the docker sbom command to generate such an SBOM for your container images. Today I want to show you how you can use this generated SBOM to check for vulnerabilities. The tool we want to use for this is Grype.

Install Grype on Windows

Out of the box, Grype is only built for Linux and MacOS.  As I’m a Windows user, probably the easiest way to get Grype running on your system is through WSL(Windows Subsystem for Linux).

Open up a terminal to your installed Linux Distribution(I typically use Windows Terminal), or if you didn’t have a Linux distribution installed yet, install a distribution of your choice:

wsl --install -d Ubuntu
Downloading: Ubuntu
Installing: Ubuntu
Ubuntu has been installed.
Launching Ubuntu...

After the installation has completed, a new menu item is added that opens a terminal window to your installed distribution and an extra entry is added to Windows Terminal(if installed on your machine).

Now we can download and install Grype using the following command:

sudo curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /mnt/c/dev/bin/grype/

This is how the output looked like on my machine:

bawu@MININT-9ABLAQJ:~$ sudo curl -sSfL https://raw.githubusercontent.com/anchore/grype/main/install.sh | sh -s -- -b /mnt/c/dev/bin/grype
[info] checking github for the current release tag
[info] fetching release script for tag='v0.35.0'
[info] checking github for the current release tag
[info] using release tag='v0.35.0' version='0.35.0' os='linux' arch='amd64'
[info] installed /mnt/c/dev/bin/grype

Check for vulnerabilities

Now that we have succesfully installed Grype, we can execute it using the following command:

grype sbom:<locationofyoursbomfile>

Here is an example where I had the sbom generated on my c: drive under c:\users\bawu

bawu@MININT-9ABLAQJ:~$ grype sbom:/mnt/c/users/bawu/sbom.json
Vulnerability DB        [updated]
  Scanned image           [75 vulnerabilities]

NAME          INSTALLED   FIXED-IN    TYPE  VULNERABILITY   SEVERITY
busybox       1.33.1-r3   1.33.1-r5   apk   CVE-2021-42375  Medium
busybox       1.33.1-r3   1.33.1-r7   apk   CVE-2022-28391  Critical
busybox       1.33.1-r3   1.33.1-r6   apk   CVE-2021-42380  High
busybox       1.33.1-r3   1.33.1-r6   apk   CVE-2021-42381  High
busybox       1.33.1-r3   1.33.1-r6   apk   CVE-2021-42382  High
busybox       1.33.1-r3   1.33.1-r6   apk   CVE-2021-42383  High
busybox       1.33.1-r3   1.33.1-r6   apk   CVE-2021-42384  High
busybox       1.33.1-r3   1.33.1-r6   apk   CVE-2021-42378  High
busybox       1.33.1-r3   1.33.1-r6   apk   CVE-2021-42386  High
busybox       1.33.1-r3   1.33.1-r4   apk   CVE-2021-42374  Medium
busybox       1.33.1-r3   1.33.1-r6   apk   CVE-2021-42379  High
busybox       1.33.1-r3   1.33.1-r6   apk   CVE-2021-42385  High
expat         2.4.1-r0    2.4.3-r0    apk   CVE-2022-22822  Critical
expat         2.4.1-r0    2.4.5-r0    apk   CVE-2022-25314  High
expat         2.4.1-r0    2.4.3-r0    apk   CVE-2022-22824  Critical
expat         2.4.1-r0    2.4.4-r0    apk   CVE-2022-23990  Critical
expat         2.4.1-r0    2.4.3-r0    apk   CVE-2022-22826  High
expat         2.4.1-r0    2.4.5-r0    apk   CVE-2022-25313  Medium
expat         2.4.1-r0    2.4.3-r0    apk   CVE-2022-22825  High
expat         2.4.1-r0    2.4.4-r0    apk   CVE-2022-23852  Critical
expat         2.4.1-r0    2.4.3-r0    apk   CVE-2022-22827  High
expat         2.4.1-r0    2.4.3-r0    apk   CVE-2021-45960  High
expat         2.4.1-r0    2.4.3-r0    apk   CVE-2021-46143  High
expat         2.4.1-r0    2.4.3-r0    apk   CVE-2022-22823  Critical
expat         2.4.1-r0    2.4.5-r0    apk   CVE-2022-25315  Critical
expat         2.4.1-r0    2.4.5-r0    apk   CVE-2022-25235  Critical
expat         2.4.1-r0    2.4.5-r0    apk   CVE-2022-25236  Critical
libcrypto1.1  1.1.1l-r0   1.1.1n-r0   apk   CVE-2022-0778   High
libcrypto1.1  1.1.1l-r0               apk   CVE-2021-4160   Medium
libretls      3.3.3p1-r2  3.3.3p1-r3  apk   CVE-2022-0778   High
libssl1.1     1.1.1l-r0               apk   CVE-2021-4160   Medium
libssl1.1     1.1.1l-r0   1.1.1n-r0   apk   CVE-2022-0778   High
ssl_client    1.33.1-r3   1.33.1-r5   apk   CVE-2021-42375  Medium
ssl_client    1.33.1-r3   1.33.1-r6   apk   CVE-2021-42379  High
ssl_client    1.33.1-r3   1.33.1-r6   apk   CVE-2021-42381  High
ssl_client    1.33.1-r3   1.33.1-r7   apk   CVE-2022-28391  Critical
ssl_client    1.33.1-r3   1.33.1-r6   apk   CVE-2021-42378  High
ssl_client    1.33.1-r3   1.33.1-r6   apk   CVE-2021-42385  High
ssl_client    1.33.1-r3   1.33.1-r6   apk   CVE-2021-42386  High
ssl_client    1.33.1-r3   1.33.1-r6   apk   CVE-2021-42380  High
ssl_client    1.33.1-r3   1.33.1-r6   apk   CVE-2021-42383  High
ssl_client    1.33.1-r3   1.33.1-r6   apk   CVE-2021-42382  High
ssl_client    1.33.1-r3   1.33.1-r6   apk   CVE-2021-42384  High
ssl_client    1.33.1-r3   1.33.1-r4   apk   CVE-2021-42374  Medium
xz-libs       5.2.5-r0    5.2.5-r1    apk   CVE-2022-1271   Unknown
zlib          1.2.11-r3   1.2.12-r0   apk   CVE-2018-25032  High

Looks like we have some work to do…

Popular posts from this blog

Podman– Command execution failed with exit code 125

After updating WSL on one of the developer machines, Podman failed to work. When we took a look through Podman Desktop, we noticed that Podman had stopped running and returned the following error message: Error: Command execution failed with exit code 125 Here are the steps we tried to fix the issue: We started by running podman info to get some extra details on what could be wrong: >podman info OS: windows/amd64 provider: wsl version: 5.3.1 Cannot connect to Podman. Please verify your connection to the Linux system using `podman system connection list`, or try `podman machine init` and `podman machine start` to manage a new Linux VM Error: unable to connect to Podman socket: failed to connect: dial tcp 127.0.0.1:2655: connectex: No connection could be made because the target machine actively refused it. That makes sense as the podman VM was not running. Let’s check the VM: >podman machine list NAME         ...

Cache stampede: when our cache turned against us

While investigating some performance issues, we ran into an ASP.NET Core API that cached a fairly expensive aggregation query for 60 seconds. Under normal load, that was fine: one request rebuilds the cache, everyone else reads from it. Under peak load, dozens of requests would arrive in that same expiry window, all see a cache miss, and all fire the same expensive query in parallel. The database didn't like that. That was the moment when our caching layer stopped helping and started hurting. A burst of requests comes in at the same time, all miss the cache, and all go hammer the database or the downstream API at once. That's a cache stampede . The cache was supposed to protect our backend, and for a few hundred milliseconds it did the opposite. Why this happens IMemoryCache.GetOrCreate (and its async sibling) looks like it protects you, but it doesn't add any locking on its own. Look at the naive version: public async Task<Report> GetReportAsync(string key) ...

A complex system designed from scratch never works

A few years ago, I worked as an architect on a big mainframe rewrite. I still count it as one of my failures. Not because the technology was wrong, but because I couldn't convince the management team to simplify the approach. Years later, the organization is still struggling to get the new system up and running. I left the project at the time, because I couldn't put my name behind an approach that would take very long and cost a lot of money without a working system to show for it along the way. Gall’s Law That memory keeps coming back to me, because it's a textbook case of Gall's Law playing out in real life. Gall's Law , from John Gall's Systemantics , states it plainly: A complex system that works is invariably found to have evolved from a simple system that worked. A complex system designed from scratch never works, and it cannot be patched to make it work. You have to start over with a simple system that works. What does that mean in practice,...