Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] Adds a parser for CycloneDX Vex data #1181

Merged
merged 12 commits into from
Aug 31, 2023
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"bomFormat": "CycloneDX",
"specVersion": "1.4",
"version": 1,
"vulnerabilities": [
{
"id": "CVE-2020-25649",
"source": {
"name": "NVD",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2020-25649"
},
"references": [
{
"id": "SNYK-JAVA-COMFASTERXMLJACKSONCORE-1048302",
"source": {
"name": "SNYK",
"url": "https://security.snyk.io/vuln/SNYK-JAVA-COMFASTERXMLJACKSONCORE-1048302"
}
}
],
"ratings": [
{
"source": {
"name": "NVD",
"url": "https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N&version=3.1"
},
"score": 7.5,
"severity": "high",
"method": "CVSSv31",
"vector": "AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
},
{
"source": {
"name": "SNYK",
"url": "https://security.snyk.io/vuln/SNYK-JAVA-COMFASTERXMLJACKSONCORE-1048302"
},
"score": 8.2,
"severity": "high",
"method": "CVSSv31",
"vector": "AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N"
},
{
"source": {
"name": "Acme Inc",
"url": "https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N/CR:X/IR:X/AR:X/MAV:X/MAC:X/MPR:X/MUI:X/MS:X/MC:N/MI:N/MA:N&version=3.1"
},
"score": 0.0,
"severity": "none",
"method": "CVSSv31",
"vector": "AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N/CR:X/IR:X/AR:X/MAV:X/MAC:X/MPR:X/MUI:X/MS:X/MC:N/MI:N/MA:N"
}
],
"cwes": [
611
],
"description": "com.fasterxml.jackson.core:jackson-databind is a library which contains the general-purpose data-binding functionality and tree-model for Jackson Data Processor.\n\nAffected versions of this package are vulnerable to XML External Entity (XXE) Injection. A flaw was found in FasterXML Jackson Databind, where it does not have entity expansion secured properly in the DOMDeserializer class. The highest threat from this vulnerability is data integrity.",
"detail": "XXE Injection is a type of attack against an application that parses XML input. XML is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. By default, many XML processors allow specification of an external entity, a URI that is dereferenced and evaluated during XML processing. When an XML document is being parsed, the parser can make a request and include the content at the specified URI inside of the XML document.\n\nAttacks can include disclosing local files, which may contain sensitive data such as passwords or private user data, using file: schemes or relative paths in the system identifier.",
"recommendation": "Upgrade com.fasterxml.jackson.core:jackson-databind to version 2.6.7.4, 2.9.10.7, 2.10.5.1 or higher.",
"advisories": [
{
"title": "GitHub Commit",
"url": "https://github.com/FasterXML/jackson-databind/commit/612f971b78c60202e9cd75a299050c8f2d724a59"
},
{
"title": "GitHub Issue",
"url": "https://github.com/FasterXML/jackson-databind/issues/2589"
},
{
"title": "RedHat Bugzilla Bug",
"url": "https://bugzilla.redhat.com/show_bug.cgi?id=1887664"
}
],
"created": "2020-12-03T00:00:00.000Z",
"published": "2020-12-03T00:00:00.000Z",
"updated": "2021-10-26T00:00:00.000Z",
"credits": {
"individuals": [
{
"name": "Bartosz Baranowski"
}
]
},
"analysis": {
"state": "not_affected",
"justification": "code_not_reachable",
"response": ["will_not_fix", "update"],
"detail": "Automated dataflow analysis and manual code review indicates that the vulnerable code is not reachable, either directly or indirectly."
},
"affects": [
{
"ref": "urn:cdx:3e671687-395b-41f5-a30f-a58921a69b79/1#pkg:maven/com.fasterxml.jackson.core/[email protected]?type=jar"
}
]
}
]
}
54 changes: 54 additions & 0 deletions internal/testing/testdata/exampledata/cyclonedx-vex-affected.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"bomFormat": "CycloneDX",
"specVersion": "1.4",
"version": 1,
"metadata" : {
"timestamp" : "2022-03-03T00:00:00Z",
"component" : {
"name" : "ABC",
"type" : "application",
"bom-ref" : "product-ABC"
}
},
"vulnerabilities": [
{
"id": "CVE-2021-44228",
"source": {
"name": "NVD",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2021-44228"
},
"ratings": [
{
"source": {
"name": "NVD",
"url": "https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H&version=3.1"
},
"score": 10.0,
"severity": "critical",
"method": "CVSSv31",
"vector": "AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H"
}
],
"analysis": {
"state": "exploitable",
"response": ["will_not_fix", "update"],
"detail": "Versions of Product ABC are affected by the vulnerability. Customers are advised to upgrade to the latest release."
},
"affects": [
{
"ref": "urn:cdx:3e671687-395b-41f5-a30f-a58921a69b79/1#pkg:maven/com.fasterxml.jackson.core/jackson-databind@",
"versions": [
{
"version": "2.4",
"status": "affected"
},
{
"version": "2.6",
"status": "affected"
}
]
}
]
}
]
}
57 changes: 57 additions & 0 deletions internal/testing/testdata/exampledata/cyclonedx-vex.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<bom xmlns="http://cyclonedx.org/schema/bom/1.5" version="1">
<vulnerabilities>
<vulnerability>
<id>CVE-2018-7489</id>
<source>
<name>NVD</name>
<url>https://nvd.nist.gov/vuln/detail/CVE-2019-9997</url>
</source>
<ratings>
<rating>
<source>
<name>NVD</name>
<url>https://nvd.nist.gov/vuln-metrics/cvss/v3-calculator?vector=AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H&amp;version=3.0</url>
</source>
<score>9.8</score>
<severity>critical</severity>
<method>CVSSv3</method>
<vector>AN/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H</vector>
</rating>
</ratings>
<cwes>
<cwe>184</cwe>
<cwe>502</cwe>
</cwes>
<description>FasterXML jackson-databind before 2.7.9.3, 2.8.x before 2.8.11.1 and 2.9.x before 2.9.5 allows unauthenticated remote code execution because of an incomplete fix for the CVE-2017-7525 deserialization flaw. This is exploitable by sending maliciously crafted JSON input to the readValue method of the ObjectMapper, bypassing a blacklist that is ineffective if the c3p0 libraries are available in the classpath.</description>
<recommendation>Upgrade com.fasterxml.jackson.core:jackson-databind to version 2.6.7.5, 2.8.11.1, 2.9.5 or higher.</recommendation>
<advisories>
<advisory>
<title>GitHub Commit</title>
<url>https://github.com/FasterXML/jackson-databind/commit/6799f8f10cc78e9af6d443ed6982d00a13f2e7d2</url>
</advisory>
<advisory>
<title>GitHub Issue</title>
<url>https://github.com/FasterXML/jackson-databind/issues/1931</url>
</advisory>
</advisories>
<created>2021-01-01T00:00:00.000Z</created>
<published>2021-01-01T00:00:00.000Z</published>
<updated>2021-01-01T00:00:00.000Z</updated>
<analysis>
<state>not_affected</state>
<justification>code_not_reachable</justification>
<responses>
<response>will_not_fix</response>
<response>update</response>
</responses>
<detail>An optional explanation of why the application is not affected by the vulnerable component.</detail>
</analysis>
<affects>
<target>
<ref>urn:cdx:3e671687-395b-41f5-a30f-a58921a69b79/1#jackson-databind-2.8.0</ref>
</target>
</affects>
</vulnerability>
</vulnerabilities>
</bom>
114 changes: 112 additions & 2 deletions internal/testing/testdata/testdata.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ var (
//go:embed exampledata/cyclonedx-no-top-level.json
CycloneDXExampleNoTopLevelComp []byte

//go:embed exampledata/cyclonedx-unaffected-vex.json
CycloneDXVEXUnAffected []byte

//go:embed exampledata/cyclonedx-vex-affected.json
CycloneDXVEXAffected []byte

//go:embed exampledata/cyclonedx-vex.xml
CyloneDXVEXExampleXML []byte

//go:embed exampledata/crev-review.json
ITE6CREVExample []byte

Expand Down Expand Up @@ -128,6 +137,99 @@ var (
//go:embed exampledata/ingest_predicates.json
IngestPredicatesExample []byte

// CycloneDX VEX testdata unaffected
pkg, _ = asmhelpers.PurlToPkg("pkg:maven/com.fasterxml.jackson.core/[email protected]?type=jar")
vulnSpec = &generated.VulnerabilityInputSpec{
Type: "cve",
VulnerabilityID: "cve-2020-25649",
}
CycloneDXUnAffectedVexIngest = []assembler.VexIngest{
{
Pkg: pkg,
Vulnerability: vulnSpec,
VexData: &generated.VexStatementInputSpec{
Status: generated.VexStatusNotAffected,
VexJustification: generated.VexJustificationVulnerableCodeNotInExecutePath,
Statement: "Automated dataflow analysis and manual code review indicates that the vulnerable code is not reachable, either directly or indirectly.",
StatusNotes: "not_affected:code_not_reachable",
KnownSince: parseUTCTime("2020-12-03T00:00:00.000Z"),
},
},
}
CycloneDXUnAffectedVulnMetadata = []assembler.VulnMetadataIngest{
{
Vulnerability: vulnSpec,
VulnMetadata: &generated.VulnerabilityMetadataInputSpec{
ScoreType: generated.VulnerabilityScoreTypeCvssv31,
ScoreValue: 7.5,
Timestamp: parseUTCTime("2020-12-03T00:00:00.000Z"),
},
},
{
Vulnerability: vulnSpec,
VulnMetadata: &generated.VulnerabilityMetadataInputSpec{
ScoreType: generated.VulnerabilityScoreTypeCvssv31,
ScoreValue: 8.2,
Timestamp: parseUTCTime("2020-12-03T00:00:00.000Z"),
},
},
{
Vulnerability: vulnSpec,
VulnMetadata: &generated.VulnerabilityMetadataInputSpec{
ScoreType: generated.VulnerabilityScoreTypeCvssv31,
ScoreValue: 0.0,
Timestamp: parseUTCTime("2020-12-03T00:00:00.000Z"),
},
},
}

// CycloneDX VEX testdata in triage
pkg1, _ = asmhelpers.PurlToPkg("pkg:maven/com.fasterxml.jackson.core/[email protected]")
pkg2, _ = asmhelpers.PurlToPkg("pkg:maven/com.fasterxml.jackson.core/[email protected]")

vulnSpecAffected = &generated.VulnerabilityInputSpec{
Type: "cve",
VulnerabilityID: "cve-2021-44228",
}
vexDataAffected = &generated.VexStatementInputSpec{
Status: generated.VexStatusAffected,
Statement: "Versions of Product ABC are affected by the vulnerability. Customers are advised to upgrade to the latest release.",
StatusNotes: "exploitable:",
}
CycloneDXAffectedVexIngest = []assembler.VexIngest{
{
Pkg: pkg1,
Vulnerability: vulnSpecAffected,
VexData: vexDataAffected,
},
{
Pkg: pkg2,
Vulnerability: vulnSpecAffected,
VexData: vexDataAffected,
},
}
CycloneDXAffectedVulnMetadata = []assembler.VulnMetadataIngest{
{
Vulnerability: vulnSpecAffected,
VulnMetadata: &generated.VulnerabilityMetadataInputSpec{
ScoreType: generated.VulnerabilityScoreTypeCvssv31,
ScoreValue: 10,
},
},
}
CycloneDXAffectedCertifyVuln = []assembler.CertifyVulnIngest{
{
Pkg: pkg1,
Vulnerability: vulnSpecAffected,
VulnData: &generated.ScanMetadataInput{},
},
{
Pkg: pkg2,
Vulnerability: vulnSpecAffected,
VulnData: &generated.ScanMetadataInput{},
},
}

// DSSE/SLSA Testdata

// Taken from: https://slsa.dev/provenance/v0.2#example
Expand Down Expand Up @@ -1925,8 +2027,8 @@ var (
},
Vulnerability: &model.VulnerabilityInputSpec{Type: "cve", VulnerabilityID: "cve-2023-0286"},
VexData: &model.VexStatementInputSpec{
Status: "AFFECTED",
VexJustification: "NOT_PROVIDED",
Status: generated.VexStatusAffected,
VexJustification: generated.VexJustificationNotProvided,
Statement: `For details on how to apply this update, which includes the changes described in this advisory, refer to:

https://access.redhat.com/articles/11258
Expand Down Expand Up @@ -2500,3 +2602,11 @@ func toTime(s string) time.Time {
}
return timeScanned
}

func parseUTCTime(s string) time.Time {
timeScanned, err := time.Parse("2006-01-02T15:04:05Z", s)
if err != nil {
panic(err)
}
return timeScanned
}
12 changes: 8 additions & 4 deletions pkg/assembler/clients/generated/operations.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions pkg/assembler/graphql/generated/root_.generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading