Skip to content

Commit 712ca0e

Browse files
committed
[GR-69734] Add Documentation for SBOM Hashes Feature
PullRequest: graal/22223
2 parents ee7ff68 + 559b4d3 commit 712ca0e

File tree

2 files changed

+56
-6
lines changed

2 files changed

+56
-6
lines changed

docs/reference-manual/native-image/BuildOutput.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,14 @@ Unassociated types are displayed when certain types (such as classes, interfaces
316316
If these types contain vulnerabilities, SBOM scanning will not detect them.
317317
To fix this, ensure that proper GAV coordinates (Group ID, Artifact ID, and Version) are defined in the project POM's properties or in _MANIFEST.MF_ using standard formats.
318318

319+
Hashes are computed for JAR inputs and GraalVM internal components if the `hashes` option is used.
320+
Hashes are not computed for directories.
321+
If `hashes` is enabled and hashes cannot be computed, the number of components without hashes is displayed.
322+
To list these components, use:
323+
```bash
324+
jq '.components[] | select(.hashes == null)' /path/to/app.sbom.json
325+
```
326+
319327
Use the [build report](BuildReport.md) to view included components, their dependencies, and any unassociated types.
320328
For more information, see [Software Bill of Materials (SBOM) in Native Image](../../security/SBOM.md).
321329

docs/security/SBOM.md

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ permalink: /security-guide/native-image/sbom/
99

1010
GraalVM Native Image assembles a Software Bill of Materials (SBOM) at build time to detect any libraries that may be susceptible to known security vulnerabilities (only available in Oracle GraalVM).
1111
Pass the `--enable-sbom` option to the `native-image` command to configure the SBOM feature.
12-
The SBOM feature is enabled by default and defaults to the `embed` option which embeds an SBOM into the native executable.
12+
The SBOM feature is enabled by default and defaults to the `embed` option which embeds an SBOM into the native executable.
1313
In addition to being embedded, the SBOM can be added to the classpath or exported as a JSON file by using `--enable-sbom=classpath,export`.
1414

1515
The CycloneDX format is supported and is the default.
@@ -40,6 +40,7 @@ It outputs the contents in the JSON format:
4040
"bomFormat": "CycloneDX",
4141
"specVersion": "1.5",
4242
"version": 1,
43+
"serialNumber": "urn:uuid:51ec305f-616e-4139-a033-a094bb94a17c",
4344
"components": [
4445
{
4546
"bom-ref": "pkg:maven/io.netty/[email protected]",
@@ -48,6 +49,16 @@ It outputs the contents in the JSON format:
4849
"name": "netty-codec-http2",
4950
"version": "4.1.104.Final",
5051
"purl": "pkg:maven/io.netty/[email protected]",
52+
"hashes": [
53+
{
54+
"alg": "SHA-256",
55+
"content": "fc03e6a2cc2d59f80fb1ec2957621e2630a952db36e069ccbbd72e0662796881"
56+
},
57+
{
58+
"alg": "SHA-512",
59+
"content": "d8dd3f31df4961b1ec6a9b047eaee3ba69c1363754b88afe29e2b4823e14f9c4efbe37632f6194110bb83053f1ecc178095ce63d0f1cbe075f36cae0e95d3c80"
60+
}
61+
],
5162
"properties": [
5263
{
5364
"name": "syft:cpe23",
@@ -78,8 +89,7 @@ It outputs the contents in the JSON format:
7889
]
7990
},
8091
...
81-
],
82-
"serialNumber": "urn:uuid:51ec305f-616e-4139-a033-a094bb94a17c"
92+
]
8393
}
8494
```
8595

@@ -110,7 +120,7 @@ json 20211205 java-archive
110120
```
111121

112122
## Enabling Security Scanning
113-
123+
114124
You can leverage the generated SBOM to integrate with security scanning solutions.
115125
There are a variety of tools to help detect and mitigate security vulnerabilities in your application dependencies.
116126

