<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Todd Matens</title>
    <description>The latest articles on DEV Community by Todd Matens (@tmatens).</description>
    <link>https://dev.to/tmatens</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3946817%2F30ab95dc-17d7-4d40-9619-d451224e9093.png</url>
      <title>DEV Community: Todd Matens</title>
      <link>https://dev.to/tmatens</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tmatens"/>
    <language>en</language>
    <item>
      <title>Docker Compose security: hardening one file, from 12 findings to none</title>
      <dc:creator>Todd Matens</dc:creator>
      <pubDate>Tue, 17 Nov 2026 14:00:00 +0000</pubDate>
      <link>https://dev.to/tmatens/docker-compose-security-hardening-one-file-from-12-findings-to-none-4hl7</link>
      <guid>https://dev.to/tmatens/docker-compose-security-hardening-one-file-from-12-findings-to-none-4hl7</guid>
      <description>&lt;p&gt;Earlier this year I ran &lt;a href="https://tmatens.github.io/compose-lint/" rel="noopener noreferrer"&gt;compose-lint&lt;/a&gt;, a security linter for Docker Compose files that I maintain, against 11,111 public Compose files from GitHub. Of the ones that parsed, 99.2% had at least one security finding. I don't think that says much about the people who wrote them. Docker gives a container some protection by default, but most of the optional hardening is left for you to turn on, and most of the examples people copy from don't.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tmatens.github.io/compose-lint/state-of-compose/" rel="noopener noreferrer"&gt;The study&lt;/a&gt; shows how common each gap is, but it doesn't show how to close them. That's what this post is for. I took an ordinary two-service file, nginx in front of Postgres, and hardened it one setting at a time. For each step I show the change, explain why it matters, and give the share of files in the study that skip it. Every percentage is a share of the 5,907 files that parsed. The finished file is at the end, with a checklist.&lt;/p&gt;

&lt;p&gt;Some of these settings will break a service the first time you turn them on, and I've tried to say where. The capability lists and tmpfs paths in this post come from testing against running containers.&lt;/p&gt;

&lt;p&gt;None of these findings is a vulnerability on its own. Most of the steps limit what someone can do after they already have code running in one of your containers. A few, like credentials and published ports, are about what's exposed before that.&lt;/p&gt;

&lt;p&gt;Each step links to a rule page that has the details, the error messages you'll see when something breaks, and the exceptions.&lt;/p&gt;

&lt;h2&gt;
  
  
  The starting file
&lt;/h2&gt;

&lt;p&gt;Here's a two-service stack, written the way most of them are:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;web&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:latest&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"8080:80"&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./site:/usr/share/nginx/html&lt;/span&gt;
    &lt;span class="na"&gt;depends_on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;db&lt;/span&gt;

  &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres:16&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hunter2&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;pgdata:/var/lib/postgresql/data&lt;/span&gt;

&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;pgdata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nothing in it is unusual. When I run &lt;code&gt;compose-lint check --fail-on low&lt;/code&gt; on it, I get twelve findings: one HIGH, nine MEDIUM and two LOW. The first seven steps below clear all twelve. The rest cover things this file doesn't do but plenty of others do.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Get credentials out of &lt;code&gt;environment:&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;In the study, 28.2% of files have a credential-shaped key with a literal value, and 5.1% have a password inside a connection string.&lt;/p&gt;

&lt;p&gt;A value in &lt;code&gt;environment:&lt;/code&gt; has three problems. Anything that can read container metadata through the Docker API gets it from &lt;code&gt;docker inspect&lt;/code&gt;, and that includes monitoring agents that were only given read access. Processes in the container running as the same user can read it from &lt;code&gt;/proc/&amp;lt;pid&amp;gt;/environ&lt;/code&gt;. And it's in git for whoever reads the file.&lt;/p&gt;

&lt;p&gt;Compose's &lt;code&gt;secrets:&lt;/code&gt; element mounts the value as a file at &lt;code&gt;/run/secrets/&amp;lt;name&amp;gt;&lt;/code&gt;, so it stays out of the environment, the daemon's metadata and process listings. Images that follow the &lt;code&gt;*_FILE&lt;/code&gt; convention (Postgres, MySQL, MariaDB, the Bitnami images and many others) make it a small change. It works outside Swarm. On a single host, a file-sourced secret is a read-only bind mount of that file.&lt;/p&gt;

&lt;p&gt;This doesn't protect the value from someone who has full control of Docker on the host. They can read the file as easily as the variable, and the file is plain text on disk. What it does is keep the value out of the places that leak more often: inspect output, the environment every child process inherits, and anything that writes its environment to a log.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Before
&lt;/span&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres:16&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;hunter2&lt;/span&gt;

&lt;span class="c1"&gt;# After
&lt;/span&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres:16&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_PASSWORD_FILE&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/run/secrets/db_password&lt;/span&gt;
    &lt;span class="na"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;db_password&lt;/span&gt;

&lt;span class="na"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;db_password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./secrets/db_password.txt&lt;/span&gt;   &lt;span class="c1"&gt;# add to .gitignore
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The secret file is an ordinary file you create on the host, next to the Compose file. It holds only the value, with no &lt;code&gt;KEY=&lt;/code&gt; prefix, no quotes and no trailing newline:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mkdir -p secrets
openssl rand -base64 32 &lt;span class="o"&gt;|&lt;/span&gt; tr -d &lt;span class="s1"&gt;'\n'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; secrets/db_password.txt
chmod 600 secrets/db_password.txt
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'secrets/'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; .gitignore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the same password also goes into a connection URL, generate it with &lt;code&gt;openssl rand -hex 32&lt;/code&gt;. Base64 output can contain &lt;code&gt;/&lt;/code&gt;, which ends the host part of a URL.&lt;/p&gt;

&lt;p&gt;Before you rely on it, check these:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;An existing database keeps its old password.&lt;/strong&gt; The postgres image reads the password once, when it initializes an empty data directory. For a database that already holds data, put its current password in the file. The &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0020/" rel="noopener noreferrer"&gt;CL-0020&lt;/a&gt; page has a section on this.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The file is mounted byte for byte, with the host file's owner and mode.&lt;/strong&gt; A line like &lt;code&gt;KEY=value&lt;/code&gt; would become the whole password, and the process in the container has to be able to open the file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;env_file:&lt;/code&gt; has the same exposure.&lt;/strong&gt; Its values land in the process environment the same way &lt;code&gt;environment:&lt;/code&gt; values do, and keeping the file out of git doesn't change that.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;So does a connection string with a password inside,&lt;/strong&gt; like &lt;code&gt;postgresql://app:hunter2@db/app&lt;/code&gt;. The &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0021/" rel="noopener noreferrer"&gt;CL-0021&lt;/a&gt; page gives three ways to take the password out.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rules: &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0020/" rel="noopener noreferrer"&gt;CL-0020&lt;/a&gt;, &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0021/" rel="noopener noreferrer"&gt;CL-0021&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Pin the image
&lt;/h2&gt;

&lt;p&gt;In the study, 50.2% of files have at least one image on a mutable tag or no tag at all, and 50.2% have at least one image with a tag but no digest. The two numbers match by coincidence. They're 2,963 and 2,967 files.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;nginx:latest&lt;/code&gt; means a different image every time the registry's tag moves. You can't reproduce it or roll it back, and a compromised upstream push deploys itself. A version tag mostly fixes the first two, although a tag like &lt;code&gt;1.30-alpine&lt;/code&gt; still gets rebuilt and re-pushed when its base image is patched. A digest fixes all three, because Docker resolves a digest to content and ignores the tag.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Before
&lt;/span&gt;&lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:latest&lt;/span&gt;

&lt;span class="c1"&gt;# Better
&lt;/span&gt;&lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:1.30-alpine&lt;/span&gt;

&lt;span class="c1"&gt;# Best
&lt;/span&gt;&lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:1.30-alpine@sha256:…&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can get the digest without pulling the whole image. &lt;code&gt;crane&lt;/code&gt; runs from its own container, so there's nothing to install:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run --rm gcr.io/go-containerregistry/crane digest nginx:1.30-alpine
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pin the index digest that command returns. A per-architecture digest breaks everyone on the other architecture. Then let Renovate or Dependabot bump the digest when the tag moves.&lt;/p&gt;

&lt;p&gt;Projects that only publish a &lt;code&gt;latest&lt;/code&gt; tag can still be pinned by digest. &lt;code&gt;image: excalidraw/excalidraw:latest@sha256:&amp;lt;digest&amp;gt;&lt;/code&gt; pulls the image you pinned until you change the pin.&lt;/p&gt;

&lt;p&gt;Rules: &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0004/" rel="noopener noreferrer"&gt;CL-0004&lt;/a&gt;, &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0019/" rel="noopener noreferrer"&gt;CL-0019&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Bind published ports to an address
&lt;/h2&gt;

&lt;p&gt;In the study, 72.1% of files publish at least one port on all interfaces. Steps 4 to 7 have higher numbers, but those count settings a file leaves out. This is the most common thing a file writes that it shouldn't.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;"8080:80"&lt;/code&gt; binds to every interface, IPv4 and IPv6. Docker publishes a port by writing its own iptables rules, so the port is reachable from the network even where UFW or firewalld would normally block it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Before
&lt;/span&gt;&lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"8080:80"&lt;/span&gt;

&lt;span class="c1"&gt;# After
&lt;/span&gt;&lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"127.0.0.1:8080:80"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A service that has to be reachable from outside should go behind a reverse proxy that terminates TLS, so that only the proxy publishes a port. If you want a host-wide answer, Docker's &lt;code&gt;DOCKER-USER&lt;/code&gt; iptables chain is where firewall rules go if they need to survive Docker's own rules. The rule page links Docker's documentation for it. Docker's newer nftables backend, which is still experimental, doesn't have that chain.&lt;/p&gt;

&lt;p&gt;On Docker 28 and later, nothing off the host can reach a port bound to &lt;code&gt;127.0.0.1&lt;/code&gt;. Before 28.0, a machine on the same network segment could.&lt;/p&gt;

&lt;p&gt;Rule: &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0005/" rel="noopener noreferrer"&gt;CL-0005&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Block privilege escalation with &lt;code&gt;security_opt&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;In the study, 97.3% of files don't set this.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;no-new-privileges&lt;/code&gt; stops a process in the container from gaining privileges through setuid binaries like &lt;code&gt;sudo&lt;/code&gt; and &lt;code&gt;su&lt;/code&gt;. It's one line, and most services run unchanged with it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;security_opt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;no-new-privileges:true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When it does break something, it usually breaks quietly. A setuid helper runs without the privilege and fails later with an ordinary &lt;code&gt;Permission denied&lt;/code&gt;. The rule page lists what it breaks and the one message that names the flag. If a container needs &lt;code&gt;sudo&lt;/code&gt; in its entrypoint, I'd fix that in the image before I'd leave escalation open.&lt;/p&gt;

