LESSON 6

Dependency and Supply Chain Security

Know and control what you ship: dependency inventory and SBOMs, vulnerability management for libraries and images, safe update practices, protection against malicious packages, build integrity, and provenance.

Introduction

A typical application contains far more code from other people than from its own team: libraries, frameworks, base images, build tools, and the libraries those libraries use. Each is a decision to trust someone else’s code and someone else’s practices. When a widely used library has a serious flaw, or when a malicious package is published under a convincing name, every project that depends on it is affected, often without anyone on the team having chosen that package directly.

This lesson teaches how to see what you depend on, keep it healthy, and protect the path from source code to running artifact.

Learning Objectives

  • Describe supply chain risks: vulnerable, malicious, abandoned, and compromised components.
  • Create and use a software bill of materials (SBOM).
  • Manage vulnerable dependencies with prioritization and safe updates.
  • Reduce exposure to malicious and typosquatted packages.
  • Secure builds, artifacts, and base images, and understand provenance and signing.
  • Define policies for adding, updating, and removing dependencies.
  • Use AI to evaluate dependencies and advisories without trusting it blindly.

1. The Risks

Risk Description Example
Known vulnerability A published flaw in a library version you use An advisory for a parsing library
Transitive dependency The vulnerable code is pulled in by another dependency A deep library you never chose
Malicious package A package built to steal data or run harmful code A fake package with a name similar to a popular one (typosquatting)
Dependency confusion A public package with the same name as a private one is installed instead Internal package name registered publicly
Compromised maintainer or account A legitimate package gets a malicious release Stolen publisher credentials
Abandoned project No maintenance; flaws will not be fixed Last release years ago
Unsafe build path A tampered build tool, script, or pipeline step Altered build script or action
Mutable references A tag or version range changes under you A base image tag that is rebuilt
License risk A dependency’s license conflicts with your obligations Incompatible license in a commercial product

The common thread: you execute third-party code with your application’s privileges, often at build time and at run time.

2. Know What You Ship: The Inventory and the SBOM

You cannot manage what you cannot list. Start with:

  • Manifests and lock files committed to version control: they record exact versions of direct and transitive dependencies, so builds are reproducible and reviewable.
  • A software bill of materials (SBOM): a machine-readable list of the components in an artifact, with versions, sources, and licenses, in a standard format such as SPDX or CycloneDX.

Generate an SBOM for every build artifact (each container image), store it with the artifact, and link it to the version. When a new vulnerability is announced, the question “do we use this, and where?” should take minutes, answered by searching SBOMs.

Include all layers: application libraries, operating system packages in the base image, and build-time tools that end up in the artifact. Keep a separate list of build and pipeline dependencies, because they run with powerful credentials.

3. Manage Vulnerable Dependencies

SCA tools compare your inventory to vulnerability databases. A workable routine:

  1. Scan on every pull request and build, and daily on what is already deployed. New advisories appear for old software.
  2. Triage with context (lesson 4): Is the vulnerable function reachable? Is the component exposed? Is there a known exploit? Is the fix available?
  3. Fix by updating to a patched version where possible. If there is no fix, consider replacing the library, disabling the affected feature, adding a mitigating control, or accepting the risk with an owner and expiry.
  4. Verify with the test suite and a re-scan.
  5. Record exceptions, with reasons and review dates.

Practices that reduce the pain:

  • Update often, in small steps. A project that updates weekly handles a security fix easily; one that has not updated in two years faces a risky leap exactly when it is under pressure. Automated update proposals make small steps routine.
  • Rely on your tests. The quality strategy’s automated tests are what make dependency updates safe; if updates frighten the team, tests are the gap.
  • Separate security updates from feature work, so they can ship quickly.
  • Watch for end-of-life runtimes and frameworks, which stop receiving fixes entirely.
  • Rebuild images regularly, even without code changes, to pick up base image patches.

4. Choose and Add Dependencies Deliberately

Every new dependency is an attack surface and a maintenance commitment. Before adding one, ask:

  • Do we need it, or is it a few lines of our own code?
  • Is it actively maintained? When was the last release? How many maintainers?
  • Is it widely used and reviewed? Does it have a security policy and a history of handling reports responsibly?
  • What does it pull in? How large is its dependency tree?
  • What permissions does it need at install and run time?
  • Is the license compatible?
  • Is the name exactly right? (Typosquatting depends on a hurried copy-and-paste.)

Write the criteria as a short policy and apply them in code review. Record significant choices as ADRs. Remove dependencies you no longer use; unused code is risk without benefit.

5. Protect Against Malicious Packages

  • Pin and lock versions; do not accept floating ranges for production builds. Install from the lock file with integrity hashes where the ecosystem supports them.
  • Use a private registry or proxy that serves approved packages, and configure it so that internal package names cannot be satisfied from public registries (preventing dependency confusion).
  • Delay adoption of brand-new releases for a short period (a cooling-off time) where practical; many malicious releases are discovered and removed within days.
  • Disable or review install scripts, which run code during installation.
  • Verify provenance and signatures where available.
  • Limit build-time access: build steps do not need production credentials or unrestricted network access.
  • Watch for unexpected changes in lock file diffs during review; a new transitive dependency, an altered integrity hash, or a changed source URL deserves a look.
  • Avoid copying commands from unknown sources into build scripts, and be suspicious of any dependency a tool, including an AI assistant, suggests that you cannot find in an official registry.

