Syft builds a software bill of materials from a container image or directory, and Grype matches that inventory against vulnerability data, so together they give a CI pipeline a repeatable record of what shipped and which known flaws it carries. This guide explains how the two open-source tools work, how to wire them into a build without leaking registry credentials, how to keep scan gates honest, and how to read the results with EPSS and KEV context rather than raw severity alone.
Both projects are command line tools and Go libraries sponsored by Anchore and released under the Apache 2.0 licence. They are often used together, but each stands on its own: Syft produces SBOMs in CycloneDX, SPDX and its own JSON format, and Grype scans images, filesystems or an existing SBOM. For the wider picture of SBOM formats, read our SBOM Guide; for running an SBOM and VEX programme at scale, see SBOM operations. If your team already runs a different scanner, our Trivy Guide covers that tool on its own terms.
This is an independent guide from NHI Mgmt Group, based on Anchore's public documentation as of November 2026. It is not sponsored or reviewed by Anchore. Product features change, so confirm settings against Anchore's current documentation.
Key takeaways
- Generate the SBOM once with Syft, store it as a build artefact, and scan that SBOM with Grype. Rescanning the stored SBOM later finds new vulnerabilities without rebuilding or pulling the image again.
- Choose the cataloguing scope deliberately. Syft defaults to
squashed, which reflects the final filesystem;all-layersalso records packages deleted in later layers, which matters for image provenance and forensics. - Pin tool versions and verify installers. The quick install pipes a script from the internet into a shell with sudo, which is convenient on a laptop and a supply chain risk in CI.
- Treat the vulnerability database as a dependency. Grype refuses a database older than its allowed age by default, and you can make it fail when the update check itself fails.
- Gate on
fail-on-severity, but prioritise with the RISK, EPSS and KEV columns. A severity-only gate blocks builds without telling anyone what to fix first. - Every ignore rule is a risk acceptance. Keep rules in version control, scope them to a package and reason, and prefer VEX documents for statements that consumers also need to see.
- Registry credentials used by the scanners are non-human identities. Give them read-only, short-lived access and keep them out of config files committed to the repository.
What Syft and Grype do
Syft is described by its maintainers as a tool for generating an SBOM from container images and filesystems. It reads package metadata for dozens of ecosystems, including Alpine apk, Debian dpkg, RPM, Go, Python, Java, JavaScript, Ruby, Rust, PHP and .NET, and supports OCI, Docker and Singularity image formats. Its outputs include CycloneDX, SPDX and Syft JSON, and it can convert between formats and create signed SBOM attestations using the in-toto specification.
Grype is a vulnerability scanner for container images, filesystems and SBOMs. It covers the major operating system package ecosystems (Alpine, Debian, Ubuntu, RHEL, Oracle Linux and Amazon Linux among others) and language packages. It adds threat and risk prioritisation using EPSS, KEV and a risk score, and it supports OpenVEX documents for filtering and augmenting results.
The split matters operationally. Syft answers "what is in this artefact?" and Grype answers "which of those components have known vulnerabilities today?" The first answer is fixed at build time. The second changes every time the vulnerability database updates. Separating them lets you keep an immutable inventory and re-run the cheaper matching step as often as you like.
Generating SBOMs with Syft
The basic call takes an image reference or a directory. With no output flag, Syft prints a table of packages. To produce an SBOM, name one or more formats, and optionally a file for each:
syft <image> -o cyclonedx-jsonwrites CycloneDX JSON to standard output.syft <image> -o spdx-json=./spdx.json -o cyclonedx-json=./cdx.jsonwrites both formats in one pass.
The CLI reference for version 1.54.0 lists these output formats: cyclonedx-json, cyclonedx-xml, github-json, purls, spdx-json, spdx-tag-value, syft-json, syft-table, syft-text and template. Syft JSON carries the most detail and is a good archival format; CycloneDX or SPDX are what customers and regulators usually ask for. Producing both from one scan avoids two inventories that disagree.
Flags worth setting in CI
--scopeselects layers to catalogue. The options aresquashed(the default),all-layersanddeep-squashed. Squashed reflects what runs; all-layers shows what a layer history still contains, including secrets tools or packages that a later layer removed but that remain extractable from the image.--source-nameand--source-versionset the name and version of the target. Set them from your build metadata so SBOMs are traceable to a release rather than to a temporary directory name.--excludeskips paths by glob. Use it for test fixtures and vendored examples, and record why each exclusion exists, because an exclusion also hides real packages.--base-pathsets the base directory for directory scans; the reference notes that links above this directory are not followed. That is a useful guard when scanning a checkout that might contain symlinks pointing elsewhere on the runner.--select-catalogersadds, removes or filters catalogers.syft cataloger listshows what is available and how it is configured.--fromsets source behaviour, such asdocker,registryoroci-dir. Being explicit stops Syft silently reading a stale local image when you meant the registry copy, or the reverse.
Locally built images
On Linux, Syft and Grype can read images from a local containers-storage store, such as one built with Buildah or Podman, but only when asked with --from containers-storage. Plain image references never look there. Rootless stores have to be read from inside the builder's user namespace, for example with podman unshare. This is convenient for scanning before push, which keeps vulnerable images out of the registry entirely.
Scanning with Grype
Grype accepts the same kinds of targets as Syft, plus SBOMs. grype alpine:latest scans an image, grype ./my-project scans a directory, and grype sbom:./sbom.json scans an SBOM that Syft produced. You can also pipe an SBOM into Grype on standard input.
Scanning the SBOM is the pattern to standardise on. It is faster, it guarantees that the vulnerability report refers to exactly the inventory you archived, and it lets you rescan old releases on a schedule without registry access. A nightly job that rescans the SBOMs of every supported release is one of the cheapest ways to learn that a newly disclosed vulnerability affects software already in production.
Configuration files
Grype reads the first configuration file it finds from ./.grype.yaml, ./.grype/config.yaml, ~/.grype.yaml and $XDG_CONFIG_HOME/grype/config.yaml, with either .yaml or .yml extensions. Only the first file found is used, so a stray file in a home directory on a self-hosted runner can override what you expected. Each setting also has a GRYPE_ environment variable, such as GRYPE_ONLY_FIXED. Commit a project config file and pass it explicitly so that the result does not depend on the runner.
Output formats
The output setting accepts table, template, json and cyclonedx. A template output needs output-template-file as well. Use JSON for machine processing and archiving, and table for logs that humans read. If you publish results to a code scanning dashboard, generate the format through a template you control and keep it with the pipeline code.
Building scan gates that hold up
fail-on-severity sets the exit code to 1 when a match meets or exceeds the given level: negligible, low, medium, high or critical. It is unset by default, which means a Grype run in CI reports problems but never fails the build. Decide the threshold on purpose and write it in the project config.
Two filters change what counts toward the gate:
only-fixedignores matches for vulnerabilities that have no fix. This keeps the gate actionable, because developers can only act on findings with an upgrade path.only-notfixeddoes the opposite and ignores matches that are fixed. It is useful for a separate report of unfixable exposure that needs compensating controls rather than upgrades.
A practical arrangement, and an NHI Mgmt Group suggestion rather than an Anchore default, is two Grype invocations against the same SBOM: a blocking run with only-fixed and fail-on-severity: high, and a non-blocking run that exports everything to JSON for the vulnerability management team. The blocking run tells developers what to fix now. The full export feeds risk tracking for issues with no fix.
Results by default use the original vulnerability ID from the data source. by-cve reports results by CVE where possible, which helps when your ticketing and risk register key on CVE identifiers.
Ignore rules
Grype ignore rules apply only when every listed criterion matches. A rule can match on vulnerability, namespace, fix-state, match-type, reason and include-aliases, on package fields (name, version, language, type, location, upstream-name), and on VEX fields (vex-status, vex-justification). Because criteria are combined, a rule naming only a vulnerability ID suppresses that finding everywhere, while a rule that also names the package and location suppresses it in one place.
Write the narrow version. Record the reason in the rule, review rules on a fixed schedule, and treat any rule without a package scope as a finding in code review. When a statement such as "this component is not affected because the vulnerable function is never called" is true, it belongs in a VEX document so that downstream consumers see it too. Grype's vex-documents setting takes a list of VEX documents to use when producing results. Our VEX Guide explains how to write those statements so customers can rely on them.
Reading results: RISK, EPSS and KEV
Grype's table output has eight standard columns: NAME, INSTALLED, FIXED-IN, TYPE, VULNERABILITY, SEVERITY, EPSS and RISK. An optional annotations column appears when relevant, showing KEV status, suppression status when --show-suppressed is used, or distribution versions for multi-distro scans.
- EPSS is shown as a raw score and a percentile, for example
94.4% (99th). The Grype documentation describes EPSS as a model that estimates the probability a vulnerability will be exploited in the next 30 days. FIRST maintains the model. - KEV appears as an annotation when the vulnerability is in the CISA Known Exploited Vulnerabilities catalog. Grype treats a KEV entry as maximum threat in its risk calculation, overriding EPSS.
- RISK is a score from 0.0 to 100.0 that combines threat (EPSS or KEV), impact (CVSS and severity ratings) and context (known ransomware campaigns). Results are sorted by this score by default.
- FIXED-IN shows a version when a fix exists, "(won't fix)" when the vendor will not fix it, and an empty cell when no fix is available.
Use these columns to order work, not to replace your own policy. A KEV entry in an internet-facing image is an emergency regardless of its CVSS score. A critical CVSS score in a build-time tool that never ships may be a low priority. The scanner cannot know which images face the internet or which hold privileged credentials; your asset inventory can, so join the two.
The vulnerability database as a dependency
Grype matches against a database it downloads and caches. The defaults are worth knowing because they decide whether a scan is trustworthy:
auto-updatechecks for database updates on each run and defaults to true.max-allowed-built-agedefaults to 120 hours, measured from when the database was built, andvalidate-age, which defaults to true, enforces it.require-update-checkfails the scan if the update check cannot be completed. It defaults to false, so by default a network failure leaves Grype using the cached database, provided it is within the allowed age.cache-dirdefaults to~/.cache/grype/db, andupdate-urldefaults tohttps://grype.anchore.io/databases.
For release gates, set require-update-check to true so that a gate never passes on stale data. For air-gapped or rate-limited environments, mirror the database internally, point update-url at the mirror, and keep validate-age on so that a broken mirror shows up as failed scans rather than quietly ageing results. Protect the mirror and the cache directory like any other build input: whoever can write to them can make vulnerabilities disappear from every report.
Running Syft and Grype safely in CI
Installation and pinning
Both READMEs offer a quick install that pipes a script into sh with sudo. In a pipeline, prefer a pinned release binary with checksum verification, a pinned container image referenced by digest, or a package from a repository you mirror. Pin third-party CI steps that wrap these tools to a full commit SHA; our guide on How to Pin GitHub Actions to Commit SHAs covers why. Security scanners run with access to source, images and often secrets, which makes them attractive targets in their own right. Plan for the scanner itself being compromised: run it with the least access it needs and keep its version changes reviewed like any code change.
Registry credentials are non-human identities
To pull private images, Syft and Grype use registry auth entries with authority, username, password, token, tls-cert and tls-key fields, and a token is mutually exclusive with a username and password. In Grype's configuration these entries are annotated with SYFT_REGISTRY_AUTH_* environment variables. syft login can also log in to a registry. Apply the usual non-human identity controls:
- Use a dedicated, read-only pull identity for scanning, never a developer's personal token or a push-capable account.
- Prefer short-lived tokens issued through workload identity federation from the CI platform over static passwords.
- Inject credentials through the CI secret store as environment variables; never commit them in
.grype.yaml. - Make sure login state written by
syft logindoes not persist on shared self-hosted runners between jobs. - Use
ca-certto trust a private registry CA rather than disabling TLS verification.
SBOM attestations
syft attest generates an SBOM as the predicate of an in-toto attestation for a container image and uploads it to the registry, with --key naming the signing key. Signed attestations let a deployment admission check confirm that an SBOM was produced by your pipeline for that exact image digest. The signing key is a high-value credential: keep it in a key management service or use keyless signing tied to the pipeline identity, and restrict which workflows can reach it. Our Provenance Attestation vs SBOM guide explains what an attested SBOM proves and what it does not.
A reference pipeline
- Build the image and record its digest.
- Run Syft against the digest with explicit
--from,--scope,--source-nameand--source-version, writing Syft JSON and CycloneDX or SPDX. - Store the SBOMs as build artefacts, and attach a signed attestation to the image.
- Run Grype against the stored SBOM with a committed config,
require-update-checkon, and a blockingfail-on-severitythreshold withonly-fixed. - Run a second, non-blocking Grype pass that exports full JSON to vulnerability management.
- Schedule nightly rescans of SBOMs for every supported release and raise tickets for new KEV or high-RISK matches.
Where SBOMs and scans fit in governance
SBOM generation and vulnerability scanning support several published frameworks. The NIST Secure Software Development Framework (SP 800-218) asks producers to protect software, verify third-party components and respond to vulnerabilities, and an archived SBOM per release is direct evidence for those practices. CISA's SBOM work sets out the minimum elements and sharing practices that customers increasingly ask for. NIST SP 800-161 places component transparency inside cyber supply chain risk management, and SLSA levels describe how much you can trust the build that produced an artefact. On the threat side, MITRE ATT&CK technique T1195.002, Compromise Software Supply Chain, describes the attacks that a current inventory helps you scope when an upstream component is found to be malicious.
The practical benefit during an incident is speed. When a widely used library is reported as compromised or critically vulnerable, the question "where do we run it?" is answered by querying archived SBOMs, not by rescanning every image under pressure.
Common failure patterns
- Scanning without a gate.
fail-on-severityis unset by default, so pipelines print findings that nobody reads and nothing ever blocks. - Blanket ignore rules. A rule that names only a vulnerability ID, added to unblock one build, silences the finding across every image for years.
- Stale data passing gates. With
require-update-checkoff, a scan can run on the cached database after an update fails, as long as the cache is within the allowed age. - Inventory from the wrong image. Scanning a tag rather than a digest, or a local image rather than the registry copy, produces an SBOM that does not match what was deployed.
- Squashed scope hiding history. Packages and files deleted in a later layer still exist in the image; squashed scope will not show them.
- Over-privileged scanner credentials. Push-capable registry tokens or long-lived personal tokens stored in scanner config.
- Unpinned tooling. Piping an install script into a root shell on every build, or pulling a scanner action by a moving tag.
- SBOMs generated and forgotten. SBOMs that are produced but never stored, rescanned or attested provide no value when a new vulnerability lands.
Practitioner checklist
- Syft runs against the image digest with explicit
--from,--scope,--source-nameand--source-version. - Each release has stored Syft JSON plus CycloneDX or SPDX SBOMs, and a signed attestation on the image.
- Grype scans the stored SBOM using a committed configuration file passed explicitly.
fail-on-severityis set, and the blocking pass usesonly-fixed; a second pass exports all findings.require-update-checkandvalidate-ageare on for release gates; any database mirror is access controlled.- Ignore rules are narrow, carry a reason, and are reviewed on a schedule; reusable statements go into VEX documents.
- Triage uses KEV, EPSS and RISK together with your own asset exposure data.
- Registry access uses a dedicated read-only, short-lived identity injected from the CI secret store.
- Tool binaries, images and wrapping CI steps are pinned and verified; updates go through review.
- Nightly rescans cover every supported release, and new KEV matches open tickets automatically.
Standards and references
- Anchore: Syft repository and README
- Anchore: Grype repository and README
- Anchore: Grype configuration reference
- Anchore: Interpreting Grype results
- Anchore: Syft CLI reference
- NIST: SP 800-218 Secure Software Development Framework (SSDF) Version 1.1
- CISA: Software Bill of Materials (SBOM)
- CISA: Known Exploited Vulnerabilities Catalog
Related NHI Mgmt Group resources: SBOM Guide · SBOM operations · VEX Guide · Trivy Guide