&lt;p&gt;While you're in &lt;code&gt;security_opt&lt;/code&gt;, leave the kernel profiles on. Docker applies a seccomp profile by default and, where available, an AppArmor profile or SELinux labelling. &lt;code&gt;seccomp:unconfined&lt;/code&gt;, &lt;code&gt;apparmor:unconfined&lt;/code&gt; and &lt;code&gt;label:disable&lt;/code&gt; turn them off. If a workload needs a syscall the default profile blocks, give it a custom profile:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Don't do this
&lt;/span&gt;&lt;span class="na"&gt;security_opt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;seccomp:unconfined&lt;/span&gt;

&lt;span class="c1"&gt;# If the default profile is in the way
&lt;/span&gt;&lt;span class="na"&gt;security_opt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;seccomp:./seccomp.json&lt;/span&gt;   &lt;span class="c1"&gt;# the CL-0009 page shows how to build it
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rules: &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0003/" rel="noopener noreferrer"&gt;CL-0003&lt;/a&gt;, &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0009/" rel="noopener noreferrer"&gt;CL-0009&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Drop every capability, then add back the ones the image needs
&lt;/h2&gt;

&lt;p&gt;In the study, 98.6% of files keep Docker's default capability set.&lt;/p&gt;

&lt;p&gt;A container starts with a fixed set of fourteen Linux capabilities. Most workloads use none of them once they're running. If you drop them all and add back only what's required, you remove privileges the service never uses but an attacker could.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# For nginx:1.30-alpine
&lt;/span&gt;&lt;span class="na"&gt;cap_drop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ALL&lt;/span&gt;
&lt;span class="na"&gt;cap_add&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;CHOWN&lt;/span&gt;      &lt;span class="c1"&gt;# entrypoint chowns /var/cache/nginx at startup
&lt;/span&gt;  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;SETUID&lt;/span&gt;     &lt;span class="c1"&gt;# then drops the workers to the nginx user
&lt;/span&gt;  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;SETGID&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The list depends on the image. That one is verified for &lt;code&gt;nginx:1.30-alpine&lt;/code&gt; against a live daemon, and another image will need a different set.&lt;/p&gt;

&lt;p&gt;Don't begin from &lt;code&gt;cap_add: [NET_BIND_SERVICE]&lt;/code&gt;. Since Docker 20.10 a low port needs no capability inside a container's own network namespace, so it does nothing, and on its own it leaves the entrypoint's &lt;code&gt;chown&lt;/code&gt; failing.&lt;/p&gt;

&lt;p&gt;When a container crash-loops after the change, the log line names the operation that failed. The &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0006/" rel="noopener noreferrer"&gt;CL-0006&lt;/a&gt; page maps each message to the capability that clears it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Two measured examples
&lt;/h3&gt;

&lt;p&gt;I got the sets below by testing. Each image ran under &lt;code&gt;read_only: true&lt;/code&gt; with its own entrypoint and no &lt;code&gt;user:&lt;/code&gt; override. I removed one capability at a time, restarted the service, and exercised what it's actually for. What's left is the set where removing any one of them broke something.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Image&lt;/th&gt;
&lt;th&gt;&lt;code&gt;cap_add&lt;/code&gt;&lt;/th&gt;
&lt;th&gt;
&lt;code&gt;tmpfs&lt;/code&gt; needed under &lt;code&gt;read_only&lt;/code&gt;
&lt;/th&gt;
&lt;th&gt;Why&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;nginx:1.30-alpine&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;CHOWN, SETUID, SETGID&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;/run&lt;/code&gt;, &lt;code&gt;/var/cache/nginx&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;The entrypoint chowns the cache directory, then drops the workers to the &lt;code&gt;nginx&lt;/code&gt; user.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;postgres:16&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;CHOWN, DAC_OVERRIDE, SETGID, SETUID&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/run/postgresql&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;The entrypoint chowns the data and socket directories and switches to the &lt;code&gt;postgres&lt;/code&gt; user. As root it also has to read the &lt;code&gt;0700&lt;/code&gt; data directory and the &lt;code&gt;0600&lt;/code&gt; secret file.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The postgres result showed me that a capability can be needed by more than one step, so test a restart and not only the first start. Without &lt;code&gt;DAC_OVERRIDE&lt;/code&gt; and with the secret from step 1, postgres fails its first start because it can't read the &lt;code&gt;0600&lt;/code&gt; file. With a world-readable secret it initializes and serves, then fails every later start because it can't read its own &lt;code&gt;0700&lt;/code&gt; data directory.&lt;/p&gt;

&lt;p&gt;I measured both sets on Docker 29, in October and November 2026. A different &lt;code&gt;user:&lt;/code&gt;, a volume that already holds data, an overridden entrypoint or a new major version can change a set in either direction, so measure again for what you run.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to find the minimum for any image
&lt;/h3&gt;

&lt;p&gt;I haven't found a registry of capability sets per image that I'd trust, and I don't think one can exist, because the set depends on your configuration as much as on the image. The method is short:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Start from nothing. Use &lt;code&gt;cap_drop: [ALL]&lt;/code&gt; with no &lt;code&gt;cap_add&lt;/code&gt;, then &lt;code&gt;docker compose up&lt;/code&gt;. Many services run this way unchanged.&lt;/li&gt;
&lt;li&gt;Exercise the real function and not only startup. Applications often catch a capability failure and carry on with that feature silently turned off.&lt;/li&gt;
&lt;li&gt;Read the failure. A missing capability almost always shows up as &lt;code&gt;Operation not permitted&lt;/code&gt; in the logs, naming the operation. Occasionally it's &lt;code&gt;Permission denied&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Add back only the capability that failure points to, one at a time, and repeat.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For a new service, I'd put &lt;code&gt;cap_drop: [ALL]&lt;/code&gt;, &lt;code&gt;read_only: true&lt;/code&gt; and &lt;code&gt;no-new-privileges&lt;/code&gt; in its first definition. Adding back what fails is quicker than proving later that each default was unnecessary.&lt;/p&gt;

&lt;p&gt;The capabilities you add back are graded too, by what each one can reach. &lt;code&gt;SYS_ADMIN&lt;/code&gt; and &lt;code&gt;NET_ADMIN&lt;/code&gt; are findings in their own right. The rule page lists which rule covers which capability.&lt;/p&gt;

&lt;p&gt;Rule: &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0006/" rel="noopener noreferrer"&gt;CL-0006&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Make the root filesystem read-only
&lt;/h2&gt;

&lt;p&gt;In the study, 98.7% of files leave it writable.&lt;/p&gt;

&lt;p&gt;With &lt;code&gt;read_only: true&lt;/code&gt;, a process that gets code execution can't modify the container's binaries or add new ones to its filesystem. That makes persistence and bringing in tools harder. It doesn't make them impossible, because tmpfs paths and volumes are still writable. The paths an application needs to write to become &lt;code&gt;tmpfs&lt;/code&gt; entries if they're ephemeral, or volumes if they need to persist. Named volumes and bind mounts stay writable under &lt;code&gt;read_only&lt;/code&gt;, so persistence through a volume is something the mount step further down has to handle.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;read_only&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;span class="na"&gt;tmpfs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/tmp&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/run&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/var/cache/nginx&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To find the paths, run the service once without &lt;code&gt;read_only&lt;/code&gt;, exercise it, and read &lt;code&gt;docker diff &amp;lt;container&amp;gt;&lt;/code&gt;. It lists the writes to the writable layer, which are the ones &lt;code&gt;read_only&lt;/code&gt; will block.&lt;/p&gt;

&lt;p&gt;Leave &lt;code&gt;tmpfs&lt;/code&gt; entries without &lt;code&gt;:exec&lt;/code&gt; or &lt;code&gt;:suid&lt;/code&gt; unless the image needs them. Docker mounts every tmpfs &lt;code&gt;noexec&lt;/code&gt; and &lt;code&gt;nosuid&lt;/code&gt; by default, and &lt;code&gt;:exec&lt;/code&gt; lets a downloaded binary run straight from &lt;code&gt;/tmp&lt;/code&gt;. &lt;code&gt;noexec&lt;/code&gt; doesn't stop an interpreter from running a script stored there, so I treat it as one more obstacle. A few images do need it. When yours does, keep the entry and suppress CL-0022 for that service with the reason written down, so the exception is visible.&lt;/p&gt;

&lt;p&gt;Rules: &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0007/" rel="noopener noreferrer"&gt;CL-0007&lt;/a&gt;, &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0022/" rel="noopener noreferrer"&gt;CL-0022&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Set memory and CPU limits
&lt;/h2&gt;

&lt;p&gt;In the study, 97.4% of files are missing a memory limit, a CPU limit, or both.&lt;/p&gt;

&lt;p&gt;Docker sets no limit by default, so one runaway or malicious process can take the host down with it. Set both, sized from what the workload uses at steady state.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;512M&lt;/span&gt;
      &lt;span class="na"&gt;cpus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'0.50'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Compose honors &lt;code&gt;deploy.resources.limits&lt;/code&gt; outside Swarm, so this works with a plain &lt;code&gt;docker compose up&lt;/code&gt;. Give memory more headroom than CPU, because a memory limit kills the process and a CPU limit only slows it down. The rule page has a sizing procedure.&lt;/p&gt;

&lt;p&gt;These limits are per container, and nothing makes them add up to what the host has. Check that the total fits the machine, with room left for the host. Several services at their limits together can exhaust it while each one stays inside its own.&lt;/p&gt;

&lt;p&gt;These two limits don't cap the number of processes. That's a separate limit, and it's in the section after step 13.&lt;/p&gt;

&lt;p&gt;Rule: &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0026/" rel="noopener noreferrer"&gt;CL-0026&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;That's all twelve findings on the starting file. The remaining steps are about settings it doesn't use.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Don't run as root when the image doesn't need to
&lt;/h2&gt;

&lt;p&gt;In the study, 1.9% of files set an explicit root user.&lt;/p&gt;

&lt;p&gt;An explicit &lt;code&gt;user: root&lt;/code&gt; overrides whatever user the image was built to run as. Remove it and let the image decide, or set a specific non-root user. If the image needs root at startup to fix volume ownership and then drops privileges, that's what the capabilities in step 5 are for.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Before
&lt;/span&gt;&lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;root&lt;/span&gt;

&lt;span class="c1"&gt;# After: remove the line and let the image decide, or
&lt;/span&gt;&lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1000:1000"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A non-root user can't write to a bind mount the host owns as root, and Compose creates a missing bind source as root. The rule page walks through fixing the ownership so you don't have to go back to root.&lt;/p&gt;

