BomLink accepts non-positive BOM versions and non-canonical shorthand UUIDs

Open Beginner friendly
#1,002 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java
Domain
data

Research direction

Start in src/main/java/org/cyclonedx/util/BomLink.java, where the BomLink(String) constructor parses the serial number and version, and where isBomLink checks the urn:cdx prefix. Run the repro from the issue against master to confirm the three true results. The schema pattern in src/main/resources/bom-1.7.schema.json shows the rules to match. Done means the constructor throws BomLinkException and isBomLink returns false for version 0, negative versions and non-36-character UUIDs, and existing tests still pass.

Written by the indexing model from the issue text.

Description

BomLink and BomLink.isBomLink accept urn:cdx: URNs with zero or negative BOM versions (/0, /-5) and non-36-character shorthand UUIDs (1-1-1-1-1), disagreeing with the urn:cdx specification and CycloneDX's bomLinkDocumentType / bomLinkElementType schema definitions. Because fields such as vulnerabilities[].affects[].ref and externalReferences[].url union bomLink with refLinkType or iri-reference/xs:anyURI, schema validation lets malformed urn:cdx: strings through and callers rely on BomLink.isBomLink to distinguish valid BOM-Links.

cat > Repro.java <<'EOF'
import org.cyclonedx.util.BomLink;

public class Repro {
    public static void main(String[] args) {
        boolean v0 = BomLink.isBomLink("urn:cdx:3e671687-395b-41f5-a30f-a58921a69b79/0");
        boolean vNeg = BomLink.isBomLink("urn:cdx:3e671687-395b-41f5-a30f-a58921a69b79/-5");
        boolean shortUuid = BomLink.isBomLink("urn:cdx:1-1-1-1-1/1");
        System.out.println("v0=" + v0 + " vNeg=" + vNeg + " shortUuid=" + shortUuid);
    }
}
EOF
curl -fsSLO https://repo1.maven.org/maven2/org/cyclonedx/cyclonedx-core-java/13.5.0/cyclonedx-core-java-13.5.0.jar
javac -cp cyclonedx-core-java-13.5.0.jar Repro.java
java -cp .:cyclonedx-core-java-13.5.0.jar Repro

Actual output:

v0=true vNeg=true shortUuid=true

Expected v0=false vNeg=false shortUuid=false (and BomLinkException from new BomLink(...)), matching the IANA urn:cdx registration referenced in BomLink's Javadoc (bom-version >= 1 and 36-character RFC 9562 UUID) and bomLinkDocumentType / bomLinkElementType (^urn:cdx:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/[1-9][0-9]*) in src/main/resources/bom-1.7.schema.json.

Verified on master (e591b11c6aaba7fa9cc859a9e9badfe3e1dd4cad, 13.6.0-SNAPSHOT) on Linux x86_64; BomLink.java is unchanged in release 13.5.0.

In src/main/java/org/cyclonedx/util/BomLink.java, BomLink(String) parses the serial number and version via UUID.fromString(...) and Integer.parseInt(parts[1]) without checking canonical 36-character UUID syntax or version >= 1.

Credit: https://ucsbplse.github.io/

Dominant language
Java
Stars
124
Forks
97
Avg merge
2d 14h
Merged PRs (30d)
11

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from CycloneDX/cyclonedx-core-java

All issues in CycloneDX/cyclonedx-core-java

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.