Skip to content

Fix: image vulnerabilities - #124

Merged
Chmokachka merged 49 commits into
mainfrom
fix/image-vulnerabilities
Jun 12, 2026
Merged

Chmokachka merged 49 commits into
mainfrom
fix/image-vulnerabilities

Conversation

@Chmokachka

@Chmokachka Chmokachka commented May 18, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Drives all runpod/* images to a clean Grype / Hadolint scan, restructures CI so images are scanned before publish, and adds several stability/perf fixes to the build pipeline. Targets every image we ship out of official-templates/ and helper-templates/.

What's fixed

Image vulnerabilities (Grype --fail-on high, --only-fixed)

  • base — bumped jupyterlab, notebook, OpenSSH-related deps; pinned versions via a new requirements.txt. Stripped the efa_metrics directory from NVIDIA Nsight Compute. That directory ships an internal Go binary (nic_sampler) that NVIDIA builds with an old Go toolchain and was triggering recurring Go-stdlib HIGH/CRITICAL findings on every rebuild. The plugin is AWS-EFA-only (x86, AWS hardware) and never runs on RunPod, so deleting it is safe and the find ... || true guard keeps it a no-op on ROCm / CPU images.
  • autoresearch — Hadolint findings fixed; aligned with new base.
  • pytorch — Hadolint fixes.
  • rocm — addressed all fixable CVEs; pinned the relevant deps. The rocm644-ubuntu2204-pytorch251 variant is removed from the build matrix.
  • nvidia-pytorch — patched OS-package CVEs; added scrub-stale-metadata.py (see below) to remove orphan .dist-info / .egg-info trees that kept the scanner reporting fixed wheels as still-vulnerable.

Hadolint

  • All DL3008 / DL3009 / DL3015 findings fixed across the touched Dockerfiles (--no-install-recommends, apt-get clean && rm -rf /var/lib/apt/lists/*, version pins where reasonable).
  • hadolint-push workflow now ignores the rules already accepted project-wide (matches the PR check behaviour).

CI: scan-before-publish (addresses #122 (review))

Reworked all build workflows (base.yml, nvidia.yml, rocm.yml) into:
docker buildx bake (load: true, push: false) → Extract refs → Grype scan → docker-push composite action

Grype is intentionally still report-only — flipping --fail-on to a non-zero exit later turns this into a real gate with no further restructuring.

CI: stability & throughput (load: true was risky on big matrices)

load: true materializes every bake target into the local Docker daemon before push, which on the pytorch matrix (~25 multi-GB CUDA/torch images) was at risk of ENOSPC and was making the "loading layer" step slow. Mitigations:

  • Enabled containerd-snapshotter in .github/actions/docker-setup. With the default overlay2, BuildKit has to re-import every layer into the daemon's image store after the build. With containerd-snapshotter the daemon and BuildKit share one image store, so the "loading layer" step is effectively free. Verified active in a follow-up check that fails the job if the snapshotter isn't picked up.
  • pytorch Dockerfile: switched pip install to a BuildKit cache mount (--mount=type=cache,target=/root/.cache/pip,sharing=locked) and dropped --no-cache-dir. Parallel matrix targets (5 CUDA × Ubuntu variants) no longer fetch the same torch / cuDNN / cuBLAS wheels independently — they share the wheel cache, and it survives across CI runs via sticky-disk. Resolves the IncompleteRead failures we were seeing on pytorch.org under bandwidth contention.
  • autoresearch Dockerfile: same shape, but for uv — added --mount=type=cache,target=/root/.cache/uv,sharing=locked and bumped UV_HTTP_TIMEOUT from the 30s default to 1000s. Resolves the Failed to download torch==2.9.1+cu128 ... network timeout failures.
  • Larger runners (blacksmith-32vcpu) and bumped timeout-minutes on the pytorch matrix, which was previously being killed before completion.

CI: misc

  • Upgraded GitHub Actions versions across nvidia.yml, rocm.yml, hadolint-pr.yml, hadolint-push.yml.
  • Fixed docker/setup-qemu-action invocation that broke after the action's input rename.
  • Pinned RUNPODCTL_VERSION=v2.3.0 in base/Dockerfile to stop tracking latest.
  • autoresearch / pytorch push steps are correctly gated on steps.changes so they only run when their template directories actually changed.

New: scripts/scrub-stale-metadata.py

Small helper invoked by Dockerfiles after pip install. NGC base images bundle several Python packages as in-tree source builds whose .egg-info lives next to the source. pip install --upgrade upgrades the wheel install but cannot reach those bundled trees, so the scanner keeps reporting the old version even though the runtime resolves to the new one. The script reads our pinned requirements.txt and deletes any .dist-info / .egg-info whose Version: disagrees with the pin.

What's NOT fixed (deliberate)

Two classes of findings remain across the matrix — both blocked on upstream work, neither actionable from this PR:

1. filebrowser Go transitive deps — affects every image that ships filebrowser

The filebrowser binary (installed via the official get.sh) is statically linked against vulnerable versions of golang.org/x/crypto, golang.org/x/net, and golang.org/x/image. Grype reports 13 HIGH/CRITICAL Go advisories for it on every rebuild:

ID Severity Module Installed Fixed in
GO-2026-5005 / 5006 / 5013 / 5017 / 5018 / 5019 / 5020 / 5021 / 5023 Critical / High golang.org/x/crypto v0.50.0 v0.52.0
GO-2026-4918 / 5026 High / Critical golang.org/x/net v0.52.0 v0.53.0 / v0.55.0
GO-2026-5032 High golang.org/x/image v0.39.0 v0.41.0

These can only be cleared by rebuilding filebrowser itself against bumped Go modules. The dependency bumps are already queued in the renovate batch filebrowser#5946. Our images will inherit the fix automatically on the next filebrowser release — no change needed on our side.

2. autoresearch Python transitive deps — affects runpod/autoresearch:* (both ubuntu2204 and ubuntu2404)

Package Installed Fixed in Severity Advisory
pillow 12.1.1 12.2.0 High GHSA-pwv6-vv43-88gr
pillow 12.1.1 12.2.0 High GHSA-whj4-6x5x-4v2j
urllib3 2.6.3 2.7.0 High GHSA-mf9v-mfxr-j63j
urllib3 2.6.3 2.7.0 High GHSA-qccp-gfcp-xxvc

These come from autoresearch's own pyproject.toml / uv.lock and need an app-level dependency upgrade in the autoresearch repo. Out of scope for this PR; tracked separately as a follow-up task.
Everything else is now clean.

Follow-ups (separate PRs)

  • Flip Grype to fail-on for HIGH/CRITICAL with fixed versions, turning the current scan ordering into a hard gate.
  • Bump filebrowser version once filebrowser#5946 is released — clears all 13 Go advisories above.
  • Open autoresearch-side PR to upgrade pillow and urllib3.

@Chmokachka
Chmokachka changed the base branch from main to feat/image-security-scanner May 18, 2026 13:19
@blacksmith-sh

This comment has been minimized.

@blacksmith-sh

This comment has been minimized.

@Chmokachka
Chmokachka marked this pull request as ready for review May 21, 2026 21:01

@TimPietruskyRunPod TimPietruskyRunPod left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded — see the Changes Requested review below.

Correction: my earlier note here claimed nvidia-pytorch "now ships Jupyter." That was wrong — the image always had Jupyter; dropping RP_SKIP_JUPYTER just lets RunPod manage/patch it. Please disregard this review.

@TimPietruskyRunPod TimPietruskyRunPod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes — a few quality fixes (details inline). The stale-metadata approach, the efa_metrics strip, and the version pins all look good, and this PR also resolves the missing if: guard I flagged on #122.

  • scrab_stale_metadata typo (bake files + COPY --from=).
  • scrub-stale-metadata.py uses 3.10+ annotation syntax + an unimported Iterator.
  • Trailing space / missing newline in the new requirements.txt files.

Comment thread official-templates/base/docker-bake.hcl Resolved
Comment thread official-templates/base/Dockerfile Resolved
Comment thread scripts/scrub-stale-metadata.py Resolved

@TimPietruskyRunPod TimPietruskyRunPod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All four requested changes are in and verified (scrub typo across the bake files + Dockerfile, from __future__ import annotations + proper Iterator import in scrub-stale-metadata.py, and the requirements.txt whitespace/newline fixes). Threads resolved. Thanks!

Base automatically changed from feat/image-security-scanner to main June 8, 2026 19:25
@blacksmith-sh

This comment has been minimized.

@TimPietruskyRunPod TimPietruskyRunPod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the new commits added since my approval (feat: push after grype + feat: pytorch timeout-minutes). Summary:

Good — this is a real improvement. Build now runs with load: true, push: false, then Extract refs → Grype → the new docker-push action, consistently across base/nvidia/rocm. So images are scanned before publish — the "scan before push" gap from the original review is now structurally closed. The autoresearch/pytorch push steps are correctly gated by steps.changes (same job that owns the changes step), and the docker-push composite action is sound (set -euo pipefail, fails on empty refs).

One concern to confirm before merge (inline): load: true materializes every image in the bake matrix into the runner's local Docker daemon before pushing. build-nvidia (single image) passed, but base and pytorch build large matrices of multi-GB CUDA/torch images — loading them all at once risks exhausting runner disk (ENOSPC). The current run is the first with load: true on those matrices and build-base/build-rocm are still in progress; worth watching them specifically. The blacksmith-32vcpu + timeout-minutes: 240 bump helps CPU/time but not disk.

Note: grype is still report-only by design, so push isn't actually blocked on findings yet — but the ordering means flipping the exit 1 later turns it into a real gate with no further restructuring. Fine as a foundation.

No blocking objection from me on the design; just confirm the base/pytorch runs go green with load: true.

official-templates/shared/versions.hcl
official-templates/base/docker-bake.hcl
push: true
load: true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

load: true imports the entire bake matrix into the runner's local Docker daemon before the push step. For the base CUDA matrix (and especially the pytorch matrix of ~25 multi-GB CUDA/torch images) this can blow the runner's disk (ENOSPC) since all images coexist locally instead of streaming straight to the registry. nvidia (1 image) is fine; please confirm build-base/build-pytorch actually pass with this. If disk becomes the bottleneck, consider load→scan→push→docker image rm per ref (or per small batch) so they don't all pile up at once.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still experimenting with load: true, as it really blows the runner's disk. Moving the PR back to draft until I'm done with it.

@Chmokachka
Chmokachka marked this pull request as draft June 10, 2026 09:41
@Chmokachka
Chmokachka marked this pull request as ready for review June 11, 2026 15:03

@TimPietruskyRunPod TimPietruskyRunPod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed at the current head after the rebase onto main + push-after-grype rework. All build jobs are green with load: true (base ~1h40m, pytorch ~5h, rocm ~2h30m), so the disk concern from my earlier comment did not materialize — resolving it. Note pytorch is brushing ~5h, so the matrix is slow under load: true, but it passes. Approving.

@Chmokachka
Chmokachka merged commit 086047c into main Jun 12, 2026
14 checks passed
@Chmokachka
Chmokachka deleted the fix/image-vulnerabilities branch June 12, 2026 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants