Cloud & app security

Container Vulnerability Scanning: How It Works and Best Practices

A container image is a stack of other people's software, and any layer can hide a known vulnerability. Scanning finds those flaws at build time, in the registry, and at runtime — before attackers do.

Cysoro Security TeamPublished · 9 min read
CLOUD & APP SECURITY Container Vulnerability Scanning Find the flaws in your images before attackers do — tools and best practices. SCAN REPORT CRITICAL — 2 fix available HIGH — 5 3 fixable MEDIUM — 11 scheduled Base image: debian:12-slim 1,204 packages checked
Quick answer

Container vulnerability scanning is the automated inspection of container images, their dependencies and running workloads to detect known vulnerabilities, exposed secrets and misconfigurations before they reach production. A scanner inventories every package in an image, matches it against CVE databases and vendor advisories, and reports what is vulnerable, how severe it is, and whether a fix exists.

Key takeaways

  • A scanner inventories every package in an image and matches it against CVE databases and vendor advisories.
  • Scan at every stage — build, registry and runtime — because new CVEs appear on old images every day.
  • Gate builds on fixable, exploitable findings, not on raw severity alone, or developers will bypass the gate.

A container image is a stack of other people's software: a base operating system, system libraries, language packages, and your own code on top. Any layer can hide a known vulnerability, and a single outdated package can turn a routine deployment into an incident. Container vulnerability scanning exists to find those flaws before attackers do.

What is container vulnerability scanning?

Container vulnerability scanning is the automated inspection of container images, their dependencies and running workloads to detect known vulnerabilities, exposed secrets and misconfigurations before they reach production. It checks image layers, operating system packages, application dependencies and configuration, and reports what is vulnerable and how severe it is.

It is not a single checkpoint. Effective scanning runs at multiple stages of the container lifecycle: on developer laptops, in the CI pipeline, in the registry, at admission control in Kubernetes, and at runtime. An image that passed CI in March can carry a critical CVE by November, because new vulnerabilities are published every day against old images.

Scanning is also only one part of container security. It finds known flaws in what you ship. It does not catch runtime attacks, zero-days, abused credentials or insecure cluster configuration, so it needs runtime detection alongside it. Our guide to the 4 types of vulnerability explains where image flaws fit in the bigger picture.

Scan at every stage — not just before release 1 Build Scan in CI on every pull request 2 Registry Rescan stored images daily 3 Deploy Block failing or unsigned images 4 Runtime Flag drift and loaded packages 5 Fix Rebuild, rescan, redeploy A clean image at build time is not a clean image forever.
Container scanning belongs at every stage of the lifecycle. Illustration by Cysoro.

How does container vulnerability scanning work?

A scanner works in three steps. First it inventories the image: it reads every layer and lists the operating system packages, language dependencies, and files inside. Second, it matches that inventory against vulnerability databases — the National Vulnerability Database, the GitHub Advisory Database, OSV, and distro-specific feeds — plus vendor advisories.

Third, it reports each match with a severity score, the fixed version if one exists, and the package path that shows how the vulnerable package entered the image.

Accuracy depends on matching packages to the right advisories. Debian, Ubuntu and Red Hat backport fixes without changing upstream versions, so a scanner that only checks the version number will flag patched packages as vulnerable. A good scanner reads distro feeds and knows which versions are actually fixed.

It also needs to see language packages and static binaries: Go binaries, fat JARs and vendored Python wheels hide dependencies that an OS-only scanner never sees.

Most scanners also generate an SBOM — a software bill of materials — in SPDX or CycloneDX format. The SBOM is the inventory itself, and it lets you rescan later without pulling the image again: when a new CVE is published, you check the SBOMs you already have.

A typical first scan with Trivy, the most widely used open-source scanner, is one command:

trivy image --severity HIGH,CRITICAL --exit-code 1 myapp:latest

That scans the image, reports high and critical findings, and fails with exit code 1 if any are found — which is exactly what a CI gate needs.

What does a container scanner actually find?

A scan report covers five different kinds of finding, and it helps to know which is which — they need different fixes.

Finding typeWhat it isExample
VulnerabilityA known flaw (CVE) in an OS or language packageAn outdated OpenSSL in a Debian base layer
MisconfigurationAn unsafe setting in a Dockerfile, manifest or IaCContainer running as root, privileged pod
MalwareMalicious binaries or scripts baked into a layerA cryptominer in a typosquatted public image
SecretCredentials left in the image filesystem or historyAn AWS access key in a copied .env file
Compliance findingA failed control against a framework or benchmarkA failed CIS Docker Benchmark check

Not every scanner covers every row. Trivy covers vulnerabilities, misconfigurations, secrets and SBOM generation in one tool. Grype focuses on vulnerability matching and leaves misconfiguration to other tools. Commercial platforms add runtime context and compliance frameworks. Check coverage before you choose, and do not assume a "vulnerability scanner" also finds secrets.

What are the best container vulnerability scanners?

