Container image scanning

Also known as: container vulnerability scanning

On this page 7

Container image scanning is the automated inspection of a container image’s contents to identify known vulnerabilities, embedded secrets, license issues and insecure configuration before the image runs in production. In Containers practice within the Cloud field, it is also called container vulnerability scanning, and it is one of the main controls for software supply chain security.

A scanner does not execute the image. It reads the image layers and metadata, builds an inventory of operating system packages and application libraries, and compares that inventory with vulnerability databases that map package versions to published CVE identifiers. The result is a report of findings ranked by severity, which pipelines and registries use to block, warn or approve an image.

How container image scanning works

A container image is a stack of filesystem layers plus a configuration file, packaged according to the Open Container Initiative image specification. The scanner unpacks these layers, reads package manager databases such as those of dpkg, rpm or apk, and parses language manifests and lock files for ecosystems such as npm, PyPI, Maven, Go modules and RubyGems.

From this material the scanner builds a software bill of materials (SBOM), often in the SPDX or CycloneDX format. It then matches each component and version against vulnerability feeds, including the National Vulnerability Database, distribution security trackers and language advisory databases, and attaches CVSS severity scores and fix versions where they exist.

The table below shows what a scanner typically examines and which kind of problem each source reveals.

Image contentExampleFinding type
OS package databasedpkg status, rpm databaseVulnerable system libraries
Language dependenciespackage-lock.json, requirements.txtVulnerable application libraries
Static binariesGo or Rust executablesEmbedded vulnerable modules
Image configurationUser, exposed ports, environmentRunning as root, risky defaults
File contentsConfiguration files, keysExposed secrets and credentials
What a scanner inspects inside an image

Where scanning fits in the container lifecycle

Scanning is most effective when it runs at several points in the lifecycle, because new vulnerabilities are disclosed every day for images that were clean when they were built. A single scan at build time therefore gives only a snapshot of known risk, not a lasting guarantee.

The following table compares the main scanning stages and their purpose.

StageTriggerMain benefitLimitation
Developer workstationManual or IDE pluginFastest feedbackEasy to skip
CI pipelineEvery buildBlocks vulnerable images earlyOnly covers new builds
Container registryPush and periodic rescanCatches newly disclosed CVEsDoes not stop running workloads
Admission controlDeployment to a clusterEnforces policy before runtimeNeeds reliable scan results
RuntimeRunning containersShows what is actually deployedFindings arrive after exposure
Scanning stages compared

Most registries, including Docker Hub and the major cloud registries, offer built-in scanning, and open-source scanners such as Trivy and Grype are commonly added to CI pipelines. In Kubernetes, an admission controller can reject images that lack a recent passing scan or a valid signature.

Interpreting and prioritizing scan results

A typical image built on a full distribution base can produce dozens to hundreds of findings, and treating them all as equally urgent quickly leads to alert fatigue. Effective triage combines severity with exploitability and reachability, asking whether the vulnerable code is present, loaded and exposed in this workload.

Useful signals include the Known Exploited Vulnerabilities catalog, exploit prediction scores such as EPSS, and VEX statements, which let a vendor or team record that a vulnerability does not affect a given product. The decision table below shows a common way to turn findings into actions.

FindingRecommended actionReason
Critical, fix available, exploited in the wildBlock the build and patch nowHighest real-world risk
High, fix availableFix within a defined service levelCheap to resolve, meaningful risk
High, no fix availableDocument, mitigate, monitorBlocking would stop all releases
Component not reachable at runtimeRecord a VEX not-affected statusReduces noise without hiding risk
Low or informationalFix during regular base image updatesLittle benefit from urgent work
A practical triage policy

Reducing findings at the source

The most durable way to improve scan results is to ship less software. Every package in an image is a potential finding, so smaller images mean fewer vulnerabilities to track and a smaller attack surface at runtime.

  • Start from a minimal or distroless base image that contains only the runtime the application needs.
  • Use a multi-stage build so compilers, package managers and build tools stay out of the final image.
  • Rebuild images regularly from updated base images instead of patching running containers.
  • Pin base images by digest and update them deliberately, so scan results stay reproducible.
  • Keep secrets out of the Dockerfile and build context, because deleted files remain in earlier layers.

Limitations of container image scanning

Image scanning finds known issues in recognizable components. It does not discover new vulnerabilities in custom code, and it does not observe how the container behaves once it runs.

The table below lists frequent blind spots and the complementary control that covers each one.

Blind spotCauseComplementary control
False negativesSoftware copied in without package metadataSBOM generated at build time
False positivesBackported fixes not reflected in version numbersDistribution-aware matching and VEX
Zero-day vulnerabilitiesNot yet in any databaseRuntime detection and least privilege
Flaws in custom codeNo public advisory existsStatic and dynamic application testing
Tampered imagesScan result not tied to the deployed imageImage signing and digest pinning
Blind spots and complementary controls

Understanding it simply

A container image is like a sealed moving box that holds a program and everything it needs to run. Container image scanning is opening the packing list and checking every item against a recall list before the box is shipped.

If a part inside is known to be faulty, the scanner flags it and usually says which newer version fixes it. Because new recalls are announced all the time, the boxes already in storage need to be checked again regularly, not only once when they were packed.

Applied in practice

A fintech development team builds about thirty microservice images a day and deploys them to Kubernetes. The first scan of its Node.js images, built on a full Debian base, reports more than 400 findings, most of them in system packages the services never use. The team moves to a multi-stage build with a slim base image, and the count falls to about 40 findings, of which six are high severity with fixes available.

The team then sets a policy: the CI pipeline fails on critical vulnerabilities with a fix, the registry rescans every image nightly, and an admission controller rejects images without a passing scan from the last seven days. When a widely exploited library flaw is published months later, the nightly rescan identifies the three affected services within hours, and patched images are rebuilt and deployed the same day.