&lt;p&gt;Rule: &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0018/" rel="noopener noreferrer"&gt;CL-0018&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Keep the Docker socket out of containers
&lt;/h2&gt;

&lt;p&gt;In the study, 7.8% of files mount the host's Docker socket.&lt;/p&gt;

&lt;p&gt;A container that can reach &lt;code&gt;/var/run/docker.sock&lt;/code&gt; can start a privileged container with the host's root filesystem mounted. That's root on the host with one extra step. Adding &lt;code&gt;:ro&lt;/code&gt; doesn't help, because the API accepts writes over a read-only socket mount. compose-lint rates this CRITICAL, and it's the most common CRITICAL finding in the study.&lt;/p&gt;

&lt;p&gt;The right fix depends on why the socket is there. In order of preference:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Delete the service that wanted it.&lt;/li&gt;
&lt;li&gt;Redesign so it isn't needed.&lt;/li&gt;
&lt;li&gt;Put a filtering proxy in front of it that exposes only the API endpoints required.&lt;/li&gt;
&lt;li&gt;Suppress the finding, with the risk written down and a review date.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://tmatens.github.io/compose-lint/examples/" rel="noopener noreferrer"&gt;The examples library&lt;/a&gt; has a deployed stack for each of the four, and the &lt;a href="https://tmatens.github.io/compose-lint/examples/netdata-socket-proxy/" rel="noopener noreferrer"&gt;netdata example&lt;/a&gt; has the full proxy configuration.&lt;/p&gt;

&lt;p&gt;A proxy still holds the real socket, so it has to be at least as hardened as anything else in the stack. Its own CL-0001 finding is suppressed for that one service with the reason written down, which keeps the rule active for everything else. If its allowlist includes the inspect endpoint, &lt;code&gt;containers/&amp;lt;id&amp;gt;/json&lt;/code&gt;, the consumer can read each container's environment, and that is the case step 1 is about.&lt;/p&gt;

&lt;p&gt;There's also a newer key that grants the socket without a &lt;code&gt;volumes:&lt;/code&gt; line. &lt;code&gt;use_api_socket: true&lt;/code&gt; (Compose 2.37.1 and later) bind-mounts the socket read-write and also copies the registry logins of whoever runs &lt;code&gt;docker compose up&lt;/code&gt; into the container. The same four answers apply. The &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0031/" rel="noopener noreferrer"&gt;CL-0031&lt;/a&gt; page covers the credential half.&lt;/p&gt;

&lt;p&gt;Rules: &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0001/" rel="noopener noreferrer"&gt;CL-0001&lt;/a&gt;, &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0031/" rel="noopener noreferrer"&gt;CL-0031&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Avoid &lt;code&gt;privileged: true&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;In the study, 2.4% of files set it.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;privileged: true&lt;/code&gt; grants every capability, disables the seccomp and AppArmor profiles, and exposes every host device. It often gets added to make a stuck container run. There's usually a narrower setting that does the job:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Need&lt;/th&gt;
&lt;th&gt;Use this&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Access to one device&lt;/td&gt;
&lt;td&gt;&lt;code&gt;devices: [/dev/foo]&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Network configuration&lt;/td&gt;
&lt;td&gt;&lt;code&gt;cap_add: [NET_ADMIN, NET_RAW]&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A debugger sidecar&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;cap_add: [SYS_PTRACE]&lt;/code&gt; with &lt;code&gt;pid: "service:&amp;lt;name&amp;gt;"&lt;/code&gt;, so it sees only that service's processes. &lt;code&gt;SYS_PTRACE&lt;/code&gt; can also read their memory.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Docker-in-Docker&lt;/td&gt;
&lt;td&gt;The &lt;code&gt;sysbox-runc&lt;/code&gt; runtime. Rootless DinD doesn't get you out of this. It still needs &lt;code&gt;privileged&lt;/code&gt;, or seccomp unconfined plus more.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The narrower settings aren't free. &lt;code&gt;NET_ADMIN&lt;/code&gt; is a HIGH finding by itself, and &lt;code&gt;SYS_PTRACE&lt;/code&gt; is graded too. If you don't know which capability a workload needs, remove &lt;code&gt;privileged: true&lt;/code&gt;, run it, and add back only what the failure names.&lt;/p&gt;

&lt;p&gt;Rules: &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0002/" rel="noopener noreferrer"&gt;CL-0002&lt;/a&gt;, &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0011/" rel="noopener noreferrer"&gt;CL-0011&lt;/a&gt;, &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0027/" rel="noopener noreferrer"&gt;CL-0027&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  11. Keep host namespaces and host networking off
&lt;/h2&gt;

&lt;p&gt;In the study, 2.8% of files use &lt;code&gt;network_mode: host&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;network_mode: host&lt;/code&gt; puts the container directly on the host's network stack. The &lt;code&gt;ports:&lt;/code&gt; key is ignored, so you can't limit a service to &lt;code&gt;127.0.0.1&lt;/code&gt; the way step 3 does. Whatever address the application binds is the address it's on, and most bind every interface by default. The container also sees every host interface and can reach services the host only listens for on &lt;code&gt;127.0.0.1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The firewall works the other way around from step 3. A host-network service is an ordinary listener on the host, so UFW and firewalld rules do apply to it. What you lose is the separation between the container and the host's own network. Bridge networking with an explicit port mapping gets that back.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pid: host&lt;/code&gt; and &lt;code&gt;ipc: host&lt;/code&gt; share the host's process and shared-memory namespaces. A sidecar that needs to see another container's processes can use &lt;code&gt;pid: "service:&amp;lt;name&amp;gt;"&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Before
&lt;/span&gt;&lt;span class="na"&gt;network_mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;host&lt;/span&gt;
&lt;span class="na"&gt;pid&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;host&lt;/span&gt;

&lt;span class="c1"&gt;# After
&lt;/span&gt;&lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"127.0.0.1:8080:8080"&lt;/span&gt;
&lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;app-network&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rules: &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0008/" rel="noopener noreferrer"&gt;CL-0008&lt;/a&gt;, &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0010/" rel="noopener noreferrer"&gt;CL-0010&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  12. Look hard at every host path you mount
&lt;/h2&gt;

&lt;p&gt;In the study, 2.5% of files bind-mount a sensitive host path. Writable mounts of root-equivalent paths are under 2%.&lt;/p&gt;

&lt;p&gt;A bind mount of &lt;code&gt;/etc&lt;/code&gt;, &lt;code&gt;/proc&lt;/code&gt;, &lt;code&gt;/root&lt;/code&gt;, &lt;code&gt;/var/lib/docker&lt;/code&gt; or a home directory hands the container the host's secrets even when it's read-only. When it's writable, &lt;code&gt;/etc&lt;/code&gt;, &lt;code&gt;/root&lt;/code&gt;, &lt;code&gt;/proc&lt;/code&gt; and &lt;code&gt;/var/lib/docker&lt;/code&gt; hand it the host. A writable &lt;code&gt;/var/lib/docker&lt;/code&gt; is every other container's filesystem. Device nodes under &lt;code&gt;devices:&lt;/code&gt; and &lt;code&gt;shared&lt;/code&gt; mount propagation open more routes.&lt;/p&gt;

&lt;p&gt;I ask three questions of each &lt;code&gt;volumes:&lt;/code&gt; entry:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does the container need this path at all, or only a copy of part of it? A named volume or a &lt;code&gt;COPY&lt;/code&gt; at build time usually replaces a host bind.&lt;/li&gt;
&lt;li&gt;If it needs the host path, does it need to write to it? If it doesn't, add &lt;code&gt;:ro&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Is it &lt;code&gt;/dev/shm&lt;/code&gt;? The container already has its own. If the bind is there because 64 MiB is too small, set &lt;code&gt;shm_size:&lt;/code&gt;.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Before
&lt;/span&gt;&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/etc:/host-etc&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./site:/usr/share/nginx/html&lt;/span&gt;

&lt;span class="c1"&gt;# After
&lt;/span&gt;&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./site:/usr/share/nginx/html:ro&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rules: &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0013/" rel="noopener noreferrer"&gt;CL-0013&lt;/a&gt;, &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0025/" rel="noopener noreferrer"&gt;CL-0025&lt;/a&gt;, &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0016/" rel="noopener noreferrer"&gt;CL-0016&lt;/a&gt;, &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0017/" rel="noopener noreferrer"&gt;CL-0017&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  13. Keep logs on
&lt;/h2&gt;

&lt;p&gt;In the study, 15 of the 5,907 files turn logging off.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;logging: driver: none&lt;/code&gt; discards the container's output at the daemon. &lt;code&gt;docker logs&lt;/code&gt; returns an error, nothing reaches a log shipper, and an incident in that container leaves no record. If the concern is disk space, rotate the logs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;json-file&lt;/span&gt;
  &lt;span class="na"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;max-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10m&lt;/span&gt;
    &lt;span class="na"&gt;max-file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'3'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rule: &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0014/" rel="noopener noreferrer"&gt;CL-0014&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hardening that compose-lint doesn't grade
&lt;/h2&gt;

&lt;p&gt;Every step so far maps to a compose-lint rule. The settings in this section don't, and in each case that was a decision. I've said why for each one. They can still be worth setting. The first two are in the final file below, and I ran it with them: both services started, served, and came back after a restart.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cap the number of processes
&lt;/h3&gt;

&lt;p&gt;This one is optional if you've set the memory limit from step 7. The memory limit is what protects the host from a fork bomb. A process limit changes how the failure ends. I ran a fork bomb in a container held to 128M and half a CPU, with and without one:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Process limit&lt;/th&gt;
&lt;th&gt;Processes reached&lt;/th&gt;
&lt;th&gt;What happened&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;About 1,200 in five seconds&lt;/td&gt;
&lt;td&gt;Hit the memory limit and was killed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;100&lt;/td&gt;
&lt;td&gt;100&lt;/td&gt;
&lt;td&gt;Further forks refused, container stayed up&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The host stayed responsive both times. Neither ending is healthy. A killed container with a restart policy comes back to the same attack, and a service at its process ceiling can't start new work. If you haven't set a memory limit, don't skip this one.&lt;/p&gt;

&lt;p&gt;CIS and OWASP both ask for a process limit, so set it if you're audited against either. The &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0026/#what-it-detects" rel="noopener noreferrer"&gt;CL-0026&lt;/a&gt; page has the rest of the measurement.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;512M&lt;/span&gt;
      &lt;span class="na"&gt;cpus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'1.0'&lt;/span&gt;
      &lt;span class="na"&gt;pids&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Put it next to the limits from step 7. I first tried the service-level &lt;code&gt;pids_limit:&lt;/code&gt; key beside a &lt;code&gt;deploy.resources.limits&lt;/code&gt; block, and Compose 5.6.1 refused the file with &lt;code&gt;can't set distinct values on 'pids_limit' and 'deploy.resources.limits.pids'&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Size it from what the service runs. &lt;code&gt;docker stats --no-stream&lt;/code&gt; has a PIDS column. Postgres forks one backend per client connection, so its limit has to clear &lt;code&gt;max_connections&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Why there's no rule: compose-lint used to have one and I retired it. Memory is the bigger risk, and a file that leaves it unbounded is already flagged by &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0026/" rel="noopener noreferrer"&gt;CL-0026&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Separate the networks
