Skip to content

Commit b0d9884

Browse files
authored
ROX-28353: use NVD 2.0 JSON feeds (#2015) (#2027)
1 parent e8694aa commit b0d9884

File tree

11 files changed

+868
-405
lines changed

11 files changed

+868
-405
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ jobs:
162162
contains(github.event.pull_request.labels.*.name, 'generate-dumps-on-pr')
163163
env:
164164
NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
165-
ROX_LEGACY_NVD_LOADER: true
165+
ROX_NVD_FEED_LOADER: true
166166
runs-on: ubuntu-latest
167167
needs:
168168
- pre-build-updater

cmd/clair/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ func Boot(config *Config, slimMode bool) {
114114
go func() {
115115
defer wg.Add(-1)
116116
var err error
117-
db, err = database.OpenWithRetries(config.Database, true, 30, 10*time.Second)
117+
// Wait for the DB to be ready: 10 minutes.
118+
db, err = database.OpenWithRetries(config.Database, true, 60, 10*time.Second)
118119
if err != nil {
119120
log.WithError(err).Fatal("Failed to open database despite multiple retries...")
120121
}

e2etests/testcase_test.go

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3595,7 +3595,7 @@ For more details about the security issue(s), including the impact, a CVSS score
35953595
},
35963596
{
35973597
AddedBy: "sha256:2412e60e610160d090f7e974a208c6ffd26b2d530361b7c9aa8967e160ac7996",
3598-
FixedBy: "2:8.2.2637-21.el9",
3598+
FixedBy: "2:8.2.2637-22.el9_6",
35993599
Name: "vim-minimal",
36003600
NamespaceName: "rhel:9",
36013601
Version: "2:8.2.2637-16.el9_0.2.x86_64",
@@ -3838,8 +3838,8 @@ Applications using RegexRequestMatcher with '.' in the regular expression are po
38383838
FixedBy: "3.0.2-0ubuntu1.7",
38393839
},
38403840
},
3841-
FixedBy: "3.0.2-0ubuntu1.16",
3842-
// This image installs the openssl pacakge in the second layer;
3841+
FixedBy: "3.0.2-0ubuntu1.18",
3842+
// This image installs the openssl package in the second layer;
38433843
// however, the first layer already installed libssl3 whose source package is openssl.
38443844
// Therefore, we claim openssl was installed in the first layer.
38453845
AddedBy: "sha256:301a8b74f71f85f3a31e9c7e7fedd5b001ead5bcf895bc2911c1d260e06bd987",
@@ -4028,7 +4028,7 @@ All OpenShift Container Platform 4.10 users are advised to upgrade to these upda
40284028
Name: "tomcat",
40294029
VersionFormat: component.JavaSourceType.String(),
40304030
Version: "9.0.59",
4031-
FixedBy: "9.0.99",
4031+
FixedBy: "9.0.107",
40324032
Location: "tomcat-embed-core-9.0.59.jar",
40334033
Vulnerabilities: []apiV1.Vulnerability{
40344034
{
@@ -4056,7 +4056,7 @@ All OpenShift Container Platform 4.10 users are advised to upgrade to these upda
40564056
},
40574057
{
40584058
Name: "CVE-2023-28708",
4059-
Description: "\nWhen using the RemoteIpFilter with requests received from a reverse proxy via HTTP that include the X-Forwarded-Proto header set to https, session cookies created by Apache Tomcat 11.0.0-M1 to 11.0.0.-M2, 10.1.0-M1 to 10.1.5, 9.0.0-M1 to 9.0.71 and 8.5.0 to 8.5.85 did not\u00a0include the secure attribute. This could result in the user agent\u00a0transmitting the session cookie over an insecure channel.\n\n\n\n\n\n\n\n",
4059+
Description: "When using the RemoteIpFilter with requests received from a reverse proxy via HTTP that include the X-Forwarded-Proto header set to https, session cookies created by Apache Tomcat 11.0.0-M1 to 11.0.0.-M2, 10.1.0-M1 to 10.1.5, 9.0.0-M1 to 9.0.71 and 8.5.0 to 8.5.85 did not\u00a0include the secure attribute. This could result in the user agent\u00a0transmitting the session cookie over an insecure channel.\n\nOlder, EOL versions may also be affected.",
40604060
Link: "https://nvd.nist.gov/vuln/detail/CVE-2023-28708",
40614061
Severity: "Moderate",
40624062
FixedBy: "9.0.72",
@@ -4318,7 +4318,7 @@ All OpenShift Container Platform 4.10 users are advised to upgrade to these upda
43184318
},
43194319
},
43204320
AddedBy: "sha256:661ff4d9561e3fd050929ee5097067c34bafc523ee60f5294a37fd08056a73ca",
4321-
FixedBy: "3.1.4-r5",
4321+
FixedBy: "3.1.7-r0",
43224322
},
43234323
},
43244324
},
@@ -4354,7 +4354,34 @@ All OpenShift Container Platform 4.10 users are advised to upgrade to these upda
43544354
NamespaceName: "alpine:v3.20",
43554355
VersionFormat: "apk",
43564356
Version: "3.3.0-r2",
4357-
AddedBy: "sha256:d25f557d7f31bf7acfac935859b5153da41d13c41f2b468d16f729a5b883634f",
4357+
Vulnerabilities: []apiV1.Vulnerability{
4358+
{
4359+
Name: "CVE-2024-6119",
4360+
NamespaceName: "alpine:v3.20",
4361+
Description: "Issue summary: Applications performing certificate name checks (e.g., TLS\nclients checking server certificates) may attempt to read an invalid memory\naddress resulting in abnormal termination of the application process.\n\nImpact summary: Abnormal termination of an application can a cause a denial of\nservice.\n\nApplications performing certificate name checks (e.g., TLS clients checking\nserver certificates) may attempt to read an invalid memory address when\ncomparing the expected name with an `otherName` subject alternative name of an\nX.509 certificate. This may result in an exception that terminates the\napplication program.\n\nNote that basic certificate chain validation (signatures, dates, ...) is not\naffected, the denial of service can occur only when the application also\nspecifies an expected DNS name, Email address or IP address.\n\nTLS servers rarely solicit client certificates, and even when they do, they\ngenerally don't perform a name check against a reference identifier (expected\nidentity), but rather extract the presented identity after checking the\ncertificate chain. So TLS servers are generally not affected and the severity\nof the issue is Moderate.\n\nThe FIPS modules in 3.3, 3.2, 3.1 and 3.0 are not affected by this issue.",
4362+
Link: "https://www.cve.org/CVERecord?id=CVE-2024-6119",
4363+
Severity: "Important",
4364+
FixedBy: "3.3.2-r0",
4365+
Metadata: map[string]interface{}{
4366+
"NVD": map[string]interface{}{
4367+
"CVSSv2": map[string]interface{}{
4368+
"ExploitabilityScore": 0.0,
4369+
"ImpactScore": 0.0,
4370+
"Score": 0.0,
4371+
"Vectors": "",
4372+
},
4373+
"CVSSv3": map[string]interface{}{
4374+
"ExploitabilityScore": 3.9,
4375+
"ImpactScore": 3.6,
4376+
"Score": 7.5,
4377+
"Vectors": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H",
4378+
},
4379+
},
4380+
},
4381+
},
4382+
},
4383+
AddedBy: "sha256:d25f557d7f31bf7acfac935859b5153da41d13c41f2b468d16f729a5b883634f",
4384+
FixedBy: "3.3.2-r0",
43584385
},
43594386
},
43604387
},
@@ -4399,30 +4426,6 @@ All OpenShift Container Platform 4.10 users are advised to upgrade to these upda
43994426
},
44004427
},
44014428
},
4402-
{
4403-
Name: "CVE-2024-47177",
4404-
NamespaceName: "rhel:8",
4405-
Description: "DOCUMENTATION: A security flaw was found in OpenPrinting CUPS. The `FoomaticRIPCommandLine` directive in a PPD file will allow arbitrary commands to be executed when a print job is sent to the affected printing device. An attacker who could provide a malicious PPD file for a new print device or modify a PPD file of an existing device could execute arbitrary commands. \n STATEMENT: Red Hat rates the severity of this CVE as Moderate due to the restrictions of the unprivileged ‘lp’ user which the resulting commands would be run as. Additionally, creating and modifying printer definitions is restricted to the privileged user groups sys, root, and wheel by default.\n MITIGATION: See the security bulletin for a detailed mitigation procedure.",
4406-
Link: "https://access.redhat.com/security/cve/CVE-2024-47177",
4407-
Severity: "Moderate",
4408-
FixedBy: "",
4409-
Metadata: map[string]interface{}{
4410-
"Red Hat": map[string]interface{}{
4411-
"CVSSv2": map[string]interface{}{
4412-
"ExploitabilityScore": 0.0,
4413-
"ImpactScore": 0.0,
4414-
"Score": 0.0,
4415-
"Vectors": "",
4416-
},
4417-
"CVSSv3": map[string]interface{}{
4418-
"ExploitabilityScore": 0.6,
4419-
"ImpactScore": 5.5,
4420-
"Score": 6.1,
4421-
"Vectors": "CVSS:3.1/AV:L/AC:L/PR:H/UI:R/S:U/C:H/I:H/A:L",
4422-
},
4423-
},
4424-
},
4425-
},
44264429
},
44274430
},
44284431
{
@@ -4794,7 +4797,7 @@ All OpenShift Container Platform 4.10 users are advised to upgrade to these upda
47944797
NamespaceName: "rhel:8",
47954798
VersionFormat: "rpm",
47964799
Version: "1:17.0.11.0.9-2.el8.x86_64",
4797-
FixedBy: "1:17.0.15.0.6-2.el8",
4800+
FixedBy: "1:17.0.16.0.8-2.el8",
47984801
AddedBy: "sha256:06c7a3d491f551a56296ccb9bee8a68c83776991e73a9005e8b5ebb533002097",
47994802
},
48004803
},
@@ -4813,7 +4816,7 @@ All OpenShift Container Platform 4.10 users are advised to upgrade to these upda
48134816
NamespaceName: "rhel:8",
48144817
VersionFormat: "rpm",
48154818
Version: "1:17.0.13.0.11-3.el8.x86_64",
4816-
FixedBy: "1:17.0.15.0.6-2.el8",
4819+
FixedBy: "1:17.0.16.0.8-2.el8",
48174820
AddedBy: "sha256:2f7b9495af5ddc85b0be7ca9411fddb54f37999ea73b03cbf1115dd0c5bd4f95",
48184821
},
48194822
},

