Skip to content

build(container): minimize build-stage images and reorganize CVE catalog - #2007

Merged
josecelano merged 11 commits into
torrust:developfrom
josecelano:1463-1457-use-rust-slim-builder-image
Jul 21, 2026
Merged

josecelano merged 11 commits into
torrust:developfrom
josecelano:1463-1457-use-rust-slim-builder-image

Conversation

@josecelano

Copy link
Copy Markdown
Member

Description

Minimize the three foundational Containerfile build stages (chef, tester, gcc) by switching to slimmer base images and removing unnecessary dependencies. Reduces build-image size, installed package inventory, vulnerability exposure, and maintenance burden without weakening build or test coverage.

Changes

  • chef stage: rust:trixie → rust:slim-trixie with three demonstrated native deps (curl, libssl-dev, pkg-config). Reduces from 1,662.7 MB / 455 packages / 2,148 findings to 1,067.4 MB / 145 packages / 1,072 findings.
  • tester stage: Consolidated APT layer, removed setup-only curl after cargo-nextest installation. Retains only sqlite3, time, and cargo-nextest. Finalizes at 975.9 MB / 123 packages / 1,014 findings.
  • gcc stage: gcc:trixie → debian:trixie-slim with only gcc and libc6-dev. Reduces from 1,556.4 MB / 464 packages / 2,165 findings to 274.3 MB / 114 packages / 1,008 findings.
  • CVE catalog: Reorganized from flat non-affecting/ folder into impact-context subdirectories (production/, build/) with per-CVE files and updated cross-references.
  • Security scans: New consolidated build-images.md scan history for ephemeral build stages. Production release scan refreshed confirming no regression (5 MEDIUM, 0 HIGH, 0 CRITICAL).

Each stage was implemented, validated, and committed independently. Containerized tests passed for every stage.

Related to #1463, #1457

Copilot AI review requested due to automatic review settings July 20, 2026 17:19
@josecelano
josecelano requested a review from a team as a code owner July 20, 2026 17:19
@josecelano josecelano self-assigned this Jul 20, 2026
josecelano added a commit to josecelano/torrust-tracker that referenced this pull request Jul 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces the dependency footprint and CVE exposure of the Containerfile build stages (chef, tester, gcc) by switching to slimmer base images and tightening installed APT packages, and it reorganizes the security CVE catalog to separate production-runtime vs build-stage analyses.

Changes:

  • Switched chef to rust:slim-trixie with only the minimal native dependencies needed for tool installation/builds.
  • Minimized tester by consolidating the APT/tooling install into one layer and removing setup-only curl.
  • Replaced gcc:trixie with debian:trixie-slim + minimal compiler headers, and reorganized/expanded security scan & CVE analysis documentation.

Reviewed changes

Copilot reviewed 12 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Containerfile Minimizes foundational build stages via slimmer base images and reduced APT installs.
project-words.txt Adds dpkg to the cspell project dictionary.
docs/security/README.md Updates security documentation pointers for the reorganized CVE catalog.
docs/security/docker/README.md Documents how to run build-stage security scans and where to record results.
docs/security/docker/scans/README.md Splits scan reporting between production exposure and build-stage exposure.
docs/security/docker/scans/torrust-tracker.md Refreshes production image scan history with the post-change verification.
docs/security/docker/scans/build-images.md Adds consolidated scan history for the chef/tester/gcc build stages.
docs/security/analysis/README.md Reorganizes the analysis index/process to use production/ and build/ subcatalogs.
docs/security/analysis/build/2026-06-10_containerfile-trixie-cves.md Updates build-stage triage evidence and references for the new minimized stages.
docs/security/analysis/production/CVE-2026-5435.md Adds per-CVE production-runtime non-affecting analysis entry.
docs/security/analysis/production/CVE-2026-5450.md Adds per-CVE production-runtime non-affecting analysis entry.
docs/security/analysis/production/CVE-2026-5928.md Adds per-CVE production-runtime non-affecting analysis entry.
docs/security/analysis/production/CVE-2026-6238.md Adds per-CVE production-runtime non-affecting analysis entry.
docs/security/analysis/production/CVE-2026-27171.md Adds per-CVE production-runtime non-affecting analysis entry.
docs/issues/open/1463-1457-use-rust-slim-builder-image.md Adds an issue spec capturing the rationale, measurements, and verification steps.
.github/skills/dev/maintenance/catalog-security-vulnerabilities/SKILL.md Updates the skill to reflect the new CVE catalog structure.
.github/skills/dev/maintenance/run-manual-docker-security-scan/SKILL.md Updates the scan skill to reflect the new CVE catalog structure.
Comments suppressed due to low confidence (1)