&lt;/h3&gt;

&lt;p&gt;Compose puts every service in a project on one network, so &lt;code&gt;web&lt;/code&gt; and &lt;code&gt;db&lt;/code&gt; can reach each other and both can reach the internet. Two networks, with the database's marked &lt;code&gt;internal&lt;/code&gt;, narrow that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;web&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;frontend&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;backend&lt;/span&gt;
  &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;backend&lt;/span&gt;

&lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;frontend&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;backend&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;internal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On the final file, &lt;code&gt;web&lt;/code&gt; still served its published port and reached &lt;code&gt;db:5432&lt;/code&gt;, and a client on &lt;code&gt;backend&lt;/code&gt; logged in with the secret from step 1. A container attached only to an &lt;code&gt;internal&lt;/code&gt; network had no default route and couldn't resolve or reach an outside host. Attached to both networks, it could.&lt;/p&gt;

&lt;p&gt;Why there's no rule: which services in a project should be able to reach each other is a design decision, and the file doesn't say what you intended.&lt;/p&gt;

&lt;h3&gt;
  
  
  Start without root
&lt;/h3&gt;

&lt;p&gt;Both services in the final file start as root, and the capabilities from step 5 are the cost of that. The nginx master process stays root for its lifetime, and postgres starts as root before it switches user. I measured two alternatives, each with &lt;code&gt;cap_drop: [ALL]&lt;/code&gt;, no &lt;code&gt;cap_add&lt;/code&gt;, &lt;code&gt;read_only: true&lt;/code&gt; and &lt;code&gt;no-new-privileges&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;nginxinc/nginx-unprivileged:1.30-alpine&lt;/code&gt; ran as uid 101 and served, with one &lt;code&gt;tmpfs&lt;/code&gt; at &lt;code&gt;/tmp&lt;/code&gt;. It listens on 8080, so the port mapping becomes &lt;code&gt;"127.0.0.1:8080:8080"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;postgres:16&lt;/code&gt; with &lt;code&gt;user: "999:999"&lt;/code&gt;, which is the image's &lt;code&gt;postgres&lt;/code&gt; user, ran through a first start and a restart on a fresh volume. The cost moves to the secret. Without &lt;code&gt;DAC_OVERRIDE&lt;/code&gt;, uid 999 has to be able to read the file by its mode. At &lt;code&gt;0600&lt;/code&gt; and owned by another user the entrypoint stopped with &lt;code&gt;Permission denied&lt;/code&gt;, and at &lt;code&gt;0644&lt;/code&gt; it started. Giving the file to uid 999 on the host would keep it at &lt;code&gt;0600&lt;/code&gt;, but I didn't run that.&lt;/p&gt;

&lt;p&gt;Why there's no rule: the image's default user isn't in the Compose file, so compose-lint can't tell a root default from a non-root one, and I didn't want it to guess. It flags &lt;code&gt;user: root&lt;/code&gt; when you write it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The hardened file
&lt;/h2&gt;

&lt;p&gt;This is the starting file with every step applied, plus the process limits and networks from the last section. With real digests in place of the shortened ones, &lt;code&gt;compose-lint check --fail-on low&lt;/code&gt; reports no findings on it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;web&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:1.30-alpine@sha256:…&lt;/span&gt;               &lt;span class="c1"&gt;# step 2
&lt;/span&gt;    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"127.0.0.1:8080:80"&lt;/span&gt;                          &lt;span class="c1"&gt;# step 3
&lt;/span&gt;    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;./site:/usr/share/nginx/html:ro&lt;/span&gt;              &lt;span class="c1"&gt;# step 12
&lt;/span&gt;    &lt;span class="na"&gt;read_only&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;                                  &lt;span class="c1"&gt;# step 6
&lt;/span&gt;    &lt;span class="na"&gt;tmpfs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/tmp&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/run&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/var/cache/nginx&lt;/span&gt;
    &lt;span class="na"&gt;cap_drop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                                        &lt;span class="c1"&gt;# step 5
&lt;/span&gt;      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ALL&lt;/span&gt;
    &lt;span class="na"&gt;cap_add&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;CHOWN&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;SETUID&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;SETGID&lt;/span&gt;
    &lt;span class="na"&gt;security_opt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                                    &lt;span class="c1"&gt;# step 4
&lt;/span&gt;      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;no-new-privileges:true&lt;/span&gt;
    &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                                          &lt;span class="c1"&gt;# step 7
&lt;/span&gt;      &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;128M&lt;/span&gt;
          &lt;span class="na"&gt;cpus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'0.50'&lt;/span&gt;
          &lt;span class="na"&gt;pids&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;                                  &lt;span class="c1"&gt;# optional, not graded
&lt;/span&gt;    &lt;span class="na"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                                         &lt;span class="c1"&gt;# step 13
&lt;/span&gt;      &lt;span class="na"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;json-file&lt;/span&gt;
      &lt;span class="na"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;max-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10m&lt;/span&gt;
        &lt;span class="na"&gt;max-file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'3'&lt;/span&gt;
    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                                        &lt;span class="c1"&gt;# not graded
&lt;/span&gt;      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;frontend&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;backend&lt;/span&gt;
    &lt;span class="na"&gt;depends_on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;db&lt;/span&gt;

  &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres:16@sha256:…&lt;/span&gt;                      &lt;span class="c1"&gt;# step 2
&lt;/span&gt;    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_PASSWORD_FILE&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/run/secrets/db_password&lt;/span&gt;   &lt;span class="c1"&gt;# step 1
&lt;/span&gt;    &lt;span class="na"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;db_password&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;pgdata:/var/lib/postgresql/data&lt;/span&gt;
    &lt;span class="na"&gt;read_only&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;                                  &lt;span class="c1"&gt;# step 6
&lt;/span&gt;    &lt;span class="na"&gt;tmpfs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;/run/postgresql&lt;/span&gt;
    &lt;span class="na"&gt;cap_drop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                                        &lt;span class="c1"&gt;# step 5
&lt;/span&gt;      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;ALL&lt;/span&gt;
    &lt;span class="na"&gt;cap_add&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                                         &lt;span class="c1"&gt;# measured minimum
&lt;/span&gt;      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;CHOWN&lt;/span&gt;                                        &lt;span class="c1"&gt;# for postgres:16,
&lt;/span&gt;      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;DAC_OVERRIDE&lt;/span&gt;                                 &lt;span class="c1"&gt;# see step 5
&lt;/span&gt;      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;SETGID&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;SETUID&lt;/span&gt;
    &lt;span class="na"&gt;security_opt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                                    &lt;span class="c1"&gt;# step 4
&lt;/span&gt;      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;no-new-privileges:true&lt;/span&gt;
    &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                                          &lt;span class="c1"&gt;# step 7
&lt;/span&gt;      &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;512M&lt;/span&gt;
          &lt;span class="na"&gt;cpus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'1.0'&lt;/span&gt;
          &lt;span class="na"&gt;pids&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;                                  &lt;span class="c1"&gt;# optional, not graded
&lt;/span&gt;    &lt;span class="na"&gt;logging&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                                         &lt;span class="c1"&gt;# step 13
&lt;/span&gt;      &lt;span class="na"&gt;driver&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;json-file&lt;/span&gt;
      &lt;span class="na"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;max-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;10m&lt;/span&gt;
        &lt;span class="na"&gt;max-file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'3'&lt;/span&gt;
    &lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                                        &lt;span class="c1"&gt;# not graded
&lt;/span&gt;      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;backend&lt;/span&gt;

&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;pgdata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

&lt;span class="na"&gt;networks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;frontend&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;backend&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;internal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;

&lt;span class="na"&gt;secrets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;db_password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./secrets/db_password.txt&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both capability lists are the measured ones from step 5. Without the &lt;code&gt;/run/postgresql&lt;/code&gt; tmpfs, postgres can't create its lock file and exits under &lt;code&gt;read_only&lt;/code&gt;. The &lt;code&gt;docker diff&lt;/code&gt; pass in step 6 is how you find paths like that one ahead of time. Measure again for the versions you run.&lt;/p&gt;

