Skip to content

SBOM and Dependency Analysis

github-actions[bot] edited this page Nov 29, 2026 · 1 revision

Last reviewed: 2026-11-28 (Syft and Grype behaviour observed in supply-chain lab CI run 46226817429 on synthetic fixtures; other statements are from upstream documentation)

Prerequisites: Container security ยท Software supply-chain assessment ยท Glossary.

๐ŸŽฏ Purpose

Explain how to produce a Software Bill of Materials (SBOM), check that it is usable, match it against vulnerability data, and record what the match does and does not prove.

โš™๏ธ Function

Covers the two common SBOM formats (SPDX and CycloneDX), generating them with Syft, matching them with Grype, the limits of version-based matching, reachability analysis, and Vulnerability Exploitability eXchange (VEX) statements.

๐Ÿ† Goal

Let a reader generate a reproducible SBOM for a pinned artifact, gate a pipeline on vulnerability severity without mistaking a tool error for a clean scan, and document exceptions with VEX instead of silent ignores.

๐Ÿ“‹ When To Use

  • Building or reviewing an SBOM step in CI
  • Triaging a vulnerability scan of a container image or source tree
  • Deciding whether a reported CVE needs a fix, a VEX statement, or more analysis

๐Ÿ“‹ Table Of Contents


SBOM Formats

An SBOM is an inventory of the components in a piece of software. The NTIA report The Minimum Elements For a Software Bill of Materials (July 2021) is the commonly cited baseline for what one should contain.

Format Maintainer What Syft 1.57.2 emits
SPDX Linux Foundation SPDX project Observed in the lab: spdx-json gives spdxVersion: SPDX-2.3 with creator Tool: syft-1.57.2. Syft's source (syft/format/internal/spdxutil/versions.go at v1.57.2) also lists spdx-json@2.2 and spdx-json@3.0, which the lab did not run
CycloneDX OWASP CycloneDX Observed in the lab: cyclonedx-json gives specVersion 1.7. Syft's source also lists older versions such as cyclonedx-json@1.5, which the lab did not run

The current SPDX specification is 3.0.1. Syft's default SPDX output is 2.3; its source has an SPDX 3.0 JSON encoder (spdx-json@3.0), which this repository has not run or validated. Check which version your consumers (dependency-tracking platforms, regulators, customers) accept before you choose, and pin the format version with the @ suffix so a tool upgrade does not change it under you.

Package URLs (purl) are the identifiers that make matching work. In the lab, the Python fixture produced pkg:pypi/pyyaml@5.3.1, and the OCI image fixture produced pkg:deb/debian/zlib1g@1%3A1.2.13.dfsg-1?arch=amd64&distro=debian-12&upstream=zlib.

Generating SBOMs With Syft

Install A Pinned Release

Download the release asset and check it against the published checksums file. This form ran successfully during research for this guide:

curl -sSfLO https://github.com/anchore/syft/releases/download/v1.57.2/syft_1.57.2_linux_amd64.tar.gz \
     -O https://github.com/anchore/syft/releases/download/v1.57.2/syft_1.57.2_checksums.txt
sha256sum --ignore-missing -c syft_1.57.2_checksums.txt
# syft_1.57.2_linux_amd64.tar.gz: OK

The checksums file comes from the same place as the tarball, so it only detects corruption. Hard-coding the digest you reviewed holds up better against a tampered release page:

echo "ad92bd3ec1b94a3df01d4d0aec199afa9c42b72e86da436ff5f837914d32706b  syft_1.57.2_linux_amd64.tar.gz" | sha256sum -c

Grype follows the same pattern (grype_0.122.1_checksums.txt; linux amd64 tarball SHA-256 f1ba7e2917ee1395618de20a98da0aa7c0fb1788927797651047c50502a37538). Both projects also publish a Sigstore bundle for the checksums file (*_checksums.txt.sigstore.json). Verifying it needs the public Sigstore trust root, and this repository has not run that check.