The best scanner depends on where you run containers and how much context you need. Open-source scanners cover build-time image checks well, while commercial platforms add runtime context, policy governance and remediation workflows. Most teams start free and add a platform when the CVE backlog becomes unmanageable.

Trivy — best free all-in-one scanner

Trivy is Aqua Security's open-source scanner for images, filesystems, repositories and Kubernetes clusters. It covers OS packages, language dependencies, infrastructure-as-code misconfigurations and secrets, and generates SBOMs in SPDX and CycloneDX. It is a single binary that runs on laptops, in CI and in clusters, which is why it is the default first scanner for most teams.

Its limit is prioritization: with no runtime context, it ranks findings by severity and fix status only. A critical CVE in a package your workload never loads looks exactly as urgent as one it does load.

Grype — best for SBOM-first pipelines

Grype is Anchore's open-source scanner for images and filesystems. It pairs with Syft, so teams generate an SBOM once and rescan it as new CVEs appear, without pulling images again. It is the right choice when your pipeline is built around SBOMs and attestations, and its vulnerability matching is accurate and well maintained.

Its limit is scope: image scanning only, with no misconfiguration or runtime coverage. Pair it with a separate tool for Dockerfile and manifest checks.

Clair — best for registry-side scanning

Clair is an open-source static analyser for container image layers, used as the scanner behind registries such as Quay. It runs as an API service: the registry pushes images to it, and it returns vulnerability reports. It is a strong fit if you run your own registry and want every pushed image scanned automatically.

Its limit is that it needs a client for pipeline use, and it offers no runtime context.

Commercial platforms — best for runtime context

Commercial platforms such as Wiz, Aqua Security, Sysdig Secure and Upwind add what open-source scanners cannot: runtime evidence of which packages are actually loaded, which workloads are reachable from the internet, and which findings sit on real attack paths. That context is the most effective way to shrink a CVE backlog to the findings worth fixing, because most images carry far more vulnerabilities than any team can fix.

They also add policy controls — severity and fix-based gates, waivers with expiry dates, and exceptions scoped to a package path — and integrations with ticketing and CI systems. They are quote-based and priced for teams, not individuals, so evaluate them when the free tools stop being enough.

If you want a second opinion on a suspicious file rather than a container image, a free on-demand scanner is the right tool instead — see our list of the best free malware scanners.

Trivy vs Grype: which should you use?

Trivy and Grype are the two open-source scanners most teams compare, and the choice comes down to what else you need. Both are free, both scan OS and language packages, and both are accurate. The differences are in scope and workflow.

CapabilityTrivyGrype
ScopeImages, filesystems, repos, clusters, IaC, secretsImages and filesystems, vulnerability matching
SBOMGenerates SPDX and CycloneDXReads SBOMs generated by Syft
MisconfigurationsYesNo
SecretsYesNo
Runtime contextCluster scanning via an operatorNo
Best forTeams wanting one free CLISBOM-first pipelines

If you want one tool that does the most, pick Trivy. If your pipeline already produces SBOMs with Syft and you want the cleanest vulnerability matching on top of them, pick Grype. Many teams run both during an evaluation and keep the one whose output their developers actually read.

What are the best practices for container vulnerability scanning?

The practices that work keep the image small, block builds on clear policy, and keep rescanning after release. Here is the checklist that matters most.

A CI gate policy developers will accept 1 FAIL on any CVE in CISA's Known Exploited list 2 FAIL on Critical or High CVEs with a fix available 3 WARN on high exploit probability with no fix yet 4 Waivers only with an owner, reason and expiry 5 Accept VEX statements marking a CVE not affected
Gate on exploitability and fix availability, not on severity alone. Illustration by Cysoro.
  • Shift scanning left. Run a scan on every pull request, not just before a production release, so a vulnerable base image never gets merged.
  • Inspect every layer. Scanners should check the full image, not only the top writable layer, since secrets and vulnerable packages are frequently baked into earlier build layers.
  • Choose minimal base images. Distroless or Alpine-based images carry fewer packages, shrinking what a scanner — and an attacker — has to work with.
  • Pin base images by digest. Use FROM image@sha256:… instead of mutable tags, so a rebuild cannot silently pull a different image.
  • Use multi-stage builds. Keep compilers and build tools out of the runtime stage of the image.
  • Run as non-root. Avoid privileged containers and drop unnecessary Linux capabilities so a compromised container cannot easily escalate.
  • Track an SBOM per image. A software bill of materials lets you instantly check whether a newly disclosed CVE affects anything already running.
  • Rescan continuously in the registry. An image that was clean at build time can become vulnerable the moment a new CVE is published.

Prioritization deserves special attention. Rank findings by exploitability as well as CVSS, using CISA's Known Exploited Vulnerabilities catalog, EPSS probability, fix availability and runtime reachability. The National Vulnerability Database publishes the CVE data and severity ratings your scanner matches against, and the CVSS standard defines the scores — 9.0 to 10.0 is Critical, 7.0 to 8.9 is High, 4.0 to 6.9 is Medium, and 0.1 to 3.9 is Low.

What can container scanning not catch?

Scanning has hard limits, and knowing them stops you from trusting it too far. It cannot find zero-day vulnerabilities, because there is no published CVE to match against. It cannot see runtime attacks such as a compromised container downloading a miner, abused credentials, or an attacker moving laterally through your cluster.

And it cannot judge whether your Kubernetes configuration is safe — open dashboards, over-permissive service accounts and exposed secrets in environment variables are outside its view.

That is why scanning is one control among several. Pair it with runtime detection, image signing and admission control, least-privilege service accounts, and network policies that limit what containers can reach. A scanner tells you what is wrong with the image. Runtime security tells you what is wrong right now.

How do I set up container scanning in CI/CD?

A minimal pipeline has four steps, and you can build it in an afternoon with free tools.

  1. Build the image from a pinned, minimal base image, using a multi-stage Dockerfile.
  2. Scan it in CI with Trivy or Grype, and generate a CycloneDX SBOM at the same time.
  3. Gate the build on the policy above: fail on KEV-listed CVEs and on fixable Critical or High findings, warn on the rest.
  4. Push and rescan. Push the image to the registry, store the SBOM with it, and schedule daily rescans of stored images against new advisories.

When a scan fails, the fix is usually one of three things: update the base image to a patched tag, update the vulnerable dependency, or replace the base image with a slimmer one. After rebuilding, rescan the new image before deploying it — never assume the rebuild fixed the problem.

Never put secrets in an imageScanners find credentials baked into layers, but by then the secret is already in your registry history. Pass secrets at runtime through your orchestrator's secret store, and rotate any credential that ever appeared in an image layer.

The bottom line

Container vulnerability scanning turns an invisible risk into a visible list: every package in every image, matched against known vulnerabilities, with a severity and a fix. Start with Trivy or Grype in CI, gate builds on fixable and exploited findings, and rescan your registry every day.

The goal is not a zero-CVE image — that is usually impossible. The goal is a short, defensible fix list, ordered by real risk, that your developers can actually work through. Pair scanning with runtime detection and minimal base images, and your containers stop being a blind spot. For the wider habits that keep a small team secure, work through our small business cybersecurity checklist.

Frequently asked questions

What is container vulnerability scanning?

Container vulnerability scanning is the automated inspection of container images, their dependencies and running workloads to detect known vulnerabilities, exposed secrets and misconfigurations. A scanner builds an inventory of every package in an image and matches it against CVE databases and vendor advisories.

What is the difference between Trivy and Grype?

Trivy, built by Aqua Security, is an all-in-one scanner that checks images, filesystems, Kubernetes clusters and infrastructure-as-code files for vulnerabilities, secrets and misconfigurations from a single binary. Grype, built by Anchore, focuses on vulnerability matching and pairs with Syft to generate a software bill of materials before scanning it.

When should I scan a container image?

At every stage: on developer laptops and pull requests, in CI before push, in the registry on a schedule, at admission control in Kubernetes, and at runtime. An image that was clean at build time can become vulnerable the moment a new CVE is published.

Can container scanning find zero-day vulnerabilities?

No. Scanners match packages against databases of known vulnerabilities, so they cannot detect a flaw nobody has published yet. They also cannot catch runtime attacks, abused credentials or insecure cluster configuration. You need runtime detection alongside scanning.

Should I fail a build on any vulnerability?

No. Failing builds on every finding, including unfixed and low-severity ones, teaches developers to bypass the gate. A better policy is to fail on CVEs in CISA's Known Exploited Vulnerabilities catalog, and on critical or high CVEs that have a fix available.

What is an SBOM and why does it matter for containers?

An SBOM, or software bill of materials, is a list of every package and dependency inside an image. It lets you check instantly whether a newly disclosed CVE affects anything already running, and rescan without pulling images again. Common formats are SPDX and CycloneDX.

Do I need a paid scanner, or is open source enough?

Open-source scanners such as Trivy and Grype cover build-time image checks well and are free. Commercial platforms add runtime context, policy governance and remediation workflows — most usefully, they show which vulnerable packages are actually loaded in production, so you can ignore the rest.

What is the most common container vulnerability?

The most common findings are outdated packages in the base image, such as an old OpenSSL in a Debian layer, and containers configured to run as root. Both are easy to fix: update the base image regularly, use minimal or distroless base images, and run as a non-root user.

Sources

  1. Upwind — Container Vulnerability Scanner: 10 Top Tools Compared
  2. Upwind — Container Image Scanning: How It Works and Best Practices
  3. NIST National Vulnerability Database — Home
  4. FIRST — Common Vulnerability Scoring System (CVSS)
  5. CrowdStrike — What is Vulnerability Management?
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against Upwind's container scanning guides, the NIST National Vulnerability Database, FIRST's CVSS standard and CrowdStrike's vulnerability management guide.

How we write and fact-check →

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free