&lt;p&gt;No findings doesn't mean there's nothing left to do. Both services here still start as root, and the linter stays quiet about that on purpose, for the reason in the last section. If that matters for your stack, the unprivileged variants there are the next step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Setting&lt;/th&gt;
&lt;th&gt;Rule&lt;/th&gt;
&lt;th&gt;Files in the study that skip it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Credentials in &lt;code&gt;secrets:&lt;/code&gt;, not &lt;code&gt;environment:&lt;/code&gt; or &lt;code&gt;env_file:&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0020/" rel="noopener noreferrer"&gt;CL-0020&lt;/a&gt;, &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0021/" rel="noopener noreferrer"&gt;CL-0021&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;28.2% / 5.1%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image pinned to a tag&lt;/td&gt;
&lt;td&gt;&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0004/" rel="noopener noreferrer"&gt;CL-0004&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;50.2%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Image pinned to a digest&lt;/td&gt;
&lt;td&gt;&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0019/" rel="noopener noreferrer"&gt;CL-0019&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;50.2%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Published ports bound to an address&lt;/td&gt;
&lt;td&gt;&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0005/" rel="noopener noreferrer"&gt;CL-0005&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;72.1%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;no-new-privileges:true&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0003/" rel="noopener noreferrer"&gt;CL-0003&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;97.3%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Seccomp, AppArmor and SELinux labelling left on&lt;/td&gt;
&lt;td&gt;&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0009/" rel="noopener noreferrer"&gt;CL-0009&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;under 2%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;cap_drop: [ALL]&lt;/code&gt;, image-specific &lt;code&gt;cap_add&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0006/" rel="noopener noreferrer"&gt;CL-0006&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;98.6%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Added capabilities limited to what the image needs&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0011/" rel="noopener noreferrer"&gt;CL-0011&lt;/a&gt;, &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0024/" rel="noopener noreferrer"&gt;CL-0024&lt;/a&gt;, &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0027/" rel="noopener noreferrer"&gt;CL-0027&lt;/a&gt; to &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0030/" rel="noopener noreferrer"&gt;CL-0030&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;3.5% / under 2%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;read_only: true&lt;/code&gt; with &lt;code&gt;tmpfs&lt;/code&gt; for writable paths&lt;/td&gt;
&lt;td&gt;&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0007/" rel="noopener noreferrer"&gt;CL-0007&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;98.7%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No &lt;code&gt;:exec&lt;/code&gt; or &lt;code&gt;:suid&lt;/code&gt; on &lt;code&gt;tmpfs&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0022/" rel="noopener noreferrer"&gt;CL-0022&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;under 2%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Memory and CPU limits&lt;/td&gt;
&lt;td&gt;&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0026/" rel="noopener noreferrer"&gt;CL-0026&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;97.4%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No explicit &lt;code&gt;user: root&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0018/" rel="noopener noreferrer"&gt;CL-0018&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;under 2%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No Docker socket mount&lt;/td&gt;
&lt;td&gt;&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0001/" rel="noopener noreferrer"&gt;CL-0001&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;7.8%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No &lt;code&gt;privileged: true&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0002/" rel="noopener noreferrer"&gt;CL-0002&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;2.4%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No &lt;code&gt;network_mode: host&lt;/code&gt;, &lt;code&gt;pid: host&lt;/code&gt;, &lt;code&gt;ipc: host&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0008/" rel="noopener noreferrer"&gt;CL-0008&lt;/a&gt;, &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0010/" rel="noopener noreferrer"&gt;CL-0010&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;2.8% / under 2%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Host paths mounted only when needed, &lt;code&gt;:ro&lt;/code&gt; where possible&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0013/" rel="noopener noreferrer"&gt;CL-0013&lt;/a&gt;, &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0025/" rel="noopener noreferrer"&gt;CL-0025&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;2.5% / under 2%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No host devices, no &lt;code&gt;shared&lt;/code&gt; mount propagation&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0016/" rel="noopener noreferrer"&gt;CL-0016&lt;/a&gt;, &lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0017/" rel="noopener noreferrer"&gt;CL-0017&lt;/a&gt;
&lt;/td&gt;
&lt;td&gt;under 2%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Logging driver not &lt;code&gt;none&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;&lt;a href="https://tmatens.github.io/compose-lint/rules/CL-0014/" rel="noopener noreferrer"&gt;CL-0014&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;under 2%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Process limit, optional with a memory limit&lt;/td&gt;
&lt;td&gt;not graded&lt;/td&gt;
&lt;td&gt;n/a&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database on an &lt;code&gt;internal&lt;/code&gt; network&lt;/td&gt;
&lt;td&gt;not graded&lt;/td&gt;
&lt;td&gt;n/a&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;No root at start, where the image allows it&lt;/td&gt;
&lt;td&gt;not graded&lt;/td&gt;
&lt;td&gt;n/a&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;To check a file against all of it at once, run &lt;code&gt;compose-lint check --fail-on low compose.yaml&lt;/code&gt;. &lt;code&gt;compose-lint fix&lt;/code&gt; applies the steps that can be applied mechanically and shows the diff before it writes anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to start if you can only do one thing
&lt;/h2&gt;

&lt;p&gt;If any credential is in &lt;code&gt;environment:&lt;/code&gt;, start with step 1. Otherwise I'd start with step 4, &lt;code&gt;no-new-privileges&lt;/code&gt;, because it's one line and rarely changes what a service does. Step 5 would be next.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this doesn't cover
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What's inside the images.&lt;/strong&gt; This post and compose-lint cover the Compose file, which is how the container is run. What's inside the image and how it was built are jobs for an image scanner and a Dockerfile linter. I wrote up what each tool reads on &lt;a href="https://tmatens.github.io/compose-lint/compare/" rel="noopener noreferrer"&gt;the comparison page&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Daemon-level options.&lt;/strong&gt; Rootless Docker and user namespace remapping change what root in a container means, and they're worth looking at separately.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  If you want to run it on your own files
&lt;/h2&gt;

&lt;p&gt;compose-lint is on PyPI and Docker Hub, and there's a GitHub Action if you want it in CI. The &lt;a href="https://tmatens.github.io/compose-lint/" rel="noopener noreferrer"&gt;docs&lt;/a&gt; cover all three, and the source is on &lt;a href="https://github.com/tmatens/compose-lint" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;. I keep a copy of this guide &lt;a href="https://tmatens.github.io/compose-lint/hardening/" rel="noopener noreferrer"&gt;in the docs&lt;/a&gt; too, and update it there as the rules change. If a rule page is wrong about an image you run, I'd like to hear about it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;compose-lint is a personal project and is not affiliated with my employer. The views here are my own.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>docker</category>
      <category>security</category>
      <category>devops</category>
      <category>selfhosted</category>
    </item>
    <item>
      <title>The fix ships weeks before your scanner knows</title>
      <dc:creator>Todd Matens</dc:creator>
      <pubDate>Thu, 12 Nov 2026 13:35:53 +0000</pubDate>
      <link>https://dev.to/tmatens/the-fix-ships-weeks-before-your-scanner-knows-2g35</link>
      <guid>https://dev.to/tmatens/the-fix-ships-weeks-before-your-scanner-knows-2g35</guid>
      <description>&lt;p&gt;In late September I published a release of &lt;a href="https://tmatens.github.io/compose-lint/" rel="noopener noreferrer"&gt;compose-lint&lt;/a&gt;, a security linter for Docker Compose files that I maintain. It fixed &lt;a href="https://github.com/tmatens/compose-lint/security/advisories" rel="noopener noreferrer"&gt;two vulnerabilities&lt;/a&gt;, and I published the advisories about fifteen minutes later. GitHub reviewed them 44 days after that, and until then no scanner that relies on GitHub's advisory data could tell anyone running an affected version that a fix existed. I wanted to know how typical that was, so I pulled the data.&lt;/p&gt;

&lt;p&gt;If you run a vulnerability management program, the clock for a finding starts when your scanner reports it, and a scanner can only report what's in the vulnerability data it reads. That's true for any kind of software. I measured the gap for open source packages, where the dates are public, using one of the main sources, the GitHub Advisory Database. For fixes released this summer, the typical advisory was reviewed into it about four weeks after the fixed version was published, and six weeks in the worst month.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuz0sf78qlgjr5h5yhxek.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuz0sf78qlgjr5h5yhxek.png" alt="Line chart: median days from a fixed release to the maintainer's advisory and to GitHub's review, by release month, August 2025 to October 2026. September and October are shaded and marked too early to tell." width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Median days after the fixed version was released. The orange line is when the maintainer published the advisory. The blue line is when GitHub reviewed it, which is the earliest a scanner reading that data could report it. The shaded months are too recent to read. Advisories that haven't been reviewed yet aren't counted, so these numbers will likely rise.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;That's probably not a surprise to those of us who have been watching CVE volume this year. GitHub has &lt;a href="https://github.blog/security/supply-chain-security/inside-the-advisory-database-and-what-happens-when-vulnerability-volume-breaks-records" rel="noopener noreferrer"&gt;written about the backlog&lt;/a&gt; themselves, and in April &lt;a href="https://therecord.media/nist-to-limit-work-on-cve-entries-surge" rel="noopener noreferrer"&gt;NIST said&lt;/a&gt; it would stop fully analyzing most CVEs in the National Vulnerability Database (NVD) because submissions were outrunning it.&lt;/p&gt;

&lt;p&gt;What's easy to miss in the tsunami of published vulnerabilities is that there's a good chance your exposure time has gone up if you rely on your scanner as the trigger. So the question I wanted to answer was how much of that time you can skip by updating when the release ships and not when the finding shows up.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I measured
&lt;/h2&gt;

&lt;p&gt;I used GitHub's public API to collect every advisory reviewed into the Advisory Database between August 22, 2025 and November 11, 2026. That came to 14,173 advisories, and 10,873 of them started as a repository advisory published by the project's maintainer. For each one I recorded when the fixed version reached its registry, when the maintainer published the advisory, when the CVE was published, and when GitHub reviewed it. Where an advisory lists more than one fixed version, I counted from the earliest. Most were published within a day of each other, and counting from the latest changes the summer median by about a day. The start date picks up where &lt;a href="https://arxiv.org/abs/2602.06009v1" rel="noopener noreferrer"&gt;an earlier study of the same pipeline&lt;/a&gt; leaves off, and my first six months matched its results.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I found
&lt;/h2&gt;

&lt;p&gt;These are median days from the fixed version being released to GitHub's review, for the maintainer-published advisories, grouped by the month of the release. It's too early to read September and October, because advisories that haven't been reviewed yet aren't counted.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Fix released in&lt;/th&gt;
&lt;th&gt;Median days to GitHub's review&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Aug 2025 to Mar 2026&lt;/td&gt;
&lt;td&gt;1 to 5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Apr 2026&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;May 2026&lt;/td&gt;
&lt;td&gt;19&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jun 2026&lt;/td&gt;
&lt;td&gt;37&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jul 2026&lt;/td&gt;
&lt;td&gt;42&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Aug 2026&lt;/td&gt;
&lt;td&gt;35&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sep 2026 (too early to tell)&lt;/td&gt;
&lt;td&gt;20&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Oct 2026 (too early to tell)&lt;/td&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Maintainers aren't where the time went. The &lt;a href="https://oss-vulnerability-guide.openssf.org/maintainer-guide.html" rel="noopener noreferrer"&gt;usual guidance for open source projects&lt;/a&gt; is to release the fix and publish the advisory together, and most did. At the median they published within a day of shipping the fix for the whole period, which is the flat orange line in the chart. The change is all in the review. Reviews of repository advisories went from a few hundred a month to 1,377 in March, and GitHub was still turning most of them around in a few days. The wait starts to show for fixes released in April and May, and it was at its worst for June and July.&lt;/p&gt;

&lt;h2&gt;
  
  
  When it mattered
&lt;/h2&gt;

&lt;p&gt;Most of these advisories aren't known to be exploited, and I don't want to overstate the risk. I checked the data against CISA's Known Exploited Vulnerabilities list and found 25 matches among about 12,000 advisories that have a CVE. Two of them stood out. The Gitea maintainers published a critical advisory on July 28. CISA added it to the list on August 25, and GitHub reviewed it on September 8. The GPUStack maintainers published a critical advisory on July 31, and it was reviewed on November 9, which is 101 days later and the same day CISA listed it. In both cases the fixed version had been available the whole time.&lt;/p&gt;

