DIGNALEGI

The reading room · Digna Legi

Hardening Container Images

A personal relevance score

80–100: high value. 70–79: worth the time. Below 70: below the usual publication threshold.

Evidence-reviewed score based on available publisher text. The argument relies on one PowerDNS Recursor image; the author notes some limits to its generalisability.

Scores reflect one reader’s profile, not an objective quality rating. Best is a separate personal selection.

How scoring works →

This brief · about 3 min with detail

Original article ↗

Why read this

Container hardening means reducing exploitable surface, post-compromise execution, unnoticed drift, and unverifiable builds, not merely shrinking an image.

AI brief · Checked against source text

The main idea

The author argues that hardening a container is not just shrinking it; it is reducing what can be exploited, what can execute after compromise, and what can go unnoticed. The PowerDNS Recursor image is rebuilt from source into a near-empty scratch image, constrained at runtime by Linux sandboxing, scanned through explicit dependency metadata, and signed so users can verify how it was built.

Technical reading. Containers, Linux isolation, CI pipelines, vulnerability scanning, and software supply-chain signing.

Go a little deeper

Removal changes the attacker’s workspace

The image moves from a full Debian-based filesystem to a scratch image containing only the compiled service binaries and a few support files. That matters because a successful exploit no longer lands in an environment with a shell, package tools, or a broad filesystem. The change denies post-compromise convenience while also reducing dependency-driven vulnerability noise.

Runtime policy catches what image minimalism cannot

The launcher applies Landlock, a Linux kernel feature for restricting filesystem and network access, before starting the service. The author also uses seccomp, a Linux facility that filters which system calls a process may invoke, with an allowlist generated by tracing real execution. This narrows escape routes such as unnecessary kernel interfaces and blocks a common fileless execution path by excluding memfd_create.

Freshness is treated as a build property

Instead of treating a version tag as one permanent artifact, the pipeline rebuilds the latest two stable release trains daily and pushes a new image when dependencies change. That means a tag such as 5.4.6 can receive security-relevant rebuilds without an upstream application version change, while hash-suffixed tags remain available for users who need exact reproducibility.

Supply-chain evidence makes scanners less blind

Because a scratch image lacks a normal distribution package database, scanners would otherwise find little. The build generates an SBOM, a Software Bill of Materials listing included components, in CycloneDX and SPDX formats, then attaches it with SLSA provenance, meaning build-origin metadata such as commit, Dockerfile, and arguments. OpenVEX, a vulnerability-exploitability statement, records which findings do not apply and why, reducing scanner noise without hiding new issues.

A case from the article

Signing detects a moved tag after registry compromise

The build receives a short-lived OIDC identity token, meaning an OpenID Connect proof from GitLab CI, exchanges it for a Fulcio certificate, and uses cosign, a Sigstore signing tool, to sign the multi-architecture image digest. Verification can then prove the image came from the stated GitLab pipeline on main, so a malicious Docker Hub tag move becomes detectable unless the GitLab account itself is compromised.

How the case is made

The case is made through a worked implementation of a trimmed PowerDNS Recursor image, with build, runtime, scanning, signing, and monitoring details.

Where the idea has limits

The author is maintaining this outside the upstream project, so new dependencies, features, or system-call needs can escape automation and require manual release review.

A question to take away · from Digna Legi

Which risks in your containers are reduced by removal, and which require continuous evidence that the build still means what it claims?

What the original adds

The source includes concrete Compose hardening options, daily rebuild/tagging policy, scanner workflow, signature verification command, and operational monitoring via a pipeline heartbeat.

About this brief

AI-written, then separately checked for source support, useful detail and clarity. The author’s claims and our editorial question are kept separate. The original remains the author’s work. How we select and summarise →

Digna legi. Worth reading.