Skip to main content

The Vulnerability Debt You Inherit From Your Base Image

· 8 min read
Ankush K
Co-founder and CTO, Dwaar
The Vulnerability Debt You Inherit From Your Base Image

You open the scan report for a small service and the list runs for pages, full of packages nobody on the team chose. They arrived on one line of the Dockerfile, and the list keeps growing after you stop touching that line.

It behaves like debt. The principal is how much your base image contains. The interest is how long ago it was built.

The ticket queue is the wrong tool​

The obvious response is to treat the report as a queue: sort by severity, assign the top to the service owner, work down. That fails structurally.

NIST SP 800-190 calls the base layer "the underlying layer upon which all other components are added" and is blunt about fixes: "with containers these updates must be made upstream in the images themselves, which are then redeployed." The service owner cannot close these findings from application code. The fix is a different build.

The queue also refills by itself. Docker's build guidance says "Building an image is taking a snapshot of that image at that moment." NIST draws the consequence: an image built from current components "may be free of known vulnerabilities for days or weeks after its creation." After that, the snapshot holds still while newly discovered vulnerabilities pile up against it.

What the studies show, and how old they are​

Shu, Gu and Enck analyzed 356,218 Docker Hub images, work they date to late April 2016. They reported that "vulnerabilities commonly propagate from parent images to child images" and that "many images have not been updated for hundreds of days."

Zerouali and colleagues studied 7,380 Debian-based images. Only 12.2% of the unique installed packages, 488 of 3,975, had security issues, yet 96% of containers were affected at every severity level except unassigned. The authors suggest that small set possibly explains it.

Both datasets are old: the Shu image analysis dates from 2016, and the Zerouali vulnerability data is the Debian tracker as of March 2018. Neither tells you what share of your own image's findings comes from the base, and I have not found a neutral source with a general figure, so I will not claim "most". The evidence is narrower: inheritance is real, and it was large in the images studied.

The route matters more than any count. CISA's alert on the xz backdoor, CVE-2024-3094, said XZ Utils "may be present in Linux distributions." I am not claiming any particular base image shipped the backdoored versions. The point is that such software reaches you through the OS layer, whatever your dependency manifest says, which is why you scan the artifact you ship.

Three levers, and what each one buys​

LeverWhat it pays downWhat it costsWhere it stops
Fewer packagesPrincipalDebugging access, possible compatibility workWhat you still need is still inherited
Scheduled rebuildsInterestThe base changes under you, so tests have to catch itFixes that do not exist yet, end-of-life tags
Pinning by digestNeither. It buys reproducibilityFreezes every known vulnerability in that baseNeeds a scheduled bump to help security

Fewer packages. Docker says a smaller base "minimizes the number of vulnerabilities introduced through the dependencies" and advises a production stage without compilers and build tools. A study of 15 machine learning containers found bloat "exacerbating vulnerabilities by up to 99%." That is an upper bound from ML containers only.

Start with the production stage, because removing a compiler from production is a change you can reason about. Swapping the whole base for a minimal one is where I slow down: you may lose the tools you debug with, and a change of C library, say glibc to musl, can mean real compatibility work. I have no neutral number for those costs; that is judgment, not measurement.

Scheduled rebuilds. Rebuild on a calendar, not when the service happens to change, because a quiet service is the one whose base ages longest. A tag like ubuntu:24.04 "may resolve to a different underlying version of the ubuntu image, as the publisher rebuilds the image with new security patches", and Docker's --pull flag forces the build to fetch the newer base. Then redeploy.

Rebuilding will not reach zero. In the Zerouali dataset "nearly half of all vulnerabilities are still open." It also cannot rescue a dead tag. When Alpine's official Docker images shipped a root account with an empty password, CVE-2019-5021, fixes landed in rebuilt newer tags, while 3.3, 3.4 and 3.5 were end-of-life and stayed vulnerable. Your calendar has to move the base version as well as the build.

Pinning by digest. The OCI image spec says a digest "uniquely identifies content by taking a collision-resistant hash of the bytes", and Docker says a pin means "you're guaranteed to always use the same image version, even if a publisher replaces the tag with a new image." Worth having: you know exactly what you built from.

It also means the publisher's patches stop reaching you. My position is to pin and also run a scheduled, reviewed bump of the digest. That pairing is my inference from Docker's guidance, not a measured result.

Where this stops applying​

The count is not risk. Zerouali's per-container figures had a mean of 1,336.44 and a median of 601, but those are Debian tracker entries that include unfixed and low severity issues. Debian itself says an issue "might not warrant an (immediate) security advisory, for example if its severity is minor."

Present does not mean reachable either. Alpine's advisory said "You are not affected unless you have shadow or linux-pam packages installed." The glibc bug CVE-2023-4911 has been in CISA's KEV catalog since 2023-11-21, so nobody should wave it away, but NVD describes it as a local attacker "launching binaries with SUID permission". What it means depends on what your container holds and who can run things inside it.

So use the levers to keep the inherited list short and young, and use exploit signals to order what remains. This is the problem Dwaar works on: discovering what you ship from source control, registries and cloud accounts, scanning it, and keeping the results in one findings list with EPSS and KEV signals.

Try it on one image​

Pick one image you ship and find the digest its FROM line resolved to at build time. If you cannot recover it, you have your reason to start pinning.

Scan the shipped image with whatever scanner you already run, then scan the base at that digest on the same day, and subtract. That is your inherited share, and it beats every statistic in this post.

Now rebuild with --pull and scan again. What disappeared was interest. What stayed is principal, or fixes upstream has not shipped. Check what is left against the KEV catalog, and you will know which lever to pull first.

References​