&lt;p&gt;Severity is also becoming a weaker guide to what can be exploited. The UK's National Cyber Security Centre &lt;a href="https://www.ncsc.gov.uk/report/impact-ai-cyber-threat-now-2027" rel="noopener noreferrer"&gt;said in 2025&lt;/a&gt; that the time between disclosure and exploitation "has shrunk to days and AI will almost certainly reduce this further". This April the UK government's AI Security Institute &lt;a href="https://www.aisi.gov.uk/blog/our-evaluation-of-claude-mythos-previews-cyber-capabilities" rel="noopener noreferrer"&gt;reported&lt;/a&gt; that one of the newest models could "discover and exploit vulnerabilities autonomously", though its tests had no active defenders. The model's developer, Anthropic, &lt;a href="https://www.anthropic.com/research/mythos-preview" rel="noopener noreferrer"&gt;describes&lt;/a&gt; it chaining two to four vulnerabilities into a working exploit, including bugs that weren't much use on their own. So I'd be careful about treating a low severity fix as one that can wait.&lt;/p&gt;

&lt;h2&gt;
  
  
  What doesn't shorten the wait
&lt;/h2&gt;

&lt;p&gt;Two things you might expect to get you the fix sooner don't.&lt;/p&gt;

&lt;p&gt;One is watching for the CVE. For fixes released this summer, the CVE was published a median of 33 days after the fix, which is no sooner than GitHub's review. A CVE also doesn't make a scanner see the fix on its own. One of my advisories had a published CVE that GitHub hadn't reviewed yet. When I scanned a project that depends on an affected version with Trivy, Grype and OSV-Scanner, none of them reported it.&lt;/p&gt;

&lt;p&gt;Those are three open source scanners. Commercial scanners that do their own research may report a fix sooner, and I didn't measure them. Whichever one you use, the finding comes after the fix.&lt;/p&gt;

&lt;p&gt;The other is counting on severity. A critical waited about as long as a low, close to three weeks at the median, and 41% of the criticals waited more than a month. GitHub says they prioritize by impact and severity, and that may decide which advisories get reviewed at all. I can only see the ones that were.&lt;/p&gt;

&lt;h2&gt;
  
  
  What helps
&lt;/h2&gt;

&lt;p&gt;Through all of this, the fixed version was available the whole time. What helps is anything that gets it installed without waiting for a finding.&lt;/p&gt;

&lt;p&gt;Updating when the release ships does that, and both of the common tools can already do it. Dependabot has &lt;a href="https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/about-dependabot-version-updates" rel="noopener noreferrer"&gt;version updates&lt;/a&gt;, which GitHub describes as pull requests that keep dependencies updated "even when they don't have any vulnerabilities", and Renovate does the same by default. Neither waits for an advisory. What waits is the other half of each tool: Dependabot's alerts, which &lt;a href="https://docs.github.com/en/code-security/dependabot/dependabot-alerts/about-dependabot-alerts" rel="noopener noreferrer"&gt;only fire for advisories GitHub has reviewed&lt;/a&gt;, the security updates those alerts trigger, and Renovate's security pull requests. If a repository only has security alerts turned on, it only has the half that waits.&lt;/p&gt;

&lt;p&gt;The pushback I'd expect is that taking new releases right away is how you end up installing a malicious one, or one that breaks something. Both are fair concerns, and waiting a few days helps with both. I've seen plenty of projects ship something broken and follow it with a fix within days, and the compromised releases that made the news this year were pulled faster than that. The malicious Trivy release in March was &lt;a href="https://www.aquasec.com/blog/trivy-supply-chain-attack-what-you-need-to-know/" rel="noopener noreferrer"&gt;available for about three hours&lt;/a&gt;, and the LiteLLM versions on PyPI for &lt;a href="https://www.kaspersky.com/blog/critical-supply-chain-attack-trivy-litellm-checkmarx-teampcp/55510/" rel="noopener noreferrer"&gt;a few hours&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Those are the well-known cases, though. A malicious package nobody is watching can sit for much longer. Testing helps with what gets past the wait, and scanning and vetting the artifacts themselves matters too, but that's a topic for a different article.&lt;/p&gt;

&lt;p&gt;A lot of teams hold new versions back for a few days for these reasons, and I do the same. How many days to wait is a decision. It should be a deliberate one, automated in most cases, and it shouldn't wait for a vulnerability to be reported. So I checked how much of that time is left for a few choices. The table shows the share of advisories where the fix had already been out longer than the hold-back by the time GitHub reviewed it.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Fix released in&lt;/th&gt;
&lt;th&gt;3 days&lt;/th&gt;
&lt;th&gt;7 days&lt;/th&gt;
&lt;th&gt;14 days&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Aug 2025 to Mar 2026&lt;/td&gt;
&lt;td&gt;36% to 60%&lt;/td&gt;
&lt;td&gt;22% to 46%&lt;/td&gt;
&lt;td&gt;16% to 36%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;May 2026&lt;/td&gt;
&lt;td&gt;91%&lt;/td&gt;
&lt;td&gt;70%&lt;/td&gt;
&lt;td&gt;56%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jun 2026&lt;/td&gt;
&lt;td&gt;87%&lt;/td&gt;
&lt;td&gt;78%&lt;/td&gt;
&lt;td&gt;70%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Jul 2026&lt;/td&gt;
&lt;td&gt;90%&lt;/td&gt;
&lt;td&gt;84%&lt;/td&gt;
&lt;td&gt;70%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Aug 2026&lt;/td&gt;
&lt;td&gt;92%&lt;/td&gt;
&lt;td&gt;86%&lt;/td&gt;
&lt;td&gt;80%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sep 2026 (too early to tell)&lt;/td&gt;
&lt;td&gt;99%&lt;/td&gt;
&lt;td&gt;95%&lt;/td&gt;
&lt;td&gt;70%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So if you had waited a full week before merging any update, you would still have had the fix before your scanner could report it for 70% to 86% of the fixes released from May through August. This held for widely used libraries too. For npm and PyPI packages with more than 10 million downloads a month, which is 200 packages including urllib3, cryptography, undici and ws, fixes waited a median of about 22 days for review, and 79% had been out for more than a week by then.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a program can do
&lt;/h2&gt;

&lt;p&gt;There's more than one way to respond to this, and I don't think there's a single right answer.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make automated updates the easy default. Give teams a setup that works out of the box and expect them to use it, so most fixes land before there's a finding. It doesn't need a policy change, but it does need tooling and tests that teams trust.&lt;/li&gt;
&lt;li&gt;Start the clock when the fix is available instead of when the scanner reports it. This is the most direct, and the hardest. It touches audit evidence and tooling, and it's a lot to ask of a team that can't see the fix either.&lt;/li&gt;
&lt;li&gt;Add earlier signals to your scanning, such as project or vendor advisories, where your tools support them. I'd check that they're actually earlier before relying on them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I'm not recommending one of these over the others. The first is the one I've done on my own project.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it looks like for maintainers
&lt;/h2&gt;

&lt;p&gt;I asked Daniel Stenberg, who maintains curl, if this is different for a project that is its own CVE Numbering Authority (CNA) and issues its own CVEs. He told me in a public exchange on LinkedIn: "we are a CNA, we get them the same second we ask for them: zero friction".&lt;/p&gt;

&lt;p&gt;The data partly backs that up. Being your own CNA puts you in control of when a CVE is published, and for some that meant speed. VMware, OpenJS and Microsoft published theirs within a day of the fix this summer. Control doesn't always mean speed, though. Gitea published its CVEs in batches, a median of 31 days after the fixes. CVEs that GitHub assigned took a median of 40 days.&lt;/p&gt;

&lt;p&gt;I'm considering going through the CNA process myself, more as an academic exercise than because compose-lint needs it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this doesn't tell you
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Every advisory in the tables was reviewed eventually, so the real wait is longer than what I'm showing. GitHub has issued CVEs since May for at least 842 advisories in ecosystems it reviews that still weren't in the database when I collected the data, and half of those had been waiting more than 135 days.&lt;/li&gt;
&lt;li&gt;It's too early to read the last two months. Eleven days after June ended it looked the way October does now, about 7 days, and it finished at 37. March looked low at the same stage and stayed low, so the drop at the end of the chart could be a recovery or June again.&lt;/li&gt;
&lt;li&gt;Updating on release assumes the fix is in a version you can move to. If it only lands in a new major version, or it's several levels down in your dependency tree, it takes more than a version bump.&lt;/li&gt;
&lt;li&gt;This only covers the package ecosystems GitHub reviews. It doesn't say anything about operating system packages.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of this needs a new tool. The fixed version was there the whole time, and both of the common update bots will propose it without waiting for an advisory. How a program makes use of that is its own call. For my part, the next time I ship a fix, I won't expect anyone's scanner to notice for a while, and I'd rather their update bot got there first.&lt;/p&gt;

&lt;p&gt;The scripts, the data, the full report and the rest of the caveats are at &lt;a href="https://github.com/tmatens/advisory-review-lag" rel="noopener noreferrer"&gt;github.com/tmatens/advisory-review-lag&lt;/a&gt; if you want to check my work or run it yourself.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;compose-lint is a personal project and is not affiliated with my employer. The views here are my own.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>opensource</category>
      <category>devops</category>
      <category>github</category>
    </item>
    <item>
      <title>Docker Hub's access token vulnerability: how signing let me verify my images</title>
      <dc:creator>Todd Matens</dc:creator>
      <pubDate>Mon, 12 Oct 2026 23:48:20 +0000</pubDate>
      <link>https://dev.to/tmatens/docker-hubs-access-token-vulnerability-how-signing-let-me-verify-my-images-58i3</link>
      <guid>https://dev.to/tmatens/docker-hubs-access-token-vulnerability-how-signing-let-me-verify-my-images-58i3</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Update, October 18.&lt;/strong&gt; Docker has published its advisory, and the issue is now CVE-2026-105445. It describes the same mechanism the email did: converting a personal account to an organization transferred the account's personal access tokens to the named owner without rotating them. Reading it also clarified something for me. My own conversion wasn't the risk, since I held my own tokens. The attack runs the other way: someone creates a throwaway account, generates a token, converts it, and names you as the owner. Docker couldn't tell legitimate conversions from malicious ones, so everyone who had used the feature got the notice.&lt;/p&gt;

&lt;p&gt;Docker's review of pushes made with transferred tokens found no tampering, which matches what my signature check showed. The advisory also recommends organization access tokens for CI rather than a user's PAT, which is where I'm headed next. The write-up is &lt;a href="https://www.docker.com/blog/docker-hub-security-advisory-cve-2026-105445/" rel="noopener noreferrer"&gt;here&lt;/a&gt;, and The Hacker News &lt;a href="https://thehackernews.com/2026/10/docker-fixes-critical-two-year-old-hub.html" rel="noopener noreferrer"&gt;covered the disclosure&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;em&gt;Originally published October 12.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Docker's review of pushes made with transferred tokens found no tampering, which matches what my signature check showed. The advisory also recommends organization access tokens for CI rather than a user's PAT, which is where I'm headed next. The write-up is &lt;a href="https://www.docker.com/blog/docker-hub-security-advisory-cve-2026-105445/" rel="noopener noreferrer"&gt;here&lt;/a&gt;, and The Hacker News &lt;a href="https://thehackernews.com/2026/10/docker-fixes-critical-two-year-old-hub.html" rel="noopener noreferrer"&gt;covered the disclosure&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A critical bug in Docker Hub's access controls meant some personal access tokens, including the ones I use to publish &lt;a href="https://tmatens.github.io/compose-lint/" rel="noopener noreferrer"&gt;compose-lint&lt;/a&gt;, a security linter for Docker Compose files, could have been used by someone else. Not the email you want on a Friday afternoon.&lt;/p&gt;

