Skip to content

9.2 SBOM and supply chain

Every deployment of the system is built from far more code than the team wrote. The Rust engine and the Go gateway each pull in direct dependencies, those pull in transitive ones, and the container image adds a base layer on top. When a vulnerability advisory lands, the question responders need answered is blunt: which of the artifacts running right now contain the affected version? A software bill of materials (SBOM) and a dependency policy are what let you answer that question in minutes and prove what was shipped.

Concepts from other sections (3)

This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.

  • Threat model: a structured answer to four questions about a system: what are we building, what can go wrong, what are we going to do about it, and did we do a good job? It turns an architecture into a list of threats, each tied to a control and a test. Read more: Chapter 9: Security
  • Resolved graph: the exact versions a build uses after resolution, recorded in the lockfile, as opposed to the version requirements. Read more: 8.3 Dependency upgrades
  • document id: a per-token label naming which packed example a token belongs to (-1 for padding), used to build a block-diagonal attention mask. Read more: 18.1 Supervised fine-tuning: chat rendering, assistant-only loss, packing in AI Engineering

This section expands one row of the threat model: the model-files and release-pipeline row, where provenance and digests are named as controls. It needs nothing beyond that. The model answers are two SPDX 2.3 documents in the solutions tree, engine.spdx.json and gateway.spdx.json, each listing packages and dependency relationships. The policy they are compared against is the contract course/contracts/allowed-deps.toml. Like the threat model, these are standalone artifacts with no code call site.

Before reading the model documents, try listing the fields you would need during a CVE response. Then check your list against what the SBOMs actually record, and against what they deliberately leave blank.

Learning objectives

  • Explain why an SBOM describes one built artifact, identified by its image digest, rather than a source manifest or a commit.
  • Read an SPDX 2.3 document: header, packages, purls, and relationships.
  • Check an SBOM for unique ids and connected relationships, and say why each property matters to a responder.
  • Use NOASSERTION correctly and identify which missing fields a release SBOM must fill.
  • Compare an SBOM against a dependency policy and decide what counts as a finding.

When a vulnerability is announced, source manifests cannot tell you whether you are exposed, because they state requirements, not results. Only the resolved graph of the built artifact can. So an SBOM is per artifact, generated from that artifact’s resolved dependency graph and tied to its image digest. The working rules follow directly: generate inventories from the exact image digest; pin base images and dependencies; record licenses and provenance; define a review path for exceptions; and regenerate an SPDX document for each released image, retaining the image digest with the CI run.

“Contains” is a graph question, because a package can arrive transitively. An SBOM therefore records packages and the edges between them, rooted at the artifact. Those edges must resolve: a relationship to an id that is not in the document is a hole in the graph exactly where a responder needs to walk. Package ids are unique, and every edge target exists in the document.

Not every fact is known when an SBOM is written. A license may not have been reviewed yet; the build may not record a download location. Writing a guess is worse than writing nothing, and writing nothing is ambiguous. SPDX’s NOASSERTION value resolves this: it says explicitly that this document makes no claim about the field.

Finally, inventory and policy are different things. The policy, allowed-deps.toml, says what may be used. It is maintained by people and is the source of truth; it is not a generated artifact. The SBOM says what was used and is generated by the build. Comparing the two is the review.

The workflow is short: build each service image, capture its digest, generate an SPDX or CycloneDX SBOM, and compare every dependency with the allowlist. Investigate unpinned transitive dependencies and known vulnerabilities before signing off.

Here is what that buys you during an incident. An advisory names google.golang.org/grpc below some fixed version. The responder opens the gateway SBOM for the running digest, finds the package row with SPDXRef-Package-Grpc, reads its versionInfo, and follows the DEPENDS_ON relationship from SPDXRef-Package-Gateway to confirm the gateway pulls it in. The engine SBOM has no gRPC package row, so the engine is not exposed through this package. The answer comes from two files in minutes, without rebuilding anything.

The artifacts are docs/sbom/engine.spdx.json and docs/sbom/gateway.spdx.json. A valid pair, together with its policy, must pass the checks in the following table.

