cyclonedx-maven-plugin icon indicating copy to clipboard operation
cyclonedx-maven-plugin copied to clipboard

SerialNumber of SBOMs are not unique

Open MeikelVielhauer opened this issue 7 months ago • 4 comments

The CycloneDX Maven Plugin is currently generating deterministic serialNumber for SBOMs, which conflicts with the CycloneDX specification's recommendation for unique serialNumber. According to the CycloneDX specification, every SBOM generated should have a unique serial number, even if its contents have not changed over time.

We had an issue because several SBOMs generated with the Plugin did not change its serialNumber since the SBOM itself did not change at all. Now, looking at the coding of the Plugin I see that the generateSerialNumber function generates reproducable serialNumber.

https://github.com/CycloneDX/cyclonedx-maven-plugin/blob/ad5624e0c739550cb0db38939b79a222b70ea445/src/main/java/org/cyclonedx/maven/BaseCycloneDxMojo.java#L425-L438

Could you please generate the serialNumber to not be deterministic to conform with the CycloneDX specification?

MeikelVielhauer avatar May 06 '25 12:05 MeikelVielhauer

@MeikelVielhauer,

Could you explain more your use case? Why do you need several SBOMs for exactly the same Maven artifact?

According to the CycloneDX specification, every SBOM generated should have a unique serial number, even if its contents have not changed over time.

The specification also has a version property, which is defined as:

Whenever an existing BOM is modified, either manually or through automated processes, the version of the BOM SHOULD be incremented by 1. When a system is presented with multiple BOMs with identical serial numbers, the system SHOULD use the most recent version of the BOM. The default version is '1'.

The reason behind the deterministic algorithm to compute a serial number is reproducibility: this allows users to verify that the published SBOM is identical to one generated from source.

ppkarwasz avatar May 06 '25 15:05 ppkarwasz

Hi, the SBOMs are created in our CI/CD pipeline. With every build also a SBOM is generated using this plugin and the pipeline doesn't have any information about previously created SBOMs.

Since we have some projects which don't increase their version with every pipeline run your implementation of generating the serial number leads to the same SBOM serial number and the same version.

Regarding your reproducibility use case: Why not use the purl of the built component from the metadata part of the SBOM? This would be for me the indicator whether it is an SBOM describing exactly the same artifact.

chrsch-dev avatar May 07 '25 07:05 chrsch-dev

Not sure when random uuids were removed, but the above code violates the spec for most people. That code would likely produce the same serial number for every SNAPSHOT build. Please keep in mind that the authors of the NTIA framing document were not favorable towards reproducibility as the practice typically sacrifices critical data at the expense of reproducibility. To some, it’s an anti-pattern.

If a CI doesn’t have a record of prior builds of the same version (and most won’t), then the serialNumber should be unique between builds. Perhaps this is an enhancement to the docs in the spec.

I would recommend making this a configurable option. For the folks that want predictability, they can misuse the spec by enabling this functionality.

stevespringett avatar May 08 '25 02:05 stevespringett

Not sure when random uuids were removed

This behavior was introduced to solve #420, since the previous behavior was to skip serialNumber entirely (see #226).

I would recommend making this a configurable option. For the folks that want predictability, they can misuse the spec by enabling this functionality.

Should the option support all three behaviors (i.e. deterministic, random or no serialNumber)?

Personally I am not strongly opinionated regarding the reproducibility of SBOMs, but reproducibility allows to perform some basic quality checks on the released SBOMs. I have seen multiple SBOMs with invalid checksums, because the release manager didn't clean his diaper (i.e., ~/.m2/repository) before the release. Recently I introduced an independent <checksum> check to my SBOM Enforcer plugin, so reproducibility might no longer be necessary.

ppkarwasz avatar May 08 '25 11:05 ppkarwasz