@@ -137,12 +147,43 @@ The generated report can then be used to update any vulnerable dependencies in y
137147

138148
Integrating security scanning into your CI/CD workflows has never been easier.
139149
With SBOM support available in the [GraalVM GitHub Action](https://github.com/marketplace/actions/github-action-for-graalvm){:target="_blank"}, your generated SBOM can be automatically submitted and analyzed using [GitHub’s dependency submission API](https://docs.github.com/en/rest/dependency-graph/dependency-submission){:target="_blank"}.
140-
It enables:
150+
It enables:
141151
- Vulnerability tracking with GitHub's Dependabot.
142152
- Dependency tracking with GitHub's Dependency Graph.
143153

144154
This integration helps ensure that your application is continuously monitored for vulnerabilities throughout the development lifecycle.
145155

156+
## Verifying Component Integrity with Hashes
157+
158+
Use `--enable-sbom=hashes` to associate each component with SHA-256 and SHA-512 hashes.
159+
The hash can be verified against trusted sources such as Maven Central.
160+
Verifying the component hashes can detect malicious tampering or substitutions in your native image builds.
161+
If a compromised dependency poses as a legitimate library, a hash mismatch against the trusted source would reveal tampering.
162+
163+
> Verifying component hashes strengthens integrity verification, but does not provide complete end‑to‑end supply chain security. Use cryptographic signing and SLSA provenances to guarantee authenticity and integrity.
164+
165+
Hashes are computed for applications JARs and GraalVM components, but not for classpath directories.
166+
The GraalVM components are associated with the hash of the runtime image file.
167+
These GraalVM components include for example `org.graalvm.nativeimage/svm`, `org.graalvm.sdk/nativeimage`, and `Oracle GraalVM`.
168+
169+
| Kind | Hashed | How to verify |
170+
|-----------------------|:------:|----------------------------------------------------------------------------------------------------------------------------------|
171+
| Application JARs | Yes | Download the JAR from a trusted source, hash it, and compare with the component hash. |
172+
| GraalVM components | Yes | Hash `$GRAALVM_HOME/lib/modules` from the same GraalVM distribution used to build the image and compare with the component hash. |
173+
| Classpath directories | No | - |
174+
175+
If you use a fat (or shaded) JAR, the hash is computed from the fat JAR, which will not match individual component hashes published on Maven Central.
176+
177+
Pair this with `--enable-sbom=hashes,strict`.
178+
The `strict` flag enforces completeness by ensuring every class in the image is mapped to a component.
179+
When using `strict`, the `native-image` builder will throw an exception if one or more components cannot be associated with a hash.
180+
181+
The Security Report in the build output indicates whether any components could not be associated with a hash.
182+
Run the following command to find these components:
183+
```bash
184+
jq '.components[] | select(.hashes == null)' /path/to/app.sbom.json
185+
```
186+
146187
## Dependency Tree
147188

148189
The SBOM provides information about component relationships through its `dependencies` field.
@@ -243,6 +284,7 @@ The class-level SBOM component would look like this:
243284
"purl": "pkg:maven/com.sbom/[email protected]",
244285
"bom-ref": "pkg:maven/com.sbom/[email protected]",
245286
"properties": [...],
287+
"hashes": [...],
246288
"components": [
247289
{
248290
"type": "library",
@@ -331,4 +373,4 @@ When this happens, all unresolved metadata gets collected in a placeholder compo
331373

332374
- [Using GraalVM Native Image SBOM Support for Vulnerability Scanning](https://medium.com/graalvm/using-graalvm-native-image-sbom-support-for-vulnerability-scanning-4211c747376)
333375
- [Embed an SBOM in a Native Executable to Identify Its Dependencies](../reference-manual/native-image/guides/use-sbom-support.md)
334-
- [Security Guide](security-guide.md)
376+
- [Security Guide](security-guide.md)

0 commit comments

Comments
 (0)