&lt;p&gt;I actually got two of them on Friday, October 2, about an hour apart. The one I happened to open first was addressed to me as the organization owner. It was pretty vague and said there was no action for me to take, so I skimmed it and moved on. The other one, sent to my user account, was titled "Action Requested." When I had a chance to read both more closely, I realized my user was the one flagged, and Docker was planning to force-deactivate my two CI tokens that Monday, October 5.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz5912eqrm9ajzy8noyk1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz5912eqrm9ajzy8noyk1.jpg" alt="Docker's security notice: a critical vulnerability in Docker Hub's IAM could let one user impersonate another via a personal access token; fixed within four hours, no evidence of exploitation" width="800" height="921"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On September 30, an outside researcher had reported a flaw in Docker Hub's identity and access management. Under certain conditions around converting a personal account to an organization, one user could take on another user's capabilities through a personal access token, which means pushing or pulling images as them. Docker said they fixed it within about four hours and hadn't seen any sign of it being exploited.&lt;/p&gt;

&lt;p&gt;At that point I knew I needed to rotate my tokens and check that my published images hadn't been touched.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I could check
&lt;/h2&gt;

&lt;p&gt;I started compose-lint because I couldn't find a Compose linter that met my needs or that I was happy with, and I'd been looking for a chance to build something open source. I also wanted a project where I could build with complete freedom and put everything I know about security engineering into it, including the release pipeline.&lt;/p&gt;

&lt;p&gt;So every compose-lint image is signed with cosign, keyless, using GitHub Actions' OIDC identity. The signing certificate records the workflow and tag that produced the image, something like &lt;code&gt;publish.yml@refs/tags/v0.34.0&lt;/code&gt;. Someone with Docker Hub push access could push an image, but they couldn't produce that signature without running my workflow in my repo on a release tag.&lt;/p&gt;

&lt;p&gt;That meant I didn't have to take Docker's word for it. I could go check.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I checked
&lt;/h2&gt;

&lt;p&gt;I verified every tag against my workflow identity. Checking that an image has a valid signature isn't enough on its own, since anyone can sign an image. You have to pin who signed it.&lt;/p&gt;

&lt;p&gt;This is where I hit something I hadn't thought about. Most of my images were signed by &lt;code&gt;publish.yml&lt;/code&gt;, but one older release, 0.3.4, was signed by a different workflow I'd used to republish it. Different workflow, different identity in the certificate. I could still verify everything, but it meant using a regexp that allowed both workflows instead of one exact identity. It works, it's just not as clean as I'd like. If you're setting this up, it's worth keeping signing in one workflow, or at least knowing every identity you've ever signed with.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for &lt;/span&gt;tag &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="s2"&gt;"https://hub.docker.com/v2/repositories/composelint/compose-lint/tags?page_size=100"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  | jq &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="s1"&gt;'.results[].name'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
  &lt;/span&gt;cosign verify &lt;span class="s2"&gt;"docker.io/composelint/compose-lint:&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;tag&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--certificate-identity-regexp&lt;/span&gt; &lt;span class="s1"&gt;'^https://github\.com/tmatens/compose-lint/\.github/workflows/(publish|publish-channel)\.yml@refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$'&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--certificate-oidc-issuer&lt;/span&gt; https://token.actions.githubusercontent.com &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/null &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"ok   &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;tag&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"FAIL &lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;tag&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All 42 images verified, and every one traced back to the CI run that built it.&lt;/p&gt;

&lt;p&gt;A signature check only tells you what a tag points to today, though. Someone could point a tag at a bad image, wait for people to pull it, then point it back, and everything would still verify afterward. So I also pulled each tag's &lt;code&gt;last_pushed&lt;/code&gt; time from the Docker Hub API and matched it against my release runs. Every push lined up with a real run. I also compared the full list of tags against my releases to make sure nothing extra had shown up and nothing was missing.&lt;/p&gt;

&lt;p&gt;Everything came back clean. I rotated the tokens and split them up so each job only gets the one it needs: read-only for the nightly scans, push for releases, and a separate one for updating the Docker Hub description.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I changed afterward
&lt;/h2&gt;

&lt;p&gt;Going back through the pipeline, I found a couple of things I wanted to fix.&lt;/p&gt;

&lt;p&gt;The release workflow signed whatever the tag pointed to right after pushing it. In the few seconds between push and sign, someone with write access to the registry could have moved the tag and gotten their image signed by my workflow. The window is small, but it's there. Now the workflow checks that the tag points to exactly what the build pushed, and stops before signing if it doesn't.&lt;/p&gt;

&lt;p&gt;The verify step in CI was also using a loose regexp. It now checks the exact workflow with &lt;code&gt;--certificate-identity "https://github.com/${GITHUB_WORKFLOW_REF}"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And signing doesn't help much if nobody verifies, so I added the command to the docs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;VERSION&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0.34.0
cosign verify &lt;span class="s2"&gt;"docker.io/composelint/compose-lint:&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;VERSION&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--certificate-identity&lt;/span&gt; &lt;span class="s2"&gt;"https://github.com/tmatens/compose-lint/.github/workflows/publish.yml@refs/tags/v&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;VERSION&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--certificate-oidc-issuer&lt;/span&gt; https://token.actions.githubusercontent.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The docs cover &lt;a href="https://tmatens.github.io/compose-lint/verifying/" rel="noopener noreferrer"&gt;how to verify compose-lint images&lt;/a&gt; in more detail, including the SBOM and VEX attestations.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you maintain images and aren't signing yet
&lt;/h2&gt;

&lt;p&gt;On GitHub Actions it's about twenty lines. The job needs &lt;code&gt;id-token: write&lt;/code&gt; so cosign can get a short-lived certificate tied to your workflow, and you sign by digest, not by tag:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;permissions&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;contents&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;read&lt;/span&gt;
  &lt;span class="na"&gt;id-token&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;write&lt;/span&gt;

&lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sigstore/cosign-installer@&amp;lt;pinned-sha&amp;gt;&lt;/span&gt;
  &lt;span class="c1"&gt;# build and push, capturing the digest&lt;/span&gt;
  &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;cosign sign --yes "docker.io/your-org/your-image@${DIGEST}"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see &lt;a href="https://github.com/tmatens/compose-lint/blob/d9006ac2cc0bb2c17024eeab6af180e4c033e08e/.github/workflows/publish.yml#L720-L739" rel="noopener noreferrer"&gt;the sign and verify steps in compose-lint's release workflow&lt;/a&gt;, and the rest of the project is on &lt;a href="https://github.com/tmatens/compose-lint" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Twenty lines is the open source on GitHub version. At a bigger org, signing is the easy part. Managing keys, keeping private repo names out of public transparency logs, deciding which builds to trust, and actually enforcing verification at deploy time is where it gets hard.&lt;/p&gt;

&lt;p&gt;For a small project, though, it's cheap. And the next time a vendor tells you there's no evidence of exploitation, you'll be able to check for yourself.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Personal project, personal views.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>security</category>
      <category>githubactions</category>
      <category>opensource</category>
      <category>docker</category>
    </item>
    <item>
      <title>More than 9 in 10 Docker Compose files skip the basic security flags</title>
      <dc:creator>Todd Matens</dc:creator>
      <pubDate>Fri, 22 May 2026 22:48:21 +0000</pubDate>
      <link>https://dev.to/tmatens/9-in-10-docker-compose-files-skip-the-basic-security-flags-2dpf</link>
      <guid>https://dev.to/tmatens/9-in-10-docker-compose-files-skip-the-basic-security-flags-2dpf</guid>
      <description>&lt;p&gt;I maintain &lt;a href="https://github.com/tmatens/compose-lint" rel="noopener noreferrer"&gt;compose-lint&lt;/a&gt;, a security linter for Docker Compose files, and I ran it over &lt;strong&gt;11,111 public &lt;code&gt;docker-compose.yml&lt;/code&gt; and &lt;code&gt;compose.yaml&lt;/code&gt; files from GitHub&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;6,666 of those are ordinary Compose files. The rest are override files, test fixtures and deliberately vulnerable labs, which the study reports separately and I leave out here. Of the 6,666, compose-lint could lint 5,907. The other 759 use the old Compose v1 layout, are fragments, or aren't valid Compose, which is Finding 3 below. Every percentage below is a share of those 5,907.&lt;/p&gt;

&lt;p&gt;Three things stood out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;99%&lt;/strong&gt; have at least one security finding.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;96%&lt;/strong&gt; set none of the four basic hardening flags.&lt;/li&gt;
&lt;li&gt;The same four findings lead every group of files I looked at, including the official vendor examples people are told to copy.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I don't read this as engineers being careless. Docker Compose leaves the hardening off unless you ask for it, almost nobody asks, and the examples people learn from don't either.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why this exists
&lt;/h2&gt;

&lt;p&gt;I run Compose in my home lab. It's quick, there is little ceremony, and it's enough to stand up a stack on a Saturday.&lt;/p&gt;

&lt;p&gt;What bugged me was how little security tooling there is for it. Kubernetes and Terraform have plenty of scanners, and Compose is an afterthought in most of them. The Compose tools I found solved other problems. &lt;a href="https://github.com/hadolint/hadolint" rel="noopener noreferrer"&gt;Hadolint&lt;/a&gt; lints Dockerfiles. &lt;a href="https://github.com/zavoloklom/docker-compose-linter" rel="noopener noreferrer"&gt;DCLint&lt;/a&gt; is mostly about Compose style and structure.&lt;/p&gt;

&lt;p&gt;I wanted a linter with no configuration, grounded in OWASP and CIS guidance, that I could drop into CI and run against my own stacks. So I wrote one. Then I got curious whether the things I kept fixing in my own files showed up everywhere else, and they do.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I measured
&lt;/h2&gt;