That last point deserves emphasis. Language models sometimes suggest packages that do not exist, inventing plausible names. Attackers can register such names with malicious content. Always check that a suggested package exists, is the one you intend, and is maintained, before installing it.

6. Secure the Build and the Artifact

Integrity means that what runs in production is exactly what the pipeline built from reviewed source.

  • Protect the source: branch protection, required reviews, signed commits for sensitive repositories, and limited write access.
  • Build in a controlled environment: ephemeral build runners, no manual builds for release, least-privilege credentials per job, and no secrets exposed to untrusted contributions.
  • Pin build tooling and pipeline steps to specific versions or digests, not mutable tags. A third-party pipeline step runs with your credentials.
  • Build once and promote by digest (as in the delivery course), so the artifact cannot change after testing.
  • Generate provenance: a signed statement recording what was built, from which source, by which pipeline, and when. Sign artifacts and verify the signature before deployment, so an image that did not come from your pipeline is refused.
  • Choose base images carefully: official or well-maintained minimal images, pinned by digest, scanned, and rebuilt regularly.
  • Keep an audit trail that links the running version to its commit, build, SBOM, scan results, and approvals (the traceability from the version management lesson).

Frameworks such as SLSA describe levels of build integrity you can work toward in steps; treat them as a roadmap, not a certificate to obtain in one sprint.

7. Policies and Ownership

Make the rules explicit and owned:

Policy Example content
Adding dependencies Criteria above; approval for new direct dependencies in sensitive areas
Updating Routine cadence; security updates within the remediation target; automated proposals reviewed like any change
Vulnerabilities Scan frequency, targets by priority, exception process
End of life Track runtimes and frameworks; plan replacement before support ends
Licenses Allowed and forbidden licenses; review process
Registries and sources Approved registries and proxies
Build and pipeline Pinned versions, permissions, signing and verification

Assign an owner for the policy and for the routine of reviewing alerts. An alert channel nobody reads protects nothing.

8. Using AI With Dependencies

AI can speed up evaluation and explanation, but supply chain is exactly where a confident wrong answer can hurt.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Act as a software supply chain security reviewer.

Inputs:
- Direct dependencies and lock file summary: [paste]
- SBOM or scan results for the latest build: [paste]
- Advisories relevant to our dependencies (from official
  sources): [paste]
- Description of how each affected component is used in our code:
  [paste]
- Our dependency policy and build pipeline description: [paste]

Tasks:
1. Group the vulnerabilities by affected component and root cause.
2. For each, assess likely reachability and exposure based on the
   usage description, and say what you would check to confirm.
3. Propose an update path with risks (breaking changes), using the
   advisory information provided.
4. Identify dependencies that appear unmaintained, unusually large,
   or redundant.
5. Review the pipeline description for places where an untrusted or
   mutable component could alter the build.
6. List questions that need answers from the official sources.

Use only the advisory information provided; do not state version
numbers or fix versions from memory. Mark uncertainty.

Rules for using AI here:

  • Never accept a package name, version, or fix version from the model without checking the official registry and advisory. Training data is out of date by definition.
  • Do not paste proprietary dependency details into unapproved tools.
  • Use AI to summarize changelogs and migration guides, then read the source for anything risky.
  • Do not let an assistant add dependencies unreviewed, and treat lock file changes in generated patches with the same care as code.

9. Practical Exercise

For SignalDesk (or your project):

  1. List the direct dependencies for each service and confirm lock files are committed.
  2. Generate an SBOM for each container image, store it with the artifact, and practice finding where one component is used.
  3. Run dependency and image scans, triage the top ten findings with context, and add confirmed ones to the findings register.
  4. Update one vulnerable dependency end to end: change, tests, re-scan, record.
  5. Write the dependency policy: adding, updating, vulnerability targets, end of life, licenses, and sources.
  6. Review the pipeline for mutable references, excessive permissions, and unpinned steps, and fix or log each.
  7. Decide how you will sign and verify artifacts, and record the plan and the current maturity.
  8. Run the AI supply chain review, verify every claim against official sources, and log corrections.

Verification

You are ready to continue when:

  • Every artifact has an SBOM linked to its version, and you can answer “where do we use component X?” quickly.
  • Lock files are committed, builds install from them, and pipeline steps and base images are pinned.
  • Vulnerable dependencies are triaged with context, with fixes verified or exceptions recorded with expiry.
  • The dependency policy has owners and a review routine.
  • No AI-suggested package or version was used without checking official sources.

Key Takeaways

  • You are responsible for the code you import, including what it imports in turn.
  • An SBOM turns “are we affected?” from a panic into a search.
  • Frequent small updates, backed by tests, are safer than rare large ones.
  • Pin, lock, verify, and limit build privileges to resist malicious packages and tampering.
  • Check every package and version an AI suggests; models invent names and go out of date.

What’s Next?

So far the analysis has been mostly tool-driven and structural. The next lesson focuses on human and AI review: reading code and configuration with a security mindset, including code that AI wrote.