pkg/env/list.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ var (
4141
// MaxGrpcConcurrentStreams configures the maximum number of HTTP/2 streams to use with gRPC
4242
MaxGrpcConcurrentStreams = RegisterIntegerSetting("ROX_GRPC_MAX_CONCURRENT_STREAMS", DefaultMaxGrpcConcurrentStreams)
4343

44-
// LegacyNVDLoader when true will cause the loader to pull NVD data using
45-
// the NVD Legacy Data Feeds, if false will pull from the NVD 2.0 API.
46-
LegacyNVDLoader = RegisterBooleanSetting("ROX_LEGACY_NVD_LOADER", false)
44+
// NVDFeedLoader when true will cause the loader to pull NVD data using
45+
// the NVD 2.0 Data Feeds. If false, the loader will pull from the NVD 2.0 API.
46+
NVDFeedLoader = RegisterBooleanSetting("ROX_NVD_FEED_LOADER", false)
4747

4848
// RHLineage when true will cause all parent layers (a.k.a lineage) to be considered when
4949
// storing scan results for RHEL image layers.

pkg/vulnloader/nvdloader/convert.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const (
1414
jsonTimeFormat = "2006-01-02T15:04Z"
1515
)
1616

17-
func toJSON(vulns []*apischema.CVEAPIJSON20DefCVEItem) ([]*jsonschema.NVDCVEFeedJSON10DefCVEItem, error) {
17+
func toJSON10(vulns []*apischema.CVEAPIJSON20DefCVEItem) ([]*jsonschema.NVDCVEFeedJSON10DefCVEItem, error) {
1818
if vulns == nil {
1919
return nil, nil
2020
}
@@ -31,6 +31,11 @@ func toJSON(vulns []*apischema.CVEAPIJSON20DefCVEItem) ([]*jsonschema.NVDCVEFeed
3131
continue
3232
}
3333

34+
// Ignore rejected vulnerabilities.
35+
if strings.EqualFold(vuln.CVE.VulnStatus, "Rejected") {
36+
continue
37+
}
38+
3439
cve := vuln.CVE
3540

3641
modifiedTime, err := toTime(cve.LastModified)
@@ -152,14 +157,18 @@ func toBaseMetricV2(metrics []*apischema.CVEAPIJSON20CVSSV2) *jsonschema.NVDCVEF
152157
}
153158

154159
func toBaseMetricV3(metrics30 []*apischema.CVEAPIJSON20CVSSV30, metrics31 []*apischema.CVEAPIJSON20CVSSV31) *jsonschema.NVDCVEFeedJSON10DefImpactBaseMetricV3 {
155-
switch {
156-
case len(metrics31) != 0:
157-
return toBaseMetricV31(metrics31)
158-
case len(metrics30) != 0:
159-
return toBaseMetricV30(metrics30)
160-
default:
161-
return nil
160+
// Prefer CVSS 3.1.
161+
baseMetric := toBaseMetricV31(metrics31)
162+
if baseMetric != nil {
163+
return baseMetric
162164
}
165+
166+
baseMetric = toBaseMetricV30(metrics30)
167+
if baseMetric != nil {
168+
return baseMetric
169+
}
170+
171+
return nil
163172
}
164173

165174
func toBaseMetricV31(metrics []*apischema.CVEAPIJSON20CVSSV31) *jsonschema.NVDCVEFeedJSON10DefImpactBaseMetricV3 {
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
package nvdloader
2+
3+
import (
4+
"os"
5+
"testing"
6+
7+
jsonschema "github.com/facebookincubator/nvdtools/cvefeed/nvd/schema"
8+
"github.com/stretchr/testify/assert"
9+
"github.com/stretchr/testify/require"
10+
)
11+
12+
func TestToJSON10(t *testing.T) {
13+
f, err := os.Open("testdata/nvdcve-2.0-2025.json")
14+
require.NoError(t, err)
15+
t.Cleanup(func() {
16+
require.NoError(t, f.Close())
17+
})
18+
19+
cveAPI, err := parseReader(f)
20+
require.NoError(t, err)
21+
22+
cveFeed, err := toJSON10(cveAPI.Vulnerabilities)
23+
assert.NoError(t, err)
24+
25+
expected := []*jsonschema.NVDCVEFeedJSON10DefCVEItem{
26+
{
27+
CVE: &jsonschema.CVEJSON40{
28+
CVEDataMeta: &jsonschema.CVEJSON40CVEDataMeta{
29+
ID: "CVE-2025-0168",
30+
},
31+
Description: &jsonschema.CVEJSON40Description{
32+
DescriptionData: []*jsonschema.CVEJSON40LangString{
33+
{
34+
Lang: "en",
35+
Value: "A vulnerability classified as critical has been found in code-projects Job Recruitment 1.0. This affects an unknown part of the file /_parse/_feedback_system.php. The manipulation of the argument person leads to sql injection. It is possible to initiate the attack remotely. The exploit has been disclosed to the public and may be used.",
36+
},
37+
},
38+
},
39+
},
40+
Configurations: &jsonschema.NVDCVEFeedJSON10DefConfigurations{
41+
Nodes: []*jsonschema.NVDCVEFeedJSON10DefNode{
42+
{
43+
CPEMatch: []*jsonschema.NVDCVEFeedJSON10DefCPEMatch{
44+
{
45+
Cpe23Uri: "cpe:2.3:a:anisha:job_recruitment:1.0:*:*:*:*:*:*:*",
46+
Vulnerable: true,
47+
},
48+
},
49+
Operator: "OR",
50+
},
51+
},
52+
},
53+
Impact: &jsonschema.NVDCVEFeedJSON10DefImpact{
54+
BaseMetricV3: &jsonschema.NVDCVEFeedJSON10DefImpactBaseMetricV3{
55+
CVSSV3: &jsonschema.CVSSV30{
56+
AttackComplexity: "LOW",
57+
AttackVector: "NETWORK",
58+
AvailabilityImpact: "NONE",
59+
BaseScore: 7.5,
60+
BaseSeverity: "HIGH",
61+
ConfidentialityImpact: "HIGH",
62+
IntegrityImpact: "NONE",
63+
PrivilegesRequired: "NONE",
64+
Scope: "UNCHANGED",
65+
UserInteraction: "NONE",
66+
VectorString: "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N",
67+
Version: "3.1",
68+
},
69+
ExploitabilityScore: 3.9,
70+
ImpactScore: 3.6,
71+
},
72+
},
73+
LastModifiedDate: "2025-02-25T21:26Z",
74+
PublishedDate: "2025-01-01T14:15Z",
75+
},
76+
{
77+
CVE: &jsonschema.CVEJSON40{
78+
CVEDataMeta: &jsonschema.CVEJSON40CVEDataMeta{
79+
ID: "CVE-2025-22144",
80+
},
81+
Description: &jsonschema.CVEJSON40Description{
82+
DescriptionData: []*jsonschema.CVEJSON40LangString{
83+
{
84+
Lang: "en",
85+
Value: "NamelessMC is a free, easy to use & powerful website software for Minecraft servers. A user with admincp.core.emails or admincp.users.edit permissions can validate users and an attacker can reset their password. When the account is successfully approved by email the reset code is NULL, but when the account is manually validated by a user with admincp.core.emails or admincp.users.edit permissions then the reset_code will no longer be NULL but empty. An attacker can request http://localhost/nameless/index.php?route=/forgot_password/&c= and reset the password. As a result an attacker may compromise another users password and take over their account. This issue has been addressed in release version 2.1.3 and all users are advised to upgrade. There are no known workarounds for this vulnerability.",
86+
},
87+
},
88+
},
89+
},
90+
Configurations: &jsonschema.NVDCVEFeedJSON10DefConfigurations{
91+
Nodes: []*jsonschema.NVDCVEFeedJSON10DefNode{
92+
{
93+
CPEMatch: []*jsonschema.NVDCVEFeedJSON10DefCPEMatch{
94+
{
95+
Cpe23Uri: "cpe:2.3:a:namelessmc:nameless:*:*:*:*:*:*:*:*",
96+
VersionEndExcluding: "2.1.3",
97+
Vulnerable: true,
98+
},
99+
},
100+
Operator: "OR",
101+
},
102+
},
103+
},
104+
Impact: &jsonschema.NVDCVEFeedJSON10DefImpact{
105+
BaseMetricV3: &jsonschema.NVDCVEFeedJSON10DefImpactBaseMetricV3{
106+
CVSSV3: &jsonschema.CVSSV30{
107+
AttackComplexity: "LOW",
108+
AttackVector: "NETWORK",
109+
AvailabilityImpact: "HIGH",
110+
BaseScore: 9.8,
111+
BaseSeverity: "CRITICAL",
112+
ConfidentialityImpact: "HIGH",
113+
IntegrityImpact: "HIGH",
114+
PrivilegesRequired: "NONE",
115+
Scope: "UNCHANGED",
116+
UserInteraction: "NONE",
117+
VectorString: "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
118+
Version: "3.1",
119+
},
120+
ExploitabilityScore: 3.9,
121+
ImpactScore: 5.9,
122+
},
123+
},
124+
LastModifiedDate: "2025-05-13T15:42Z",
125+
PublishedDate: "2025-01-13T20:15Z",
126+
},
127+
}
128+
129+
assert.ElementsMatch(t, expected, cveFeed)
130+
}

0 commit comments

Comments
 (0)