Container Security

Trivy vs Grype: Container Scanning Head-to-Head

Compare Trivy and Grype on vulnerability database sources, scan speed, OS coverage, SBOM integration, and CI ergonomics to pick the right open source container scanner.

Shadab Khan
Security Engineer
5 min read

Trivy (Aqua Security) and Grype (Anchore) are the two most widely deployed open source container vulnerability scanners in 2023. Both are free, both run as a single Go binary, and both scan Linux base images against OS and language package advisories. Picking between them is rarely about raw capability - it is about scan speed under load, how well each handles your specific base images, and how cleanly each slots into your existing SBOM pipeline. This post targets platform and DevSecOps engineers standardizing a container scanning layer for a Kubernetes CI pipeline. We compare feed sources, scan performance, false positive behavior, SBOM integration, and CI ergonomics using Trivy 0.46 and Grype 0.70 on Alpine 3.18, Debian 12, and UBI 9 test images.

Where do their vulnerability feeds come from?

Trivy aggregates more sources out of the box, Grype relies on a single Anchore feed. Trivy (0.46) consumes Red Hat OVAL, Debian Security Tracker, Alpine secdb, Amazon Linux ALAS, Oracle ELSA, Wolfi secdb, GitHub Security Advisories, Go vulnerability DB, and Ruby Advisory DB, among others. Grype (0.70) pulls from a single consolidated feed maintained by Anchore that normalizes NVD, GHSA, Alpine secdb, Debian, RHSA, Amazon ALAS, Wolfi, and OSV into vulnerabilities.db. The practical difference: Trivy sometimes reports an advisory a day or two earlier because it reads distro feeds directly; Grype gives more consistent severity scoring because Anchore does its own normalization. Neither is canonically "more accurate" across all distros.

How do they compare on scan speed?

Grype is usually faster on first run; Trivy is faster after cache warm-up. In a sandbox run against a 1.2 GB UBI 9 application image on a 4-vCPU runner, Grype completed the initial scan in about 18 seconds versus Trivy's 26 seconds including DB download. On a warm cache, Trivy dropped to roughly 6 seconds against Grype's 8 seconds because Trivy's BoltDB lookups outperform Grype's SQLite reads at scale. For very large images (>4 GB) or deeply layered images, Trivy's --skip-files and --skip-dirs options give finer control than Grype's equivalents. Memory footprint at peak is similar - both stay under 500 MB for typical application images.

Which one handles language ecosystems better?

Trivy covers more languages natively; Grype defers to Syft. Trivy 0.46 detects Python (requirements.txt, Pipfile.lock, poetry.lock), Node.js (package-lock.json, yarn.lock), Java (pom.xml, gradle.lockfile, JAR inspection), Go binaries (module info), Ruby (Gemfile.lock), Rust (Cargo.lock), .NET, PHP, and more. Grype relies on Syft to produce the SBOM and then matches it against its DB, which means Syft's ecosystem coverage is effectively Grype's ceiling. In practice Syft + Grype is strong on Go and Java binaries and weaker on Poetry lockfiles with complex extras, while Trivy has known blind spots on older Gradle Groovy lockfiles. Both tools miss vendored-and-renamed C libraries unless fingerprints happen to match.

How do they integrate with SBOMs?

Grype is SBOM-native; Trivy treats SBOM as one of several inputs. Grype's design assumes a Syft-generated CycloneDX or SPDX as input (grype sbom:./sbom.json) and is therefore the better pick if you already generate SBOMs upstream and want to scan them without re-reading the image. Trivy can also scan SBOMs (trivy sbom ./sbom.json) and additionally produce them (trivy image --format cyclonedx) without a separate tool. For air-gapped environments where you generate SBOMs once at build time and scan them repeatedly, Grype has a cleaner story; for shops that want a single binary to both generate and scan, Trivy is simpler.

How do they slot into CI?

Both are single-binary and CI-friendly, but exit codes and output differ. Trivy exposes --exit-code, --severity, --ignore-unfixed, and native SARIF, JSON, CycloneDX, and GitHub Actions table output. Grype exposes --fail-on, --only-fixed, and SARIF, JSON, CycloneDX, and table output. GitHub Actions support is official for both (aquasecurity/trivy-action and anchore/scan-action). The common complaint about Grype in CI is noisier SARIF (duplicate findings across layers) that requires downstream dedup; Trivy's SARIF is usually cleaner but its table output wraps awkwardly in narrow terminals.

Who wins for what workload?

  1. Single-binary, all-in-one scanning (image, FS, IaC, SBOM) - Trivy.
  2. SBOM-first pipelines where Syft is already in place - Grype.
  3. Wolfi, Chainguard, or distroless-heavy estates - either, both have good Wolfi feeds.
  4. Very large (>4 GB) images with skip rules - Trivy.
  5. Consistent severity across distros for SLA reporting - Grype, due to Anchore normalization.
  6. Gitleaks/secrets detection alongside vulns - Trivy, which bundles secret scanning.

How Safeguard Helps

Safeguard does not replace Trivy or Grype - it consumes their output. Teams standardize on one scanner in CI, export SARIF and CycloneDX, and send the artifacts to Safeguard, which deduplicates findings, applies reachability analysis against the runtime image, and enforces policy gates on base image age and fixable criticals before release. Griffin AI translates Trivy or Grype findings into prioritized remediation steps and correlates them with SBOM provenance so engineers see a single queue rather than two scanner UIs. This preserves the open source, zero-license cost of Trivy and Grype while adding the governance layer enterprises need.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.