Skip to content

Commit 73abed7

Browse files
authored
Merge pull request #24303 from ajeetraina/fixvex
add: build child images with provenance attestations
1 parent facd292 commit 73abed7

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

content/manuals/dhi/how-to/scan.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,93 @@ Example output:
5353

5454
For more detailed filtering and JSON output, see [Docker Scout CLI reference](/reference/cli/docker/scout/).
5555

56+
### Build child images with provenance attestations
57+
58+
When you build a custom image that uses a Docker Hardened Image as its base, you must build with `--provenance=mode=max` and `--sbom=true` so that Docker Scout can trace the base image lineage and correctly apply VEX statements.
59+
60+
Without these flags, Docker Scout cannot identify the DHI base image in
61+
the provenance chain. As a result, it reports CVEs that are already suppressed
62+
by VEX statements in the base image, producing false CVE positives in your
63+
scan results.
64+
65+
> [!NOTE]
66+
> **Why provenance attestation is required**
67+
>
68+
> Docker Scout uses max-mode provenance attestations to identify the DHI base image
69+
> and track its lineage. A cryptographically signed provenance attestation ensures that
70+
> base image lineage is verified and tamper-resistant, giving Docker Scout the trust
71+
> anchor it needs to correctly apply VEX statements from the base image.
72+
73+
To build with maximum provenance and SBOM attestations:
74+
75+
```console
76+
$ docker build \
77+
--provenance=mode=max \
78+
--sbom=true \
79+
--push \
80+
-t docker.io/<namespace>/<image>:<tag> .
81+
```
82+
83+
After building with these flags, Docker Scout reads the full provenance
84+
chain, matches the DHI base image, and applies its VEX statements. Scans of
85+
your child image then reflect the correct suppressed CVEs, giving you an
86+
accurate vulnerability assessment.
87+
88+
### VEX attestations in child images
89+
90+
If you introduce new layers in your child image and want to suppress CVEs in those layers, you can attach your own VEX attestation to the child image independently, you do not need to duplicate or aggregate the VEX statements from the DHI base image.
91+
92+
When `docker scout cves` runs against your child image, Scout reads VEX attestations from the full provenance chain and applies them cumulatively:
93+
94+
- **Base image VEX** - attached to the DHI, applied to CVEs in base image layers
95+
- **Child image VEX** - attached to your image, applied to CVEs in layers you introduced
96+
97+
For example, if you add a `requests` layer to a DHI Python base image and attach a VEX statement suppressing `CVE-2024-47081`, Scout applies both VEX attestations independently and attributes each to its respective author:
98+
99+
```text
100+
✓ VEX statements obtained from attestation
101+
CVE-2024-47081 VEX: not affected [vulnerable code not present] : <your-namespace>
102+
```
103+
104+
Scout suppresses CVEs from the DHI base VEX and CVEs from your child VEX in the same scan - no aggregate VEX document is required.
105+
106+
To create and attach a VEX attestation to your child image:
107+
108+
```bash
109+
cat > child-vex.json << 'EOF'
110+
{
111+
"@context": "https://openvex.dev/ns/v0.2.0",
112+
"@id": "https://<your-namespace>/vex/<image-name>/1",
113+
"author": "<your-namespace>",
114+
"timestamp": "<timestamp>",
115+
"version": 1,
116+
"statements": [
117+
{
118+
"vulnerability": {
119+
"name": "<CVE-ID>"
120+
},
121+
"products": [
122+
{
123+
"@id": "pkg:pypi/<package>@<version>"
124+
}
125+
],
126+
"status": "not_affected",
127+
"justification": "vulnerable_code_not_present"
128+
}
129+
]
130+
}
131+
EOF
132+
133+
docker scout attestation add \
134+
--file child-vex.json \
135+
--predicate-type https://openvex.dev/ns/v0.2.0 \
136+
docker.io/<your-namespace>/<image>:<tag>
137+
```
138+
139+
> [!NOTE]
140+
> This is only possible because you built with `--provenance=mode=max`. Without the full
141+
> provenance chain, Scout cannot traverse back to the base image to retrieve its VEX attestations.
142+
56143
### Automate DHI scanning in CI/CD with Docker Scout
57144

58145
Integrating Docker Scout into your CI/CD pipeline enables you to automatically

0 commit comments

Comments
 (0)