Are we affected?
A software bill of materials, an SBOM, is a list of every component inside a piece of software. On the morning a serious flaw is announced, it answers the first question in minutes: which of our systems hold it?
Without one, teams spend days asking every owner to check by hand.
By the end of this lesson
Note
I can use SBOMs to find which systems hold an affected component.
Key words
| Word | What it means |
|---|---|
| SBOM | a list of the components in a piece of software |
| Component | one package or library, with its version |
| CycloneDX | an open SBOM format from OWASP |
| Triage | deciding what to deal with first |
| VEX | a statement of whether a product is affected by a CVE |
The cells students fill in are left blank in this preview.
Starter
Have a go
Starter
4 questionsAn SBOM lists every component
An SBOM names each component with its version and a package URL that says where it came from. Two open formats are common: CycloneDX, from OWASP, and SPDX, from the Linux Foundation.
Trivy writes one with --format cyclonedx. Keep the SBOM of every build, and you can search everything you run without scanning it again.
Write the old image's SBOM
docker exec scanner trivy image --input /targets/web-1.25.3.tar --format cyclonedx -o /work/reports/web.cdx.jsonShown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the shop's SBOM
docker exec scanner trivy fs /targets/shop --format cyclonedx -o /work/reports/shop.cdx.jsonShown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the Java service's SBOM
docker exec scanner trivy fs /targets/reports --format cyclonedx -o /work/reports/reports.cdx.jsonShown here, not run. Press Start lab to type it into your own lab’s terminal.
How many components does the image hold?
docker exec tools python3 -c "import json; b = json.load(open('/work/reports/web.cdx.json')); print(b['bomFormat'], b['specVersion'], len(b['components']))"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Check
Have a go
Check
3 questionsSearch the SBOMs, not the servers
Imagine the morning Log4Shell was announced. You search every SBOM for log4j and get an answer for every system at once.
An SBOM can also be scanned again later with trivy sbom. A newer database then finds flaws published after the build, with no need for the image or the source.
Try it: which system has a component?
bom = {
"web": [["libssl3", "3.1.4-r5"], ["libexpat", "2.5.0-r1"], ["nginx", "1.25.3-r1"]],
"reports": [["log4j-core", "2.14.1"], ["jackson-databind", "2.13.2"]],
"shop": [["Flask", "2.2.2"], ["urllib3", "1.26.12"]],
}
wanted = "log4j-core"
for system in bom:
for component in bom[system]:
if component[0] == wanted:
print(system, "has", component[0], component[1])
# Change wanted to "urllib3". Which system has it now?
Make a free account to save your work and track your progress.
Write the script that searches SBOMs
docker exec tools sh -c "printf '%s\n' 'import glob' 'import json' 'import sys' '' 'name = sys.argv[1]' 'for path in sorted(glob.glob(\"/work/reports/*.cdx.json\")):' ' with open(path) as f:' ' bom = json.load(f)' ' hits = 0' ' for c in bom.get(\"components\", []):' ' if name in c[\"name\"]:' ' hits = hits + 1' ' print(path.split(\"/\")[-1], c[\"name\"], c.get(\"version\"))' ' if hits == 0:' ' print(path.split(\"/\")[-1], \"nothing called\", name)' > steps/whohas.py"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Which SBOMs hold log4j?
docker exec tools python3 steps/whohas.py log4jShown here, not run. Press Start lab to type it into your own lab’s terminal.
What whohas.py printed
| SBOM | Component | Version |
|---|---|---|
| reports.cdx.json | log4j-api | 2.14.1 |
| reports.cdx.json | log4j-core | 2.14.1 |
| shop.cdx.json | nothing called log4j | - |
| web.cdx.json | nothing called log4j | - |
The cells students fill in are left blank in this preview.
Your turn: search for ssl
docker exec tools python3 steps/whohas.py sslShown here, not run. Press Start lab to type it into your own lab’s terminal.
Scan the Java SBOM, not the service
docker exec scanner trivy sbom /work/reports/reports.cdx.json --severity CRITICALShown here, not run. Press Start lab to type it into your own lab’s terminal.
Check
Have a go
Check
3 questionsVEX records a judgement about one CVE
Not every finding matters. VEX, Vulnerability Exploitability eXchange, lets a supplier or team state that a product is not affected, affected, fixed or still under investigation, with a reason.
Here the team claims curl's CVE-2024-2398, an HTTP/2 client flaw, does not reach nginx, which never calls curl. Trivy then hides those two findings and says why.
Write the team's VEX statement
docker exec tools sh -c "printf '%s\n' '{\"@context\": \"https://openvex.dev/ns/v0.2.0\", \"@id\": \"https://college.example/vex/web-1\",' ' \"author\": \"College IT\", \"timestamp\": \"2026-11-23T09:00:00Z\", \"version\": 1,' ' \"statements\": [{\"vulnerability\": {\"name\": \"CVE-2024-2398\"},' ' \"products\": [{\"@id\": \"pkg:apk/alpine/curl\"}, {\"@id\": \"pkg:apk/alpine/libcurl\"}],' ' \"status\": \"not_affected\", \"justification\": \"vulnerable_code_not_in_execute_path\"}]}' > /work/web.vex.json"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Scan again with the VEX statement
docker exec scanner trivy image --input /targets/web-1.25.3.tar --vex /work/web.vex.json --show-suppressedShown here, not run. Press Start lab to type it into your own lab’s terminal.
A common mistake
Warning
Many people think a VEX statement removes the flaw. The package is still installed; the statement only records why it does not matter now. It needs evidence and a review date, because a later change could make it wrong.
Check
Have a go
Check
3 questionsAssignment: who is affected?
Answer "are we affected?" from SBOMs. boms is a dictionary from a system's name to its SBOM, a dictionary whose components list holds dictionaries with name and version.
version_parts(text) turns "2.14.1" into [2, 14, 1]. is_older(version, fixed) is True when the version is below the fixed one, comparing numbers, not text. affected_systems(boms, name, fixed) returns, in the order of boms, the systems holding that component at a version older than the fixed one.
def version_parts(text):
return []
def is_older(version, fixed):
return False
def affected_systems(boms, name, fixed):
return []
Make a free account to save your work and track your progress.
Exit quiz
Have a go