docs/security/analysis/build/2026-06-10_containerfile-trixie-cves.md:3

  • The frontmatter date-analyzed is set to 2026-07-20, but this bulk-triage file is explicitly dated 2026-06-10 in its filename and referenced that way elsewhere. Keeping date-analyzed aligned with the filename avoids confusion when grepping/sorting by date; the 2026-07-20 refresh is already captured in the document’s change log.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/security/analysis/README.md Resolved
@josecelano
josecelano force-pushed the 1463-1457-use-rust-slim-builder-image branch from 0751c6a to 84d58d5 Compare July 20, 2026 17:25
Copilot AI review requested due to automatic review settings July 20, 2026 18:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 18 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

docs/security/analysis/build/2026-06-10_containerfile-trixie-cves.md:4

  • The frontmatter date-analyzed is now 2026-07-20, but the filename and changelog indicate the analysis was originally created on 2026-06-10 and later refreshed. To avoid confusion when scanning the catalog by filename/date, consider recording the original analysis date explicitly in frontmatter (or alternatively renaming the file and updating references).

Comment thread Containerfile Resolved
Comment thread Containerfile Resolved
Comment thread Containerfile Resolved
Copilot AI review requested due to automatic review settings July 20, 2026 19:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 18 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (1)

docs/security/analysis/build/2026-06-10_containerfile-trixie-cves.md:3

  • The file name and changelog indicate this analysis was created on 2026-06-10, but frontmatter date-analyzed was changed to 2026-07-20. That makes it unclear whether date-analyzed means ‘initial analysis’ or ‘last refresh’. Keep date-analyzed aligned with the original analysis date and rely on the changelog for later updates.

Comment thread Containerfile Resolved
Comment thread project-words.txt Resolved
Comment thread docs/security/README.md Resolved
Comment thread Containerfile Resolved
…pin cargo-nextest, fix cspell, update security README
Copilot AI review requested due to automatic review settings July 20, 2026 20:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 18 changed files in this pull request and generated 2 comments.

Comment thread docs/security/docker/scans/README.md Resolved
Copilot AI review requested due to automatic review settings July 21, 2026 08:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 18 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

docs/security/analysis/build/2026-06-10_containerfile-trixie-cves.md:7

  • The file name suggests this is the 2026-06-10 bulk scan/event record, but the frontmatter and body now describe a 2026-07-20 scan (e.g., date-analyzed: 2026-07-20). In docs/security/analysis/README.md the convention for bulk scan/event files is {date}_{source}.md, so this mismatch makes the catalog harder to navigate chronologically. Consider moving this updated analysis into a new file named with the new scan date (and leaving the original 2026-06-10 record intact), then update inbound links accordingly.

@josecelano

Copy link
Copy Markdown
Member Author

ACK a20ef3b

@josecelano
josecelano merged commit dc7ec02 into torrust:develop Jul 21, 2026
18 checks passed

@da2ce7 da2ce7 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.

This is a post-merge review of #2007 as its change stands at e170b96 on the default branch.

What still runs: the chef stage builds on rust:slim-trixie and installs only curl, libssl-dev and pkg-config (Containerfile:14-26); the tester stage installs sqlite3, time and [email protected] in one layer and purges curl afterwards (Containerfile:44-50); the gcc stage compiles su-exec on debian:trixie-slim with only gcc and libc6-dev (Containerfile:60-67). Later commits moved torrust-cargo-chef from 0.1.78 to 0.1.79 and added the CARGO_BUILD_JOBS cap; the base images, package lists and cargo-nextest pins are as merged. The CVE catalog keeps the production/ and build/ layout this change introduced.

[Minor] The catalog move left references to the old layout, although the description says the cross-references were updated. docs/adrs/20260603000000_keep_unit_tests_inside_container_build.md:9 (a semantic-links.related-artifacts entry) and docs/adrs/20260603000000_keep_unit_tests_inside_container_build.md:97 (the pointer from the ADR's security rationale to the build-stage analysis) both name docs/security/analysis/non-affecting/2026-06-10_containerfile-trixie-cves.md, which does not exist at e170b96; the file is docs/security/analysis/build/2026-06-10_containerfile-trixie-cves.md. A reader who follows the ADR to the analysis finds nothing, and the frontmatter validator resolves related-artifacts paths only for issue and epic specs in the draft and open folders (contrib/dev-tools/checks/frontmatter-validator/src/repository.rs:147), so no check reports it. In the moved analysis itself, docs/security/analysis/build/2026-06-10_containerfile-trixie-cves.md:91 still says the tested binary is produced by rust:trixie, which this change replaced with rust:slim-trixie in the same file's tables. Smallest fix: point both ADR lines at the build/ path and change rust:trixie to rust:slim-trixie on line 91.

[Nit] [email protected] is written twice: at Containerfile:28 in chef, whose descendants run cargo nextest archive, and at Containerfile:47 in tester, whose descendants run cargo nextest run --archive-file on those archives. Nothing ties the two lines together, and the repository's dependency-update configuration covers only GitHub Actions and Cargo, so a later bump of one line alone brings back the version skew between the producer and the consumer of the archive that the pin was added to remove. Smallest fix: declare ARG CARGO_NEXTEST_VERSION=0.9.140 once before the first FROM, redeclare ARG CARGO_NEXTEST_VERSION in both stages and install cargo-nextest@${CARGO_NEXTEST_VERSION}.

[Nit] The curl ... | bash pipe at Containerfile:46 runs under /bin/sh without pipefail, so the pipeline's status is that of bash: a failed download exits 0 and the layer fails one command later with cargo's unknown-command error for binstall, not at the download, and a transfer that breaks mid-stream lets bash run a truncated prefix of the installer. .hadolint.yaml:34-37 waives DL4006 because pipefail would require installing bash in every build stage, but the two stages that pipe (Containerfile:27 and Containerfile:46) already pipe into bash, so it is present in both. Smallest fix: add SHELL ["/bin/bash", "-o", "pipefail", "-c"] to the chef and tester stages and reword the DL4006 rationale to match.

Checked and found sound: the slim chef image covers the native build needs of the lockfile at e170b96 (the sqlite feature of sqlx bundles SQLite, openssl-sys finds libssl-dev through pkg-config, aws-lc-sys, ring and zstd-sys build with the C compiler the slim Rust image keeps, and there are no git dependencies or workspace build scripts); apt-get purge --auto-remove curl in tester removes only what curl pulled in, leaving the TLS libraries the tests load and the libz.so.1 that Containerfile:233-234 copies into the shipped image; debian:trixie-slim with gcc and libc6-dev provides the cc and headers that su-exec.c needs; the runtime stage and what it copies from the build stages are unchanged; the cargo-nextest pins match each other at e170b96; and the unpinned installer URL on main at Containerfile:27 and Containerfile:46 is a trade-off the project records in .hadolint.yaml:39-48.

This branch was previously deployed

1 inactive deployment
coverage — a20ef3b8 Deployed Jul 21, 2026 by josecelano via Generate Coverage Report #1615
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.

Docker Security Overhaul: Consider using docker.io/library/rust:slim-trixie

3 participants