Sources

syft scan --help lists these source schemes: docker:, podman:, registry:, docker-archive: (a docker save tarball), oci-archive:, oci-dir:, singularity:, oci-model-registry: (an OCI model artifact from a registry), dir: and file: (from cmd/syft/internal/commands/scan.go at v1.57.2). The lab exercised only dir: and oci-archive:.

# Source tree: write SPDX and CycloneDX in one pass (lab case sbom-dir-vulnerable, rc 0)
syft scan dir:fixtures/python-vulnerable -q \
  -o spdx-json=out/python-vulnerable.spdx.json \
  -o cyclonedx-json=out/python-vulnerable.cdx.json

# OCI image archive (lab case sbom-oci-archive, rc 0)
syft scan oci-archive:out/lab-image.oci.tar -q \
  -o spdx-json=out/lab-image.spdx.json \
  -o cyclonedx-json=out/lab-image.cdx.json

For an image, the CycloneDX metadata.component was type container with the manifest digest as its version. Record that digest: it ties the SBOM to one exact image.

Warning

Tar gotcha (observed): an OCI archive whose first member is ./, which is what tar -C dir -cf x.tar . produces, is refused by Syft with potential path traversal attack with entry: "./" (exit 1, lab case negative-sbom-oci-dot-entry). The lab builds both archives in Python and did not run tar itself. An archive whose members are named without the ./ prefix (oci-layout, index.json, blobs/...) was accepted. The lab runs this case without -q because quiet mode hides the error text, so do not suppress output when debugging.

syft convert (marked experimental in its help text) converts between SPDX, CycloneDX and Syft JSON. Upstream documents data loss between formats in the format-conversion wiki page, so generate each format from the artifact when you can rather than converting.

Checking An SBOM Before You Trust It

An SBOM is evidence produced by a tool, not ground truth. Before you publish or gate on one:

  1. Bind it to the artifact. Record the image digest or source commit, and hash the SBOM file itself. A hash proves the SBOM has not changed since you recorded it. It says nothing about whether the SBOM is complete.
  2. Check the format version your consumer expects (spdxVersion, specVersion).
  3. Check for empty or missing ecosystems. During research, a bare package.json with no lockfile yielded no npm components. Scanners read lockfiles and installed-package databases; a manifest with version ranges may produce nothing, or a guess. Compare the component count with what you know is in the build.
  4. Validate against the schema. Both projects publish JSON schemas (CycloneDX, SPDX). This repository has not run a schema validator, so no specific tool is recommended here.
  5. Sign or attest it if others will rely on it. See Signing & provenance.

Vulnerability Matching With Grype

Grype matches packages from an image, directory or SBOM against its vulnerability database. Scanning the SBOM rather than the artifact again means the inventory you reviewed is the inventory that was matched.

# Lab case vuln-positive-pyyaml-5.3.1: rc 2, GHSA-8q59-q68h-6hv4 (Critical) reported
grype sbom:out/python-vulnerable.cdx.json -o json --fail-on critical

# Lab case vuln-negative-pyyaml-5.4.1: rc 0, no matches
grype sbom:out/python-patched.cdx.json -o json --fail-on critical

Exit Codes Are Part Of The Contract

Exit code Meaning Evidence
0 No match at or above the --fail-on threshold Observed in CI (vuln-negative-pyyaml-5.4.1)
1 Tool or database error, for example failed to load vulnerability db: database does not exist Observed in CI (negative-vuln-no-db)
2 A finding at or above the --fail-on severity Observed in CI (vuln-positive-pyyaml-5.3.1)

Important

A pipeline that treats "any non-zero means vulnerable" or "anything but 2 means clean" will misread a broken scan. Fail the job on exit 1 as an error, and keep the scanner output.

Other options from grype --help that matter for gating:

Option Effect (help text)
--only-fixed Ignore matches for vulnerabilities that are not fixed
--ignore-states Ignore matches with the listed fix states (fixed, not-fixed, unknown, wont-fix)
--vex A list of VEX documents to consider when producing results
--by-cve Orient results by CVE instead of the original vulnerability ID when possible
-o json, table, cyclonedx, cyclonedx-json, sarif, template

The Database Is An Input

Results depend on the database as much as on the SBOM. From grype config (v0.122.1): the cache defaults to ~/.cache/grype/db, updates come from https://grype.anchore.io/databases, auto-update is on, and a database older than max-allowed-built-age (120h) fails validation. Record grype db status -o json with every result. The lab's CI run used schema v6.1.10, built 2026-11-28T06:20:09Z. A rerun with a newer database can add or withdraw matches, so a scan result is a statement about one database build.

For reproducible or air-gapped runs, grype db import accepts a local archive or URL, and per its help text a ?checksum=sha256:... query parameter verifies it. The lab did not pin or import a database.

Limits Of Version Matching

A match means "a package with this name and version appears in an advisory's affected range". It does not mean:

  • The vulnerable code is present. Distributions backport fixes without changing the upstream version, and builds can exclude optional modules.
  • The vulnerable code runs. Many advisories cover one function in a large library.
  • The SBOM was complete. Vendored code, statically linked binaries and copied source often have no package metadata, so nothing is matched and nothing is reported.
  • No match means safe. An empty result covers only what was inventoried and what the database knew on that day.

Treat severity as the advisory's rating, not your risk. Prioritise with exploit data such as the CISA Known Exploited Vulnerabilities catalog and with exposure (is the service reachable, does it handle untrusted input).

Reachability Analysis

Reachability analysis asks whether your code can actually call the vulnerable function. It needs symbol-level advisory data and a call graph, so support is language-specific.

  • Go: govulncheck "reduces noise in your results by only surfacing vulnerabilities in functions that your code is actually calling" (README). It analyses source (govulncheck ./...) or a binary's symbol table, backed by the Go vulnerability database.
  • Other ecosystems: some commercial and open-source scanners offer reachability for specific languages. This repository has not evaluated them and makes no recommendation.

Honest limits of any reachability result:

  • Static call graphs miss reflection, dynamic dispatch, plugins, eval and code loaded at runtime. "Not reachable" is a lower-confidence claim than "reachable".
  • It answers "is the function called", not "can an attacker control the input". That is a separate judgement.
  • Advisory data often lacks the affected symbols, in which case the tool falls back to package-level matching.

Use reachability to order the work and to support a VEX not_affected statement. Do not use it to close a finding with no record.

VEX: Recording Exploitability Decisions

VEX lets a supplier state, per product and vulnerability, whether the product is affected. It replaces ad-hoc ignore files with a document that has an author, a timestamp and a reason. Formats include OpenVEX, CycloneDX VEX and CSAF VEX.

OpenVEX status values (from the OpenVEX specification):

Status Meaning
not_affected No remediation is required. MUST include a justification or an impact_statement
affected Action is recommended
fixed These product versions contain a fix
under_investigation Not yet known

not_affected justifications are fixed labels: component_not_present, vulnerable_code_not_present, vulnerable_code_not_in_execute_path, vulnerable_code_cannot_be_controlled_by_adversary and inline_mitigations_already_exist. The spec itself notes that the last two "could be difficult to prove conclusively".

Pass VEX documents to Grype with --vex <file> so suppressed matches are explained rather than hidden. --show-suppressed (table output only) shows them. This repository's lab did not exercise --vex.

Tip

Review VEX statements like code: a not_affected statement that nobody re-checks after a dependency upgrade becomes a false negative.


See also

Related Files


โฌ…๏ธ Back to Master Index | ๐ŸŽฏ Role Navigation | Legal Notice


๐Ÿ“„ Source: ContainerSecurity/sbom-and-dependency-analysis.md | โœ๏ธ Suggest an edit | โฌ…๏ธ Back to Container Security

Clone this wiki locally