-
Notifications
You must be signed in to change notification settings - Fork 734
Description
What happened:
Syft generates a CycloneDX-JSON SBOM with two "components" and two "dependencies" sections and each one appears to contain the same list of components and dependencies. This is causing Grype (and also how the issue was discovered) to throw an error that the JSON is invalid.
This occurs when explicitly specifying the scan scheme to be "registry:..." (and maybe others), but does not occur when scanning "dir:..." for example. It occurs when using a ".syft.yaml" config file with the "output" key set to "cyclonedx-json". If I also specify "-o cyclonedx-json" on the command line, the problem disappears.
What you expected to happen:
Syft should generate a CycloneDX JSON that contains one top-level "components" section and one top-level "dependencies" section.
Steps to reproduce the issue:
Preconditions. You'll need to have a registry setup with a suitable image to test on. I'm testing with the standard Debian image: docker.io/library/debian stable 678d881964f7 4 weeks ago 124 MB in my Ubuntu environment.
- Create the syft config file:
syft config > ~/.syft.yaml - Modify the syft config file to change the "output:" key to be "cyclonedx-json". diff patch of this change:
--- .syft.yaml.orig 2025-10-30 15:20:36.842628077 +0100
+++ .syft.yaml 2025-10-30 15:29:23.476844318 +0100
@@ -24,7 +24,7 @@
# - "syft-json=<syft-json-output-file>"
# - "spdx-json=<spdx-json-output-file>" (env: SYFT_OUTPUT)
output:
- - 'syft-table'
+ - 'cyclonedx-json'
# file to write the default report output to (default is STDOUT) (env: SYFT_LEGACYFILE)
legacyFile: ''
-
Execute syft as follows:
syft scan registry:docker.io/library/debian:stable | jq . > debian-sbom.json
Thejqis there to make it readable, but isn't a required part of the execution. -
Examine the resulting SBOM file. If the error has occurred you will find the file has duplicate "components" and "dependencies" objects. Also, if you attempt to feed this file into grype, you'll get the following error:
[0000] ERROR failed to catalog: unable to decode sbom: unable to decode cyclonedx json document: invalid character '{' after top-level value
Anything else we need to know?:
The issue does not occur if I add the -o "cyclonedx-json" option to the syft command line. Also, the issue does not occur for some scan schemes, such as "file" and "dir", but I haven't tried to determine the complete set of schemes affected.
Environment:
- Output of
syft version:
Application: syft
Version: 1.34.2
BuildDate: 2025-10-16T12:19:31Z
GitCommit: 0c98a364d503789ff8d7f122763bb8748de9772f
GitDescription: v1.34.2
Platform: linux/amd64
GoVersion: go1.24.7
Compiler: gc
SchemaVersion: 16.0.40
- OS (e.g:
cat /etc/os-releaseor similar):
PRETTY_NAME="Ubuntu 24.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.3 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo
Running in WSL2 on Windows11
Metadata
Metadata
Assignees
Labels
Type
Projects
Status