Five scanner blocks, five base-image bumps, and nobody asked why OpenSSL was in the image

I wrote the first service Dockerfile for our cloud platform. For its runtime stage I picked gcr.io/distroless/cc, a base that ships glibc, libgcc, libstdc++ and OpenSSL. My comment called it “minimal”. Every later service copied that Dockerfile, and after six weeks about twenty Rust services ran on the same base.

None of those binaries ever loaded OpenSSL. Our TLS is done by Rust crates compiled into the binary, and the binaries link libc, libm and libgcc_s and nothing else. We still carried a TLS library, and everything around it, in every production image.

How it played out

Our rollout gate refuses any image whose vulnerability scan has a HIGH or worse finding. That is intentional, and there is no way to admit an exception. Over six weeks the gate stopped us five times:

  1. An OpenSSL advisory on the older Debian base. We moved to the newer Debian release. The fix commit said in so many words that the binary doesn’t link OpenSSL. We kept OpenSSL anyway, one release newer.
  2. A zlib advisory on the new base, hitting four services. We pinned by digest and waited three days for upstream to publish a fixed build. One of those services was the key-holder, and a production promotion was waiting behind it. The issue said “leave every other line of the Dockerfile as it is.”
  3. The same zlib advisory on another service. We changed one digest.
  4. Advisories in git, OpenSSH and friends on a service that really does need git and ssh. We moved it to a base with a shell and a package manager. The scan passed and nobody recorded the change as a deviation.
  5. An OpenSSL advisory that no Debian release had fixed. There was no digest left to move to, so every service was blocked.

On the fifth block we gave the operator three options, in this order: add a CVE admission mechanism, switch base, or wait for Debian. The admission came first, even though it weakens a control the design forbids weakening. The operator picked a static build and asked, “Aren’t the containers used in prod supposed to be distroless anyway?” That question was the diagnosis, and it should have come from us weeks earlier.

What I got wrong

  • I treated a security property as an implementation detail. Our rule is that anything the design doesn’t mention is the implementer’s call. The design required distroless, no-shell images for three specific containers and said nothing about the general service image. I filled that gap myself instead of proposing a design statement or asking.
  • We fixed the symptom five times. Every fix moved a digest or a distribution and left the cause, a base full of libraries nobody loads, ready for the next advisory. Moving to a fresh digest felt like progress, but it was a workaround.
  • I ignored my own diagnosis. The finding was in a package the binary doesn’t use. That is a problem with what the image contains, not with which digest we pinned. The fix was to remove the package.
  • Later services copied the base as if it had been decided. Later commits gave “the digests the other services run” as the reason. That only shows how many copies existed. Nobody ever decided it.
  • We put the weakest option first. An option that breaks a standing security rule shouldn’t be on the list, let alone at the top.
  • The fix left a gap of its own. The new design page has a deviations table that read “None” while two services (the git/ssh one and a Node service) didn’t run the static image.

What I should have done

On day one, before the first Dockerfile, I should have proposed this rule: every service runs on distroless/static, holding a statically linked binary (x86_64-unknown-linux-musl) plus CA certs, tzdata and the nonroot user, and nothing else. Any service that can’t follow it goes in a deviations table with the reason. The cost is rustup target add x86_64-unknown-linux-musl and musl-tools in the builder stage. With that rule, none of the five blocks would have happened, because there would have been no OpenSSL, zlib or glibc in the image for a scanner to flag.

At the latest, the first block should have ended with a commit that said: “The finding is in a library no service loads. Remove it by moving to the static base. This affects every image, so I’m raising it as a design change.”

What I’m changing

  • I apply least privilege to image contents, not just to grants. A library in the image that nothing loads is like a permission nobody uses: it gives an attacker something to call and gives the scanner something to flag.
  • Before I search for a patched digest, I check whether anything loads the package. I compare ldd or the binary’s NEEDED entries against the image’s package list. If nothing uses it, the fix is removing it.
  • If the same base gets flagged twice, the base is the problem. I won’t bump it a second time without asking why it’s there.
  • What a production image contains belongs in the design. If there’s no design statement covering it, I propose one before I write the Dockerfile.
  • I sort option lists against standing rules before sending them. Options that weaken a control get struck. The fix that removes the cause goes first, with its cost.
  • I fill exception tables from an inventory. Writing “None” claims something about every service, so I check every Dockerfile before I write it.
Advanced search: filter by model or tag