Running and Reading an Authenticated Scan
Scan two lab containers from the network and with credentials, match a fixed advisory feed using each distribution's own version rules, reject a backport false positive, patch a host, verify the fix with a rescan and cross-check with Trivy.
Contentsand lesson path
On this page
- Goal and setup
- Step 1: Start the two targets
- Step 2: Look from the network
- Step 3: Match the banner against upstream versions
- Step 4: Read the package database with credentials
- Step 5: Compare versions the distribution's way
- Step 6: Patch one host and rescan
- Step 7: Finish the patch and verify closure
- Step 8 (optional): Cross-check with a real scanner
- Step 9: Clean up
- Troubleshooting
- Check your understanding
- Apply it
- Review prompt
Lessons of Vulnerability Management
- From Asset Inventory to Scan Coverage Concept · 20 min
- Running and Reading an Authenticated Scan Lab · 30 min
- Prioritising with CVSS, EPSS and KEV Worked example · 25 min
- Remediation Workflows, Exceptions and Verification Concept · 20 min
- Metrics That Show Exposure Going Down Worked example · 15 min
- Vulnerability Management Check Knowledge check · 8 questions
What you will learn
- Build an asset inventory and run authenticated vulnerability scans against a lab network, separating real findings from false positives.
01. Goal and setup
You will assess two targets in two ways and compare the results. The unauthenticated view works only through the network: it connects to ports, sends requests and reads the answers, such as a banner, the version string that a service announces. The authenticated view uses a credential to read the package database inside each target. Real tools do more: Nmap's version detection (-sV) matches the responses to a series of probes against a signature database, and Greenbone (OpenVAS) runs remote tests that can send crafted requests, plus "local security checks" after logging in with SSH, SMB, ESXi or SNMP credentials.
The targets are two containers: e30-se3-vm-deb from node:22-bookworm-slim (Debian 12, tested with 12.15) and e30-se3-vm-alp from alpine:3.20 (tested with 3.20.10). The "credential" is your permission to run docker exec, which gives the same view as a root SSH login. That is more than a scan needs: in production, give scan accounts only the privileges their checks need, and note that Docker socket access is equivalent to root on the host. Only scan targets you own.
You need: a Linux host with Docker (tested with 29.8.0), Python 3.10 or later, and network access for one package upgrade. Optional step 8 downloads Trivy 0.76.2 and its database, 1.7 GB unpacked in November 2026.
The advisory feed in step 3 is a fixed excerpt, copied on 16 November 2026 from the Debian security tracker and the Alpine secdb; a real scanner downloads its feed before each run.
vm-lab/
├── web.js step 1: the service inside the Debian target
├── targets.txt step 2: name and IP address of each target
├── unauth_scan.py step 2: network-only view of each target
├── advisories.json step 3: fixed advisory feed (snapshot, 16 Nov 2026)
├── match_banner.py step 3: banner versus upstream version ranges
├── collect.py step 4: authenticated package inventory
├── compare.py step 5: distro version comparison
├── test_compare.py step 5: comparator tests, including negative cases
├── match_auth.py step 5: inventory versus distro fixed versions
└── trivy_check.py step 8: summary of the real scanner's reports02. Step 1: Start the two targets
The Debian target runs a tiny web service on port 8080 that announces its glibc version in the Server header. No port is published to the host: step 2 connects to each container's own address on the Docker bridge network, like a scanner on the same segment. The Alpine target runs no service.
// A tiny web service that advertises the glibc version it runs on, the way many
// servers put library or product versions in their banner.
const http = require('http');
const glibc = process.report.getReport().header.glibcVersionRuntime;
http
.createServer((req, res) => {
res.setHeader('Server', `labweb/1.0 glibc/${glibc}`);
res.end('ok\n');
})
.listen(8080, '0.0.0.0');mkdir vm-lab && cd vm-lab
# save web.js here, then start the two targets:
docker run -d --name e30-se3-vm-deb \
-v "$PWD/web.js:/srv/web.js:ro" node:22-bookworm-slim node /srv/web.js
docker run -d --name e30-se3-vm-alp alpine:3.20 sleep 3600
docker ps --filter name=e30-se3-vm- --format '{{.Names}} {{.Image}} {{.Ports}}'a28c36c7b6ef67d229960ccf054f2cb1ecd0d5d123e81b0ce3eb945770b2e973
1f5ec9fbbcffc0305af5070c654f10ef9857b3d65dd18f3eb82db5c0e8be869b
e30-se3-vm-alp alpine:3.20
e30-se3-vm-deb node:22-bookworm-slim 03. Step 2: Look from the network
A network scan starts from a list of addresses. Here it comes from docker inspect, as a real target list comes from discovery in the inventory lesson. Docker assigns the addresses, so yours may differ.
fmt='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'
for c in e30-se3-vm-deb e30-se3-vm-alp; do
echo "$c $(docker inspect -f "$fmt" "$c")"
done | tee targets.txte30-se3-vm-deb 172.17.0.11
e30-se3-vm-alp 172.17.0.12The script probes two TCP ports per target: 22, SSH, where a credentialed scanner would log in on a real server, and 8080, the lab web service. It sends a minimal HTTP request and keeps the Server header. closed means the target answered with a TCP reset: the host is up, but nothing listens. no reply means nothing answered before the timeout: a firewall dropped the packet, or no host uses the address. Nmap calls these states closed and filtered.
"""Unauthenticated view: probe two TCP ports on each target's own IP address."""
import socket
PORTS = [22, 8080] # 22: SSH, where a credentialed scan logs in; 8080: lab web
def targets(path="targets.txt"):
return [line.split() for line in open(path) if line.strip()]
def probe(ip, port):
try:
with socket.create_connection((ip, port), timeout=2) as s:
s.sendall(b"HEAD / HTTP/1.1\r\nHost: lab\r\nConnection: close\r\n\r\n")
reply = s.recv(4096).decode(errors="replace")
except ConnectionRefusedError:
return "closed", "" # TCP reset: the host is up, nothing listens here
except OSError:
return "no reply", "" # timeout or unreachable: filtered, or no host
for line in reply.split("\r\n"):
if line.lower().startswith("server:"):
return "open", line.split(":", 1)[1].strip()
return "open", "(no Server header)"
if __name__ == "__main__":
for name, ip in targets():
for port in PORTS:
state, banner = probe(ip, port)
print(f"{name:<15} {port:<5} {state:<8} {banner}".rstrip())python3 unauth_scan.pye30-se3-vm-deb 22 closed
e30-se3-vm-deb 8080 open labweb/1.0 glibc/2.36
e30-se3-vm-alp 22 closed
e30-se3-vm-alp 8080 closedThe Debian target shows one open port and a banner. Neither target runs SSH, which is why this lab uses docker exec as the credential. The Alpine target is up, since both ports answered closed, but it offers nothing to read, and more ports or probes would not change that. A network-only report says "nothing found" for it, which is not "nothing vulnerable".
04. Step 3: Match the banner against upstream versions
Each advisory names a source package, a distribution release and the first package version with the fix (fixed; null means no fix has been released for that release yet). Some entries also carry the upstream range from the CVE record, in the OSV style: introduced, then fixed or last_affected. For CVE-2023-4911, the NVD record lists glibc from 2.34 up to, but excluding, 2.39.
[
{
"id": "CVE-2023-4911", "source": "glibc", "distro": "debian:12",
"fixed": "2.36-9+deb12u3", "advisory": "DSA-5514-1",
"upstream": {"product": "glibc", "introduced": "2.34", "fixed": "2.39"}
},
{
"id": "CVE-2026-95818", "source": "glibc", "distro": "debian:12",
"fixed": null, "advisory": "Debian bug 1148728",
"upstream": {"product": "glibc", "introduced": "2.14", "last_affected": "2.44"}
},
{
"id": "CVE-2026-57433", "source": "perl", "distro": "debian:12",
"fixed": "5.36.0-7+deb12u4", "advisory": "DLA-4821-1"
},
{
"id": "CVE-2026-107891", "source": "musl", "distro": "alpine:3.20",
"fixed": "1.2.5-r4", "advisory": "Alpine secdb v3.20",
"upstream": {"product": "musl", "introduced": "0", "fixed": "1.2.7"}
},
{
"id": "CVE-2026-22184", "source": "zlib", "distro": "alpine:3.20",
"fixed": "1.3.2-r0", "advisory": "Alpine secdb v3.20"
}
]"""Match banners against upstream version ranges, as a network-only check does."""
import json
import re
from unauth_scan import PORTS, probe, targets
def ver(text):
return tuple(int(part) for part in text.split("."))
def upstream_hit(version, rng):
if ver(version) < ver(rng["introduced"]):
return False
if "fixed" in rng:
return ver(version) < ver(rng["fixed"])
return ver(version) <= ver(rng["last_affected"])
advisories = json.load(open("advisories.json"))
for name, ip in targets():
for port in PORTS:
state, banner = probe(ip, port)
for product, version in re.findall(r"(\w+)/([\d.]+)", banner):
for adv in advisories:
rng = adv.get("upstream")
if rng and rng["product"] == product and upstream_hit(version, rng):
print(f"{name:<15} {port:<5} {adv['id']:<15} {product} {version}"
" -> LIKELY VULNERABLE (banner)")python3 match_banner.pye30-se3-vm-deb 8080 CVE-2023-4911 glibc 2.36 -> LIKELY VULNERABLE (banner)
e30-se3-vm-deb 8080 CVE-2026-95818 glibc 2.36 -> LIKELY VULNERABLE (banner)The banner says glibc 2.36, inside both upstream ranges, so both CVEs are flagged. Greenbone's manual names this limit for its CVE scanner, which matches product versions against NVD data: it cannot detect backported fixes, because the product version does not show them. A remote test that checks how a service reacts to a crafted request avoids this, but only some flaws can be tested that way.
05. Step 4: Read the package database with credentials
First look at the raw data that a credentialed scanner reads. On Debian, dpkg-query prints each binary package with its full version and source package. On Alpine, the database is a text file where P: is the package name and V: the version.
docker exec e30-se3-vm-deb \
dpkg-query -W -f '${Package} ${Version} [${source:Package}]\n' libc6 perl-base
docker exec e30-se3-vm-alp grep -A1 -E '^P:(musl|zlib)$' /lib/apk/db/installedlibc6 2.36-9+deb12u14 [glibc]
perl-base 5.36.0-7+deb12u4 [perl]
P:musl
V:1.2.5-r3
--
P:zlib
V:1.3.2-r0The version 2.36-9+deb12u14 has no epoch, so it has two parts. 2.36 is the upstream version. After the hyphen, 9+deb12u14 is the Debian revision; by convention +deb12u14 marks the fourteenth update of this package for Debian 12. Security fixes land in that counter while the upstream part stays at 2.36. collect.py saves the inventory of both targets as JSON.
"""Authenticated view: read the package database of each target, as an agent or an
SSH-credentialed scanner does. Here the credential is access to `docker exec`."""
import json
import re
import subprocess
HOSTS = ["e30-se3-vm-deb", "e30-se3-vm-alp"]
DPKG_FMT = "${Package}\t${Version}\t${source:Package}\n"
def run(host, *cmd):
out = subprocess.run(["docker", "exec", host, *cmd],
capture_output=True, text=True, check=True)
return out.stdout
def os_release(host):
lines = run(host, "cat", "/etc/os-release").split("\n")
pairs = (line.split("=", 1) for line in lines if "=" in line)
return {k: v.strip('"') for k, v in pairs}
def packages(host, family):
if family == "debian":
rows = run(host, "dpkg-query", "-W", "-f", DPKG_FMT).strip().split("\n")
return [dict(zip(("name", "version", "source"), r.split("\t"))) for r in rows]
found = [] # alpine: "musl-1.2.5-r3 x86_64 {musl} (MIT) [installed]"
for line in run(host, "apk", "list", "--installed").strip().split("\n"):
m = re.match(r"^(.+)-([^-]+-r\d+) \S+ \{(.+?)\}", line)
found.append({"name": m[1], "version": m[2], "source": m[3]})
return found
inventory = {}
for host in HOSTS:
rel = os_release(host)
family = rel["ID"]
parts = 1 if family == "debian" else 2 # debian:12, alpine:3.20
release = ".".join(rel["VERSION_ID"].split(".")[:parts])
pkgs = packages(host, family)
inventory[host] = {"distro": f"{family}:{release}", "packages": pkgs}
print(f"{host:<15} {rel['PRETTY_NAME']:<34} {len(pkgs)} packages")
json.dump(inventory, open("inventory.json", "w"), indent=1)python3 collect.pye30-se3-vm-deb Debian GNU/Linux 12 (bookworm) 88 packages
e30-se3-vm-alp Alpine Linux v3.20 14 packages06. Step 5: Compare versions the distribution's way
Package versions are not plain strings. Debian versions can have an epoch (1: at the front, which outranks everything after it), and ~ sorts before anything, even the end of the string. Alpine uses -rN release numbers. So compare.py asks the package manager inside the target. It must also fail closed. An unreachable target or a malformed version, such as a typo in an advisory, gives no clean answer, and apk version -t even prints > for an invalid version. Reading that as "not older" would silently report "not affected". So the script checks Alpine versions with apk version -c first, accepts only the known answers and raises CompareError for anything else.
"""Version comparison with each distribution's own rules, run inside the target.
Fails closed: anything other than a clean answer raises CompareError."""
import subprocess
# Each script prints one token; ANSWERS maps it to "installed sorts before fixed".
SCRIPTS = {
"debian": 'dpkg --compare-versions "$1" lt "$2"; echo "rc=$?"',
"alpine": 'apk version -c "$1" "$2" >/dev/null && apk version -t "$1" "$2"',
}
ANSWERS = {
"debian": {"rc=0": True, "rc=1": False}, # rc=2: malformed version
"alpine": {"<": True, "=": False, ">": False},
}
class CompareError(Exception):
"""The comparison did not run cleanly, so there is no verdict."""
def is_older(host, family, installed, fixed):
"""True if `installed` sorts before `fixed` for this package manager."""
cmd = ["sh", "-c", SCRIPTS[family], "sh", installed, fixed]
out = subprocess.run(["docker", "exec", host, *cmd],
capture_output=True, text=True)
answer = out.stdout.strip()
if answer not in ANSWERS[family]:
raise CompareError(f"no verdict for {installed} < {fixed} on {host}",
out.stderr.strip())
return ANSWERS[family][answer]Test the comparator before trusting it. A version exactly at the fix must not count as older, some cases are traps for plain string comparison, and the last three inputs must be refused: a malformed Debian version, a malformed Alpine version and a missing container.
"""Negative and positive tests for the comparator. Run with both targets started."""
from compare import CompareError, is_older
DEB, ALP = "e30-se3-vm-deb", "e30-se3-vm-alp"
cases = [
# (host, family, installed, fixed, expected is_older)
(DEB, "debian", "2.36-9+deb12u14", "2.36-9+deb12u3", False), # u14 is newer than u3
(DEB, "debian", "5.36.0-7+deb12u4", "5.36.0-7+deb12u4", False), # at fixed version
(DEB, "debian", "5.36.0-7+deb12u3", "5.36.0-7+deb12u4", True), # one below
(DEB, "debian", "1:2.38.1-5+deb12u3", "2.40-1", False), # epoch 1 wins
(DEB, "debian", "252.39-1~deb12u2", "252.39-1", True), # ~ sorts before nothing
(ALP, "alpine", "1.3.2-r0", "1.3.2-r0", False), # at fixed version
(ALP, "alpine", "1.2.5-r3", "1.2.5-r4", True), # one release below
]
failed = 0
for host, family, installed, fixed, expected in cases:
got = is_older(host, family, installed, fixed)
naive = installed < fixed # plain string comparison, for contrast
status = "ok " if got == expected else "FAIL"
failed += got != expected
wrong = " (wrong)" if naive != expected else ""
print(f"{status} {installed} < {fixed}: distro={got} naive={naive}{wrong}")
refused = [ # each must raise CompareError, never return a verdict
(DEB, "debian", "2.36-9+deb12u14", "2.36-9+deb12u 3"), # typo: a space
(ALP, "alpine", "1.2.5-r3", "1.2.5-rX"), # apk version -t alone answers ">"
("e30-se3-vm-gone", "debian", "1.0-1", "1.0-2"), # target not reachable
]
for host, family, installed, fixed in refused:
try:
status, why = "FAIL", f"returned {is_older(host, family, installed, fixed)}"
except CompareError as err:
status, why = "ok ", err.args[0]
failed += status == "FAIL"
print(f"{status} refused: {why}")
print("all comparator tests passed" if not failed else f"{failed} tests failed")python3 test_compare.pyok 2.36-9+deb12u14 < 2.36-9+deb12u3: distro=False naive=True (wrong)
ok 5.36.0-7+deb12u4 < 5.36.0-7+deb12u4: distro=False naive=False
ok 5.36.0-7+deb12u3 < 5.36.0-7+deb12u4: distro=True naive=True
ok 1:2.38.1-5+deb12u3 < 2.40-1: distro=False naive=True (wrong)
ok 252.39-1~deb12u2 < 252.39-1: distro=True naive=False (wrong)
ok 1.3.2-r0 < 1.3.2-r0: distro=False naive=False
ok 1.2.5-r3 < 1.2.5-r4: distro=True naive=True
ok refused: no verdict for 2.36-9+deb12u14 < 2.36-9+deb12u 3 on e30-se3-vm-deb
ok refused: no verdict for 1.2.5-r3 < 1.2.5-rX on e30-se3-vm-alp
ok refused: no verdict for 1.0-1 < 1.0-2 on e30-se3-vm-gone
all comparator tests passed"""Match installed packages against distribution advisories (fixed versions)."""
import json
from compare import is_older
advisories = json.load(open("advisories.json"))
inventory = json.load(open("inventory.json"))
findings = []
for host, data in inventory.items():
family = data["distro"].split(":")[0]
for adv in (a for a in advisories if a["distro"] == data["distro"]):
pkgs = [p for p in data["packages"] if p["source"] == adv["source"]]
versions = {p["version"] for p in pkgs}
for installed in sorted(versions):
if adv["fixed"] is None:
verdict = "AFFECTED, no fix released"
elif is_older(host, family, installed, adv["fixed"]):
verdict = f"VULNERABLE, fixed in {adv['fixed']}"
else:
verdict = "not affected, at or above fix"
print(f"{host:<15} {adv['id']:<15} {adv['source']} {installed}: {verdict}")
if not verdict.startswith("not affected"):
names = sorted(p["name"] for p in pkgs if p["version"] == installed)
print(f"{'':<16}binary packages: {', '.join(names)}")
findings.append({"host": host, "id": adv["id"], "source": adv["source"],
"installed": installed, "fixed": adv["fixed"]})
json.dump(findings, open("findings.json", "w"), indent=1)
print(f"\nfindings: {len(findings)} (written to findings.json)")python3 match_auth.pye30-se3-vm-deb CVE-2023-4911 glibc 2.36-9+deb12u14: not affected, at or above fix
e30-se3-vm-deb CVE-2026-95818 glibc 2.36-9+deb12u14: AFFECTED, no fix released
binary packages: libc-bin, libc6
e30-se3-vm-deb CVE-2026-57433 perl 5.36.0-7+deb12u4: not affected, at or above fix
e30-se3-vm-alp CVE-2026-107891 musl 1.2.5-r3: VULNERABLE, fixed in 1.2.5-r4
binary packages: musl, musl-utils
e30-se3-vm-alp CVE-2026-22184 zlib 1.3.2-r0: not affected, at or above fix
findings: 2 (written to findings.json)Now compare the two views:
- CVE-2023-4911 was a banner finding and is a false positive. Debian fixed it in
2.36-9+deb12u3(DSA-5514-1) without changing the upstream version, and the target runsdeb12u14. Close such findings only after checking the installed package against the distribution's advisory (Debian DSAs and DLAs, Ubuntu USNs). A self-built upstream version would take the host off the distribution's security updates. - CVE-2026-95818 is in both views and is real. Debian 12 has no fix yet, so it needs a compensating control and a time-limited exception, as in the remediation lesson.
- CVE-2026-107891 on Alpine is real, has a fix, and was invisible from the network. musl fixed it in 1.2.7; Alpine backported the fix into
1.2.5-r4. - CVE-2026-57433 and CVE-2026-22184 are the negative tests: installed equals fixed, so nothing is reported.
07. Step 6: Patch one host and rescan
Upgrade musl on the Alpine target, then repeat the authenticated scan. This verification rescan decides closure: the ticket stays open until the asset shows the fixed version.
docker exec e30-se3-vm-alp apk upgrade --no-cache musl
python3 collect.py
python3 match_auth.pyfetch https://dl-cdn.alpinelinux.org/alpine/v3.20/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/community/x86_64/APKINDEX.tar.gz
(1/1) Upgrading musl (1.2.5-r3 -> 1.2.5-r4)
OK: 8 MiB in 14 packages
e30-se3-vm-deb Debian GNU/Linux 12 (bookworm) 88 packages
e30-se3-vm-alp Alpine Linux v3.20 14 packages
e30-se3-vm-deb CVE-2023-4911 glibc 2.36-9+deb12u14: not affected, at or above fix
e30-se3-vm-deb CVE-2026-95818 glibc 2.36-9+deb12u14: AFFECTED, no fix released
binary packages: libc-bin, libc6
e30-se3-vm-deb CVE-2026-57433 perl 5.36.0-7+deb12u4: not affected, at or above fix
e30-se3-vm-alp CVE-2026-107891 musl 1.2.5-r3: VULNERABLE, fixed in 1.2.5-r4
binary packages: musl-utils
e30-se3-vm-alp CVE-2026-107891 musl 1.2.5-r4: not affected, at or above fix
e30-se3-vm-alp CVE-2026-22184 zlib 1.3.2-r0: not affected, at or above fix
findings: 2 (written to findings.json)The finding is still open: the source package musl builds two binary packages, and musl-utils is still at 1.2.5-r3. Its tools, such as getent, load the C library from musl, so the vulnerable code was most likely replaced already. A scanner cannot know that without analysis, because a statically built binary carries its own copy, so it reports every binary package from the affected source. The rule is to upgrade them all. Without the rescan, this partial patch would have been reported as done.
08. Step 7: Finish the patch and verify closure
docker exec e30-se3-vm-alp apk upgrade --no-cache musl-utils
python3 collect.py > /dev/null
python3 match_auth.pyfetch https://dl-cdn.alpinelinux.org/alpine/v3.20/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/community/x86_64/APKINDEX.tar.gz
(1/1) Upgrading musl-utils (1.2.5-r3 -> 1.2.5-r4)
Executing busybox-1.36.1-r31.trigger
OK: 8 MiB in 14 packages
e30-se3-vm-deb CVE-2023-4911 glibc 2.36-9+deb12u14: not affected, at or above fix
e30-se3-vm-deb CVE-2026-95818 glibc 2.36-9+deb12u14: AFFECTED, no fix released
binary packages: libc-bin, libc6
e30-se3-vm-deb CVE-2026-57433 perl 5.36.0-7+deb12u4: not affected, at or above fix
e30-se3-vm-alp CVE-2026-107891 musl 1.2.5-r4: not affected, at or above fix
e30-se3-vm-alp CVE-2026-22184 zlib 1.3.2-r0: not affected, at or above fix
findings: 1 (written to findings.json)One finding remains, the glibc issue with no fix. Keep findings.json; it is the input for the next lessons.
09. Step 8 (optional): Cross-check with a real scanner
Trivy is an open-source scanner that reads the same package databases from container images and matches them against distribution advisories. Download the release binary and check its SHA-256 sum against the published checksum file.
mkdir -p bin
base=https://github.com/aquasecurity/trivy/releases/download/v0.76.2
curl -sSLo trivy.tgz "$base/trivy_0.76.2_Linux-64bit.tar.gz"
curl -sSLo sums.txt "$base/trivy_0.76.2_checksums.txt"
sum=$(grep ' trivy_0.76.2_Linux-64bit.tar.gz$' sums.txt | cut -d' ' -f1)
echo "$sum trivy.tgz" | sha256sum -c
tar -xzf trivy.tgz -C bin trivy && bin/trivy --version | head -1trivy.tgz: OK
Version: 0.76.2Scan both images for operating system packages only, then look up the lab advisories in the reports. The totals depend on the database date, so your numbers will differ.
"""Summarise Trivy JSON reports and look up the lab advisories in them."""
import collections
import json
LAB_IDS = [a["id"] for a in json.load(open("advisories.json"))]
for report in ["trivy-deb.json", "trivy-alp.json"]:
data = json.load(open(report))
vulns = [v for r in data.get("Results", []) for v in r.get("Vulnerabilities") or []]
counts = dict(sorted(collections.Counter(v["Severity"] for v in vulns).items()))
print(f"{data['ArtifactName']}: {len(vulns)} package-CVE pairs")
print(f" by severity: {counts}")
for v in vulns:
if v["VulnerabilityID"] in LAB_IDS:
fixed = v.get("FixedVersion") or "-"
print(f" {v['VulnerabilityID']:<15} {v['PkgName']:<10} "
f"{v['InstalledVersion']:<15} fixed={fixed} status={v.get('Status')}")for t in deb:node:22-bookworm-slim alp:alpine:3.20; do
bin/trivy image --cache-dir ./trivy-cache --pkg-types os --quiet \
--format json --output "trivy-${t%%:*}.json" "${t#*:}"
done
python3 trivy_check.pynode:22-bookworm-slim: 227 package-CVE pairs
by severity: {'CRITICAL': 1, 'HIGH': 38, 'LOW': 85, 'MEDIUM': 98, 'UNKNOWN': 5}
CVE-2026-95818 libc-bin 2.36-9+deb12u14 fixed=- status=affected
CVE-2026-95818 libc6 2.36-9+deb12u14 fixed=- status=affected
alpine:3.20: 2 package-CVE pairs
by severity: {'HIGH': 2}
CVE-2026-107891 musl 1.2.5-r3 fixed=1.2.5-r4 status=fixed
CVE-2026-107891 musl-utils 1.2.5-r3 fixed=1.2.5-r4 status=fixedTrivy agrees with your matcher: no CVE-2023-4911, no perl or zlib finding, and CVE-2026-95818 affected with no fixed version. It still reports musl because it scanned the image, while you patched a running container. Every new container from alpine:3.20 starts unpatched, so the real fix is a rebuilt image. Alpine 3.20 also left support on 1 April 2026 (Alpine releases page), and an unsupported release is a finding in its own right.
10. Step 9: Clean up
docker rm -f e30-se3-vm-deb e30-se3-vm-alpe30-se3-vm-deb
e30-se3-vm-alp11. Troubleshooting
12. Check your understanding
13. Apply it
Take the lab towards the skill project:
- Add a third target from another image, extend
collect.pyfor its package format, and add one advisory from its distribution's tracker, with a negative test. - Make
match_auth.pyprint which targets were assessed with credentials and which failed. - Scan an application's
package-lock.jsonwithbin/trivy fs --scanners vuln .and note which findings come from libraries rather than the operating system.
14. Review prompt
Without looking back:
- Why did the banner check flag CVE-2023-4911, and what showed it was a false positive?
- What can a network scan tell you about the Alpine target, and what can it not?
- Why must a version comparator fail closed?
- Why did Trivy still report musl after you patched the Alpine container?
References
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.