Skip to main content

Checking Application Containers for Vulnerabilities

Product manufacturers and application suppliers can check the containers they ship on their own build machines. Docker Buildx generates a software bill of materials (SBOM) for the application image. cve-bin-tool matches the listed components and versions against known vulnerabilities and produces a report for the application maintainer to review.

1. Generate an SBOM with Docker Buildx​

This example uses application version 1.0.0 for linux/arm64. From the directory containing the application's Dockerfile, choose a directory for the SBOM and scan reports. If you already have an SPDX JSON SBOM for the image you shipped, go directly to section 2.

OUT=../myapp-1.0.0-linux-arm64
mkdir -p "$OUT"

When building your own application image, add --sbom=true to the build parameters for the release. This example uses your existing builder and exports the container filesystem and the SBOM to a local directory. Docker Buildx SBOM documentation

docker buildx build \
--platform linux/arm64 \
--sbom=true \
--output "type=local,dest=$OUT/rootfs" .

Extract the SPDX document from the Buildx output and save it as app.spdx.json. The following jq command checks that at least one component has both a name and a version.

jq -e '(.predicate // .) | select(.spdxVersion and any(.packages[]?; (.name // "") != "" and (.versionInfo // "") != ""))' \
"$OUT/rootfs/sbom.spdx.json" > "$OUT/app.spdx.json"

If a multi-platform image in your registry already has an SBOM, use the imagetools inspect command included with Docker Buildx to read the SBOM for the architecture you ship. Replace the example reference with your release image, preferably using the digest recorded at release. Then continue to section 2. Inspecting SBOMs by platform

IMAGE=registry.example.com/product/myapp:1.0.0
docker buildx imagetools inspect "$IMAGE" \
--format '{{ json (index .SBOM "linux/arm64").SPDX }}' > "$OUT/app.spdx.json"

2. Scan the SBOM with cve-bin-tool​

The first time you use the tool, install it in a dedicated Python 3 virtual environment.

python3 -m venv ../cve-scan-venv
../cve-scan-venv/bin/python -m pip install cve-bin-tool

Run the scan from the same shell. This example reads $OUT/app.spdx.json and writes a dated CSV report. If you already have the SBOM for the released image, set OUT to its directory and point --sbom-file at the actual .spdx.json file. The tool downloads public vulnerability data on its first run. On subsequent runs, its default interval for checking database updates is one day. CVE Binary Tool SBOM scanning guide · Vulnerability database updates

../cve-scan-venv/bin/cve-bin-tool \
--sbom spdx --sbom-file "$OUT/app.spdx.json" \
--format csv --output-file "$OUT/cve-$(date -u +%F).csv"

3. Review Findings and Track Released Images​

  • Check what the SBOM covers. Confirm that the application's critical components, third-party SDKs, and statically linked libraries appear with their versions. If a component is missing, request its SBOM from the supplier and assess it separately. An empty report means the scan found no known vulnerabilities matching the components it identified.
  • Review each match. Use the component name, version, and CVE identifier to find the distribution or supplier advisory. Check whether a fix has been backported and whether the affected functionality is enabled in the product. If the product is affected, update the dependency or base image, rebuild and rescan the image, and record which application release contains the fix.
  • Rescan supported releases. Keep the application version, target architecture, digest (sha256) of the image you shipped, SBOM, and scan report together. When the vulnerability database changes, run the scan in section 2 again using the same SBOM. Save a new SBOM whenever the image changes.

4. Resolve an SBOM Attestation Error​

If the build in section 1 reports Attestation is not supported for the docker driver, Docker Engine is usually using its classic image store. The default builder can generate SBOMs when it uses the containerd image store. You can also use docker buildx ls to find an existing builder with the docker-container driver, then add --builder BUILDER_NAME to the original build command. Docker containerd image store

If you need to create a builder, run the following command once. Then add --builder naos-sbom after docker buildx build in section 1.

docker buildx create --name naos-sbom --driver docker-container