CaseChecksWhy it matters downstream
it is SPDX 2.3 JSONspdxVersion is SPDX-2.3 and the document id is SPDXRef-DOCUMENT.Standard tools (scanners, license checkers) can read it.
it has packages and relationshipsBoth arrays are non-empty.An inventory with no edges cannot answer “who depends on this?”.
package ids are uniqueNo two packages share an SPDXID.Relationships resolve to exactly one package.
relationships are connectedEvery non-DESCRIBES relationship points at a package in the document.No dangling edges; the graph is walkable from the root.
the policy has a section per componentallowed-deps.toml has [rust.tl-engine] and [go.tinyllm].Each inventory has a policy to be compared against.

With the rules in place, you can read the model documents field by field and see each rule at work.

The engine document opens like this:

{
"spdxVersion": "SPDX-2.3",
"dataLicense": "CC0-1.0",
"SPDXID": "SPDXRef-DOCUMENT",
"name": "tinyllm-engine-reference-sbom",
"documentNamespace": "https://example.invalid/spdx/tinyllm-engine-reference-2026-10-09",
"creationInfo": {
"creators": ["Tool: supersource-course-reference"],
"created": "2026-10-09T00:00:00Z",
"comment": "Reference example only. Release automation must replace this inventory with the exact image digest and resolved Cargo.lock packages."
},

dataLicense must be CC0-1.0 in SPDX 2.3: the SBOM’s own metadata is public domain. documentNamespace is a unique URI per document so that two SBOMs never collide in a database; the model uses the reserved .invalid domain because it is an example. creators and created say who generated the document and when, which is how a responder knows whether it matches the deployed build. The comment restates the first rule: the real document must come from the image digest and the lockfile.

Next come the packages, starting with the root:

{
"name": "tinyllm-engine",
"SPDXID": "SPDXRef-Package-Engine",
"downloadLocation": "NOASSERTION",
"filesAnalyzed": false,
"licenseConcluded": "NOASSERTION",
"licenseDeclared": "NOASSERTION",
"copyrightText": "NOASSERTION",
"primaryPackagePurpose": "APPLICATION"
},
{
"name": "anyhow",
"SPDXID": "SPDXRef-Package-Anyhow",
// ... downloadLocation, license, copyright: NOASSERTION
"externalRefs": [{"referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl",
"referenceLocator": "pkg:cargo/anyhow"}]
},

The root is marked primaryPackagePurpose: APPLICATION. Each dependency carries a purl (package URL), the identifier that vulnerability databases match on. filesAnalyzed: false says the document does not list individual files, which is normal for a dependency inventory. The license fields are NOASSERTION: the model makes no license claim it has not checked.

The gateway document shows the complete form of a package row:

{
"name": "github.com/BurntSushi/toml",
"SPDXID": "SPDXRef-Package-Toml",
"versionInfo": "1.6.0",
// ... NOASSERTION fields
"externalRefs": [{"referenceCategory": "PACKAGE-MANAGER", "referenceType": "purl",
"referenceLocator": "pkg:golang/github.com/%21burnt%21sushi/toml@1.6.0"}]
},

Here you have both versionInfo and a versioned purl. The odd-looking %21burnt%21sushi is the Go module proxy’s case encoding (!b for B), percent-encoded inside the purl. Compare the engine model: its package rows omit versionInfo and use unversioned purls such as pkg:cargo/anyhow. That is the gap its creation comment points at. Without versions, the CVE question from the walk-through cannot be answered for the engine, so a release SBOM generated from Cargo.lock must include them.

The engine’s relationships array is short:

"relationships": [
{"spdxElementId": "SPDXRef-DOCUMENT", "relationshipType": "DESCRIBES", "relatedSpdxElement": "SPDXRef-Package-Engine"},
{"spdxElementId": "SPDXRef-Package-Engine", "relationshipType": "DEPENDS_ON", "relatedSpdxElement": "SPDXRef-Package-Anyhow"},
{"spdxElementId": "SPDXRef-Package-Engine", "relationshipType": "DEPENDS_ON", "relatedSpdxElement": "SPDXRef-Package-SerdeJson"}
]

DESCRIBES names the root: the document is about the engine. DEPENDS_ON edges go from the root to each dependency, recording the graph. Every target id is one of the three package ids, so the graph is connected. A full SBOM would also have edges between dependencies (serde_json depends on serde, and so on), which a generator produces from the lockfile.

The last step is the review itself. The engine’s direct dependencies anyhow and serde_json both appear under [rust.tl-engine] in allowed-deps.toml (anyhow = "1", serde_json = "1"). The gateway’s github.com/BurntSushi/toml and google.golang.org/grpc appear under [go.tinyllm] with major v1, and the SBOM’s 1.6.0 satisfies it. A package in an SBOM that has no row in its component’s policy section is a finding: either the policy is extended through review, or the dependency is removed.

The full model answers are engine.spdx.json and gateway.spdx.json.

Generating the SBOM from the built artifact, rather than writing it from the manifest, is the decisive choice: the manifest is a requirement, and transitive resolution, vendored code, and the base image show up only in what was built. SPDX beats an ad-hoc JSON list because scanners, license tools, and registries already read it, and its relationship model answers graph questions; CycloneDX would serve equally well, since the point is a standard format. NOASSERTION beats guessing because a wrong license or location is worse than an honest gap when downstream tools will trust it. The tradeoff you accept is freshness: an SBOM is only as current as its last build, so it must be regenerated and stored with every released digest, which is a release-pipeline step someone has to maintain.

The most damaging mistake is writing the SBOM from the manifest instead of the artifact. Transitive and base-image packages go missing, and a CVE response gives the wrong answer; the model guards against this with a creation comment that requires regeneration from the image digest and resolved lockfile. A close second is colliding package ids or dangling relationships, which leave a graph that cannot be walked from the root; in the model each package has a unique SPDXRef-Package-* id and every DEPENDS_ON target is in packages.

Warning: Never fill in metadata you have not verified. Guessed license or location fields are wrong in exactly the places downstream tools trust them. Use NOASSERTION for anything unknown.

The last pitfall is missing versions, which makes advisories impossible to match. The gateway model shows the complete form, with versionInfo and a versioned purl, and the engine model flags the gap for release automation to close.

This section supplies evidence for the release-pipeline row of the threat model, where provenance and digests are listed as controls. It also connects to Dependency upgrades: an upgrade changes the resolved graph, so every upgrade produces a new SBOM to review against the policy.

  • SBOM: a software bill of materials, an inventory of the packages in one built artifact and the dependency edges between them.
  • SPDX: a standard SBOM format; version 2.3 is used here.
  • purl: a package URL, the cross-ecosystem identifier vulnerability databases match on.
  • NOASSERTION: the SPDX value meaning the document makes no claim about a field.
  • Dependency policy: the human-maintained list of what may be used (allowed-deps.toml), against which each SBOM is reviewed.
  • An SBOM describes one built artifact, identified by its image digest, and is generated from that artifact’s resolved dependency graph.
  • Each package has a unique SPDX id, and every dependency relationship points at a package in the same document.
  • Unknown facts are recorded as NOASSERTION, never guessed; versions and versioned purls are required for advisory matching.
  • The dependency policy is the source of truth for what may be used; the SBOM is the record of what was used, and the review compares the two.
  1. Why is the SBOM tied to an image digest and not to a git commit?

    Answer

    The same commit can build different images (a different base image, a different resolution of a loose requirement, a different toolchain). The digest identifies exactly what runs, and the SBOM must describe exactly that.

  2. Why does a dangling relationship matter?

    Answer

    A responder walks edges from the root to find whether a vulnerable package is reachable. An edge to an id that is not in the document breaks that walk, and the answer becomes “unknown” exactly where it is needed.

  3. The engine model has no versionInfo. Which question can it not answer?

    Answer

    “Is the running engine affected by an advisory for versions below X?” It shows that anyhow is present but not which version, so the responder would have to rebuild or inspect the image. A release SBOM generated from Cargo.lock includes versions and versioned purls.

  4. Why is allowed-deps.toml not generated from the SBOM?

    Answer

    Then the policy would allow whatever happened to be used, and the comparison would always pass. The policy is a human decision about what may be used; the SBOM is a machine record of what was used. Keeping them separate is what makes the comparison a review.