Skip to content

ADR-026: Advisory CI Vulnerability Scanning

Status

accepted

Date

2026-05-09

Reader boundary

This Explanation records design reasons and constraints. Dated examples, versions, estimates, and measurements describe their stated revision. They do not establish current interface support or installed qualification. The CI explanation describes maintained use. The record's status and amendments still determine its decision scope.

Context

APTL already runs a single GitHub Actions Checks workflow for quality and security feedback. The workflow includes pre-commit, Python tests, MCP and web vitest coverage, an advisory dependency audit, and advisory SonarCloud analysis.

Issue #278 adds Trivy and OSV-scanner coverage:

  • Trivy for lab container images under web/ and containers/, plus filesystem and IaC scanning where relevant.
  • OSV-scanner for the root uv.lock dependency graph.
  • SARIF, JSON, or equivalent scan artifacts, with advisory behavior.

The lab intentionally contains vulnerable targets and research tooling. Scanner findings are therefore signal for triage, not an automatic release or merge gate.

Decision

Add Trivy and OSV-scanner as advisory CI scanners in the existing GitHub Actions checks surface. They extend the current CI security feedback loop; they do not introduce a new release gate, runtime security service, policy engine, or lab configuration schema.

Boundaries

  • Keep scanner jobs in the existing CI workflow unless there is a concrete operational reason to split workflows.
  • Preserve advisory semantics with explicit non-failing behavior (--exit-code 0, continue-on-error: true, or the scanner's equivalent).
  • Publish scan output as short-retention GitHub Actions artifacts, consistent with existing coverage artifacts.
  • Keep GitHub token permissions minimal. Do not add security-events: write unless the implementation intentionally uploads SARIF to GitHub code scanning, not merely as an artifact.
  • Treat OSV-scanner as the authoritative check for uv.lock; do not duplicate a second Python lockfile parser in scripts.
  • Treat Trivy as the authoritative scanner for container images and filesystem/IaC checks; do not add custom Dockerfile, Compose, or Terraform parsing logic.
  • Do not rebuild and scan the Kali image on every PR or protected-branch push. The Kali image is intentionally noisy because it is a rolling security-tooling distribution; scan it when files under containers/kali/ change, or when the workflow itself changes.

Consequences

Positive

  • Container image, filesystem, IaC, and Python lockfile vulnerability feedback is visible on every PR and protected-branch push.
  • Advisory behavior matches SonarCloud and existing dependency-audit semantics, avoiding false merge blockers from intentionally vulnerable lab assets.
  • Scanner output is retained as CI evidence without adding repo-local state.

Negative

  • CI time and network dependency increase because images and vulnerability databases must be built or fetched.
  • Advisory scans can be ignored unless maintainers actively review artifacts and job summaries.

Risks

  • Trivy image scans can become expensive if every Dockerfile is built independently without cache-aware job structure.
  • The Kali image can dominate scan noise because most findings come from the upstream tool distribution rather than APTL-owned code. Triage applies when LilRAE changes Kali images, exposes operator data, weakens isolation, or adds an owned package that can be updated.
  • Scanning built images, filesystems, and IaC are related but distinct concerns; conflating them can hide coverage gaps.
  • SARIF upload to GitHub code scanning changes the permission and visibility model. Artifact-only SARIF does not require that broader permission.
  • The existing dependency-audit job already runs pip-audit and npm audit. OSV-scanner should complement that job for uv.lock, not be wired as a replacement for all ecosystem audits unless that is decided separately.

Amendment: OpenSSF Scorecard and dependency pinning (issue #847)

Issue #847 adds OpenSSF Scorecard. Two parts of this ADR need qualifying.

Scorecard runs in its own workflow

The boundary above says to keep scanner jobs in the existing Checks workflow "unless there is a concrete operational reason to split workflows." Scorecard is that concrete reason, and the only one so far.

publish_results: true enables Scorecard publisher validation. It rejects workflow or job env and defaults, workflow write permissions, non-Ubuntu runners, and unapproved actions. checks.yml violates several of those by design. Folding the publisher into it would make a fragile contract that breaks the next time an unrelated job needs an env block. The publisher also needs id-token: write, which must not sit at workflow scope where every other job would inherit it.

.github/workflows/scorecard.yml therefore runs alone, triggered only by pushes to main and a weekly schedule.

Scorecard is advisory, and its score is not a vulnerability count

Scorecard is a repository and supply chain posture assessment. It does not replace Trivy, OSV-scanner, pip-audit, or npm audit, which remain the authoritative scanners for their surfaces. The aggregate score is not a merge gate. A default-branch workflow cannot reliably supply a pull-request status.

Findings are triaged per check, at the detail level, never from the aggregate score. Contributors, Code-Review, CII-Best-Practices, and Branch-Protection describe governance or process. Editing a file to appear compliant does not correct those facts. In particular, .github/branch-protection-baseline.json documents intent; the live GitHub repository rules are authoritative, and editing the JSON is not remediation.

Dependencies are pinned by content, not by label

security-events: write is requested only for the Scorecard job's intentional SARIF upload to GitHub Code Scanning. This is the publication exception already described by this ADR.

Beyond the scanners, #847 makes the pinning itself an invariant:

  • Container base images are pinned by digest, with Dependabot docker entries so the digests are refreshed rather than frozen.
  • Node installs use npm ci, which honors the lockfile and fails on drift.
  • Python installs use pip install --require-hashes -r requirements/<x>.txt. astral-sh/uv-pre-commit generates the exports from uv.lock. They are not hand-edited. The required CI hook job regenerates them and rejects stale output.
  • Release artifacts carry a SLSA build-provenance attestation, and the bundle is attached to the GitHub release so a downloaded artifact can be verified.

tests/test_supply_chain_pinning.py and tests/test_hashed_requirements.py enforce these as structural gates, so the properties survive without depending on a reviewer noticing.

Two pip invocations are deliberately not hash-pinned, each for a stated reason rather than convenience:

  • appliance/guest/provision-offline.sh installs with --no-index from a staged wheelhouse inside a content-identified payload, at an exact == version. No index is contacted, so there is no mutable upstream for a hash to protect. The test asserts --no-index and the version pin, so removing either fails rather than silently reopening a network fetch.
  • scenarios/fixtures/techvault-content/.../deploy.sh is fake corporate content a red-team agent discovers on a compromised host. It is never executed by a build. Hash-pinning it would make the prop read as machine-generated and degrade the scenario, which is the product. Per this ADR's existing guidance, a designed lab weakness is preserved while real supply chain components are repaired.

Amendment (2026-09-20): Required platform dependency audit (issue #969)

The advisory decision above continues to govern the mixed target, image, filesystem, IaC, and OSV scanner jobs. The existing Dependency vulnerability scan job now has a narrower blocking duty for the platform that handles operator credentials and host resources. The job audits hash-pinned Python runtime, web, and CI/build exports.

It also audits production dependencies in every MCP package and the web control plane. Python known vulnerabilities and high or critical npm findings fail the job. Lock or scanner failures also fail it.

The job is a required dev pull-request context.

Intentionally vulnerable lab targets remain outside that blocking dependency surface and retain advisory scanner feedback. A target's teaching purpose does not exempt a dependency in the CLI, API, web control plane, MCP broker, or build path. There are no active platform vulnerability exceptions. A temporary exception belongs beside its scanner command or affected manifest. It names the advisory, dependency version, affected component, reason, owner, and removal condition. It must not suppress an entire package family, lower the global threshold, or turn scanner failure into success.

The checked-in branch-protection baseline records the required context names; the live GitHub dev branch settings enforce them. The bounded installed-wheel smoke and the profile it supports are described in platform-pr-gates.md.

Amendment (2026-10-04): Blocking scanner gates with tracked unfixed findings (issue #1193)

This amendment supersedes the advisory decision for the Trivy filesystem, IaC, and image scans and for OSV-scanner. An advisory scanner reported thousands of image findings for months without a gate ever failing, which is the "advisory scans can be ignored" risk above, realized. Two premises no longer hold.

The scanned images are platform and generic substrate images. Since ADR-048, scenario declarations supply teaching vulnerabilities. These images are not exempt merely because the lab contains vulnerable targets.

Second, "artifact-only SARIF" lost track of findings after seven days.

Each scan now does two separate things:

  • Track. It records every CRITICAL, HIGH, and MEDIUM finding as SARIF, including vulnerabilities with no upstream fix yet. The SARIF goes to a short-retention artifact and to GitHub code scanning, so that job requests security-events: write. A code-scanning alert stays open until a scan no longer reports the finding. That is how an upstream problem with no fix stays visible until one ships. Fork and Dependabot pull requests get a token that cannot write security events, so they skip only the upload.
  • Gate. The job fails on any vulnerability at those severities that has an available fix, on any secret, and on any IaC misconfiguration. An unfixed vulnerability cannot be resolved by an upgrade, so it does not fail the gate. Once a fix is published, the next scan fails until the image or lock takes it. Remove a vulnerable package an image does not need rather than waiting.

trivy-image builds each local Dockerfile in a separate matrix job. A derived image builds its parent first and names that exact build. The aggregate Trivy image scan job is the single required context for the matrix, so adding an image adds it to the gate. OSV-scanner fails on any finding in uv.lock, and the RAES scenario validation gate, advisory during its Phase A, blocks as well. All of these are required dev contexts in the checked-in branch-protection baseline.

.trivyignore.yaml holds the only waivers. Each names one rule, the exact Dockerfiles it applies to, and the reason the finding cannot be fixed there. DS-0002 concerns image processes that run as root. Exceptions cover required UID-0 processes: systemd, materialized substrates, sshd privilege separation, Suricata packet capture with its co-located Wazuh agent, and the nftables helper. Every other image sets a non-root USER. The file also records exact-version exceptions for vendored pip and npm vulnerabilities without an available fixed release.

A waiver never covers a whole rule, severity, or directory, and never covers a vulnerability whose fix the image can take. Misconfiguration waivers are permanent design decisions and also apply to the IaC record. Vulnerability waivers relax only the gate, so those findings stay open in code scanning until an upstream release fixes them.

Issue #1468 also records CVE-2026-114613 as not affected for pip's exact vendored MessagePack version. The upstream advisory identifies the compiled extension as affected and the Python fallback as unaffected. The Debian substrate build asserts that pip uses the fallback. This entry does not cover a standalone MessagePack installation. The Caddy build takes the available go-jose v4.1.6 fix for CVE-2026-116587.