Container Image Hardening: Patch, Strip, and Repeat

One RapidFort customer ran a runtime scan across eight containers and found 1,661 vulnerabilities. After replacing their base images with curated, same-version equivalents and rebuilding, the same eight containers reported 24. Many teams treat container image hardening as a passed configuration benchmark, but NIST defines hardening as patching vulnerabilities and turning off nonessential services, and most images need both. Both also have to repeat, because clean images don't stay clean. This article covers how to control what you inherit, patch by replacement, strip what never runs, and build all three into your pipeline, with a second customer who went from 5,286 CVEs to three in 48 hours.
In the webinar Best Practices for Software Supply Chain Security, George Manuelian, Chief Strategy Officer at RapidFort, described how fast findings now pile up. A team running eight containers used to see about a dozen new findings over two weeks. Today, a couple of hundred can accumulate within a week on an image that started clean.
Most of what you ship is inherited
A modern container image is mostly software your team didn't write. It stacks a base OS layer, OS-level packages for networking, SSL, encryption, or FIPS, a framework layer with the language runtime and its direct and transitive dependencies, and then your application binaries. Manuelian estimates that your own code is 10% or less of what you ship.
Inherited vulnerabilities also multiply. Your scanner counts each CVE everywhere it appears, so a base image with 100 vulnerabilities under 100 applications produces 10,000 findings. Two questions show where your findings come from:
- How many of your last scan's findings came from your own binaries, and how many came from the layers underneath them?
- Who chose your base images and frameworks? Was it a controlled decision, or did they arrive with legacy software and whatever was pulled from the internet?
Controlling the base layer is the first step to controlling vulnerabilities across your whole estate.
Patch by replacing the base image, without a migration
Patching inherited CVEs one package at a time is slow. Replacing the image they came from with a curated version that is already patched eliminates them in a single rebuild.
Compatibility decides whether this works. If your teams run Ubuntu and the curated alternative is a proprietary OS or a different distribution, engineers have to change package managers and rewrite Dockerfiles. That's a migration, and migrations stall adoption. If the curated image matches the same OS and the same version, such as Python 3.12 on Ubuntu 20.04, it's a drop-in replacement. You mirror the curated images into your own registry, builds pull from there, and developers see no change. In most Dockerfiles, the change is the FROM line:
# Before FROM ubuntu:20.04 # After: the curated equivalent, mirrored into your registry FROM [INSERT internal registry path]/ubuntu:20.04
In the eight-container example above, a MongoDB image carrying 155 vulnerabilities dropped to three after replacement with its RapidFort Images equivalent. A first-party Node.js application rebuilt on a clean Ubuntu 22.04 (Jammy) base image, with no changes to its libraries or Dockerfile, went from 521 CVEs to nine. Across all eight containers, the total fell from 1,661 to 24.
That count will rise again as new CVEs are disclosed. RapidFort Images are updated daily, so rebuilding from them brings the count back down. Teams that rebuild every day pick up those fixes with each build instead of scheduling patch sprints.
Strip what never runs
Patching eliminates CVEs in the components you keep. The second half of hardening is removing the components you don't need. Manuelian calls it scorched earth: an attacker who gets into a container should find nothing to work with. The usual leftovers are shells, package managers, build tools left in runtime images, unused libraries, and default accounts and sample files.
Each leftover helps an attacker. A package manager lets them install a malicious package, and network utilities let them open a tunnel and move data out. Attackers find it hard to bring their own tools into a container, so most rely on tools that were left behind.
AI-assisted development adds to the pile. When AI writes much of the code, engineers often don't know which packages and versions are in use, and each prompt change can pull in new libraries that nothing cleans up. One RapidFort customer had 125 vulnerabilities in a Bluetooth driver package. They didn't use Bluetooth.
Removing unused code pays off beyond the CVE count. Smaller images cost less to store and deploy. Less code also gives AI vulnerability discovery models, such as Anthropic's Claude Mythos Preview, fewer places to find the next flaw. When an exploit depends on chaining several vulnerabilities, removing unused components can break the chain.
How much you can remove depends on the image. In RapidFort's experience, images for interpreted and runtime-based languages such as Python, Node.js, and Java shrink by 60% to 80%, on average. Distroless, minimal, or scratch images and compiled languages such as Go and Rust shrink by around 30%, on average. We often see images shrinking to up to 90%, however.
Build profile, replace, and optimize into every build
None of this holds as a one-time project. RapidFort frames the continuous version as zero trust software architecture (ZTSA). Zero trust networking controlled access to the network, and zero trust identity controlled who could access what. ZTSA applies the same thinking to the software itself, because so much of it comes from outside your organization. It covers three points:
- Intake: verify that public software has no malware, tampering, or planted vulnerabilities before it enters your registry. RapidFort Images are signed with Sigstore and Cosign and carry Supply-chain Levels for Software Artifacts (SLSA) attestations, and your team can re-sign them with your own certificates after verification.
- Build: pull packages only from that trusted registry, so new dependencies don't reintroduce risk. In March 2026, attackers compromised Trivy, a widely used open source scanner, publishing a malicious release and hijacking its GitHub Actions to steal CI/CD credentials. Even trusted tools need to come from a verified source.
- Runtime: track what the application uses, where new vulnerabilities land, and what the pipeline needs to change.
In practice, that becomes a repeating cycle:
- Profile. A Helm chart deploys the RapidFort profiler as a DaemonSet into a QA or staging cluster, where it generates a software bill of materials (SBOM) and a Runtime Bill of Materials (RBOM®). Run it through at least one full QA cycle. Ideally it keeps running across every cluster where the application is deployed, so infrequently used code paths are captured over time. Take a snapshot of the profile before each build. The profiler stays in QA and staging and doesn't ship to production. In serverless environments, where you can't deploy a DaemonSet, the profiler is injected into the container itself. Teams already running CrowdStrike Falcon Cloud Security can use it as the runtime data source instead of deploying another DaemonSet.
- Replace. Swap base images for drop-in curated equivalents on every build.
- Optimize. Use the RBOM® to remove unused packages and files, so every build ships only what the application uses.
Profiling coverage is the limitation to plan for. A code path that never runs during profiling looks unused, so keep the profiler running long enough to capture infrequently used paths before you remove components from production builds. In addition, you may also specify which components should always be retained in a hardened image by using a profile file.
From 5,286 CVEs to three in 48 hours
One RapidFort customer preparing a deployment for a large financial institution needed to reach zero critical and high vulnerabilities. Their scanner reported 5,286. The engineering estimate for fixing them manually was five or six engineers working for at least three months.
| Step | What happened | Vulnerabilities remaining |
|---|---|---|
| Starting point | Scanner results | 5,286 |
| Profile | 1,700 found not affected; tickets closed with justifications recorded in Vulnerability Exploitability eXchange (VEX) documents | 3,586 |
| Replace | Base images swapped for curated, same-version equivalents, including older images such as Ubuntu 20.04 and Alpine 3.20, in a build that took about 90 minutes | About 500 |
| Optimize | Unused third-party packages removed, including the Bluetooth driver; image shrank from 1.8 GB to 262 MB | 3 (no fix available yet) |
The whole process took 48 hours. The same steps now run in their CI/CD pipeline, so every build pulls a clean image and removes unused components. For the full account, read How to cut container CVE remediation from months to 48 hours. To decide which remaining CVEs matter, see Container CVE triage: loaded, reachable, and exposed.
Start from a clean base
Most of the software you ship is software you didn't write, and every component you don't ship is one that can't carry a CVE. Patching by replacement and stripping what never runs, on every build, makes software supply chain security part of how your software is built instead of a cleanup project after release.
Learn more about RapidFort Images: tens of thousands of drop-in, near-zero CVE images on the distributions your teams already use, updated continuously.
Latest posts
Eliminate Attack Vectors at the Source
Continuously eliminate up to 99.9% of CVEs without code changes
Products
Use Case
Quicklinks
Stay in touch
Subscribe for product updates and RapidFort newsletter.
Address
440 North Wolfe Road, Sunnyvale, CA 94085
© 2026 RapidFort, Inc.
RapidFort, RAPIDFORT, and RBOM® are registered trademarks of RapidFort, Inc. All other marks and names mentioned herein may be trademarks of their respective companies.