&lt;p&gt;The 6,666 files are sorted by where they came from, because one number for "all Compose files" would average a vendor's polished example with someone's first attempt:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Vendor examples&lt;/strong&gt; (249 files): awesome-compose, Bitnami, Grafana, Vaultwarden and others. This is what a README tells you to copy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;App-store templates&lt;/strong&gt; (596): CasaOS, runtipi, Dockge. They are written for a home LAN.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Template collections&lt;/strong&gt; (1,485): large repos of ready-made stacks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Popular projects&lt;/strong&gt; (1,231): the Compose files that projects with 50 or more stars use themselves.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Long tail&lt;/strong&gt; (3,105): a sweep of GitHub code search. These are ordinary repos that few people look at.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of compose-lint's 28 rules cites the &lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html" rel="noopener noreferrer"&gt;OWASP Docker Security Cheat Sheet&lt;/a&gt;, the CIS Docker Benchmark or Docker's own documentation. The full method is in the &lt;a href="https://tmatens.github.io/compose-lint/state-of-compose/" rel="noopener noreferrer"&gt;report&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding 1: the hardening flags are almost never set
&lt;/h2&gt;

&lt;p&gt;Four findings each show up in 97 to 99% of files:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3n5a5a5flb1ugvkx2cqg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3n5a5a5flb1ugvkx2cqg.png" alt="Ten rules account for 98% of all findings. The four hardening flags are each missing from 97 to 99% of linted files." width="800" height="491"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Filesystem not read-only&lt;/strong&gt; (&lt;code&gt;read_only: true&lt;/code&gt; missing): 98.7%&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No capability restrictions&lt;/strong&gt; (&lt;code&gt;cap_drop: [ALL]&lt;/code&gt; missing): 98.6%&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No resource limits&lt;/strong&gt; (no memory or CPU limit): 97.4%&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Privilege escalation not blocked&lt;/strong&gt; (&lt;code&gt;no-new-privileges&lt;/code&gt; missing): 97.3%&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;96.2% of files have all four findings, so they set none of the flags.&lt;/p&gt;

&lt;p&gt;None of these is rated HIGH. Each one is a control that was left off, which is different from something being actively misused. Setting them looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:1.30-alpine@sha256:...&lt;/span&gt;   &lt;span class="c1"&gt;# pin a digest along with the tag
&lt;/span&gt;    &lt;span class="na"&gt;read_only&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;                       &lt;span class="c1"&gt;# CL-0007
&lt;/span&gt;    &lt;span class="na"&gt;cap_drop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;ALL&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;                       &lt;span class="c1"&gt;# CL-0006
&lt;/span&gt;    &lt;span class="na"&gt;security_opt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="s"&gt;no-new-privileges:true&lt;/span&gt;            &lt;span class="c1"&gt;# CL-0003
&lt;/span&gt;    &lt;span class="na"&gt;deploy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;limits&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;                           &lt;span class="c1"&gt;# CL-0026
&lt;/span&gt;          &lt;span class="na"&gt;memory&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;512M&lt;/span&gt;
          &lt;span class="na"&gt;cpus&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'0.50'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It is rarely that simple in practice. A read-only filesystem needs a &lt;code&gt;tmpfs:&lt;/code&gt; for the paths the app writes to, and some images need one or two capabilities added back. The &lt;a href="https://tmatens.github.io/compose-lint/hardening/" rel="noopener noreferrer"&gt;hardening guide&lt;/a&gt; walks one file from twelve findings to none and shows what breaks at each step.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Aren't these optional settings and not vulnerabilities?"&lt;/strong&gt; Mostly, yes. A finding here means the file leaves a recommended control unset. It does not mean anything was exploited.&lt;/p&gt;

&lt;p&gt;Whether that matters depends on what the service does and where it runs, and that call belongs to whoever runs it. These four are named controls in the &lt;a href="https://www.cisecurity.org/benchmark/docker" rel="noopener noreferrer"&gt;CIS Docker Benchmark&lt;/a&gt; and the OWASP cheat sheet, so the linter is reporting a difference from a published baseline. What it saves you is having to know that each control exists.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding 2: the examples people copy are no better
&lt;/h2&gt;

&lt;p&gt;I expected the vendor examples to be the hardened ones. Every vendor example that lints has at least one finding, 191 of 191. So does every app-store template and every popular project's file. The only clean files in the study are 46 in the long tail and 1 in a template collection.&lt;/p&gt;

&lt;p&gt;Popular projects' files have the most findings, about 20 per file against 9 to 14 elsewhere. That looked like a worse result until I counted services:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq5ljfjvjz54vapz62udb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq5ljfjvjz54vapz62udb.png" alt="Popular projects average 20 findings per file, more than any other group. Per service, every group has between 5.8 and 6.3." width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Per service, every group has about six findings. Popular projects write 3.3 services per file and templates write 1.5 to 2.1, so the popular files are bigger and the rate is the same. A popular project's services are no more hardened than anyone else's, and a vendor's aren't either.&lt;/p&gt;

&lt;h2&gt;
  
  
  How serious the findings are
&lt;/h2&gt;

&lt;p&gt;Most findings are the four flags above. The serious ones are less common. This is the worst finding in each file:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnw10zd6mxtxxceyl78xr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fnw10zd6mxtxxceyl78xr.png" alt="Of every 100 files, 11 have a CRITICAL finding, another 30 have a HIGH, 58 have only MEDIUM or LOW findings, and fewer than 1 is clean." width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Two of those are worth naming. 7.8% of files mount the Docker socket into a container, which hands that container control of the host. In popular projects it is 16.1%. And 28.4% of files have a literal credential in them, more than one in four.&lt;/p&gt;

&lt;p&gt;If you run a homelab, your threat model matters here. A box behind a firewall with one user is a different risk from something exposed to the internet, and most findings are something to decide about. I'd start with the CRITICAL and HIGH ones, which is why the CI gate fails on those by default, and work through the four flags after that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding 3: one in nine files never gets linted
&lt;/h2&gt;

&lt;p&gt;This is the one I didn't expect. 759 of the 6,666 files produced no lint result at all, which is why the percentages above are out of 5,907:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxekw9uicg2aenmes2k22.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxekw9uicg2aenmes2k22.png" alt="One in nine files was never linted. In the long tail it is 16%: 247 skipped and 240 parse errors." width="800" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are two reasons. 466 files use the old Compose v1 layout or are fragments with no services, so there is nothing in them to lint. And 293 are not valid Compose. In the long tail, 7.7% of files fail to parse, and four out of five of those are a shape error like this one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# What a lot of people write (does not parse):
&lt;/span&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;nginx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:1.27&lt;/span&gt;

&lt;span class="c1"&gt;# What Compose wants:
&lt;/span&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;nginx&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;nginx:1.27&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A file that doesn't parse was never deployed by a real engine, so these are documentation snippets, tutorial follow-alongs and first drafts.&lt;/p&gt;

&lt;p&gt;The first version of this article got this wrong. The linter exits cleanly on a v1 file because it finds nothing to check, and the early editions of the study counted those files as clean. Most of the gap between the 91% I reported then and the 99% here comes from that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the flags are off
&lt;/h2&gt;

&lt;p&gt;Docker's defaults are chosen so a container runs the first time: a writable filesystem, the default capability set, no limits. Hardening is something you opt into, and that means knowing the control exists, checking that your app still works with it, and adding a few lines per service.&lt;/p&gt;

&lt;p&gt;Knowing it exists is the hard part. The controls are spread across the Compose spec, the Docker run reference, the OWASP cheat sheet and the CIS benchmark. Most people writing a Compose file want their stack up, and I don't think it's reasonable to expect them to carry all of that in their head.&lt;/p&gt;

&lt;p&gt;It also doesn't get better with time. Files written in the last year have 5.99 findings per service, and files three or more years old have 5.82. The examples never opt in, the next person copies them, and their file becomes someone else's example.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this doesn't show
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;It counts misconfigurations. It does not show that anything was exploited.&lt;/li&gt;
&lt;li&gt;It describes this sample. There are no significance tests and no estimates for all Compose files.&lt;/li&gt;
&lt;li&gt;It covers public GitHub only. Private and company Compose files may look different.&lt;/li&gt;
&lt;li&gt;It only counts what compose-lint has a rule for. Some hardening, such as a non-root user, a process limit or network segmentation, was left out of the linter on purpose, and the &lt;a href="https://tmatens.github.io/compose-lint/hardening/#hardening-compose-lint-does-not-grade" rel="noopener noreferrer"&gt;hardening guide&lt;/a&gt; covers it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The report has the full list under &lt;a href="https://tmatens.github.io/compose-lint/state-of-compose/#what-this-study-does-not-claim" rel="noopener noreferrer"&gt;what this study does not claim&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it on your own files
&lt;/h2&gt;

&lt;p&gt;compose-lint is MIT licensed, needs no configuration, and its only dependency is PyYAML.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# one-off, without installing anything&lt;/span&gt;
uvx compose-lint docker-compose.yml

&lt;span class="c"&gt;# or the published image&lt;/span&gt;
docker run --rm -v &lt;span class="s2"&gt;"$(pwd):/src"&lt;/span&gt; composelint/compose-lint:1.6.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In CI there is a GitHub Action:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# .github/workflows/compose-lint.yml
&lt;/span&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;compose-lint&lt;/span&gt;
&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;pull_request&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="na"&gt;permissions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;contents&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;read&lt;/span&gt;
&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;lint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v6&lt;/span&gt;
      &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;tmatens/compose-lint@v1&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;pattern&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"**/*compose*.y*ml"&lt;/span&gt;
          &lt;span class="na"&gt;fail-on&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;high&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;fail-on: high&lt;/code&gt; is the default. It fails the job only on HIGH and CRITICAL findings, so you can adopt it without fixing every MEDIUM on day one. There is also a pre-commit hook, JSON and SARIF output, and &lt;code&gt;compose-lint --explain CL-0007&lt;/code&gt; prints any rule's reasoning and fix. Releases are signed and ship with build provenance, and the &lt;a href="https://github.com/tmatens/compose-lint" rel="noopener noreferrer"&gt;repo&lt;/a&gt; explains how to verify one.&lt;/p&gt;

&lt;p&gt;The tables, the method and the steps to reproduce every number are in the report: &lt;strong&gt;&lt;a href="https://tmatens.github.io/compose-lint/state-of-compose/" rel="noopener noreferrer"&gt;State of Docker Compose Security&lt;/a&gt;&lt;/strong&gt;. If you maintain a Compose example that other people copy, I'd welcome an issue or a pull request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Updated November 2026.&lt;/strong&gt; This article was first published in May 2026 with numbers from compose-lint 0.7.0 and 6,444 files. It now uses the fourth edition of the study: compose-lint 1.6.0, 11,111 files, run on November 15, 2026. The &lt;a href="https://github.com/tmatens/compose-lint/blob/082db9f5c63c5a5637f2e9e2b29d00e345023b00/docs/state-of-compose.md" rel="noopener noreferrer"&gt;first edition&lt;/a&gt; is still available.&lt;/p&gt;

&lt;p&gt;compose-lint is a personal project and is not affiliated with my employer. The views here are my own.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>security</category>
      <category>containers</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
