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

ROX-19862: Add manual entry for CVE-2023-32697 #1464

Merged
merged 7 commits into from
Apr 9, 2024
Merged

Conversation

dcaravel
Copy link
Contributor

@dcaravel dcaravel commented Apr 4, 2024

CVE-2023-32697 was not being detected for sqlite-jdbc-3.41.2.1.jar due to an inaccurate CPE URI on the NVD entry.

To fix the match a manual entry was created with cpe:2.3:a:xerial:sqlite-jdbc:*:*:*:*:*:*:*:* added.

You'll notice some information appears missing when comparing the updater output to the NVD page and API, such as references and CWE. This appears to be because the updater omits data that was not provided by NVD, such as other CNA's, in this case GitHub. Consider this while reviewing the PR - if the additional data is used by Scanner / ACS it may be worthwhile adding it, unless there is a reason not to (such as licensing).

JSON output from Scanner updater

Output from: ./bin/updater generate-dump...

  {
    "cve": {
      "affects": null,
      "CVE_data_meta": {
        "ASSIGNER": "",
        "ID": "CVE-2023-32697"
      },
      "data_format": "",
      "data_type": "",
      "data_version": "",
      "description": {
        "description_data": [
          {
            "lang": "en",
            "value": "SQLite JDBC is a library for accessing and creating SQLite database files in Java. Sqlite-jdbc addresses a remote code execution vulnerability via JDBC URL. This issue impacting versions 3.6.14.1 through 3.41.2.1 and has been fixed in version 3.41.2.2.\n"
          }
        ]
      },
      "problemtype": null,
      "references": null
    },
    "configurations": {
      "CVE_data_version": "",
      "nodes": [
        {
          "cpe_match": [
            {
              "cpe23Uri": "cpe:2.3:a:sqlite_jdbc_project:sqlite_jdbc:*:*:*:*:*:*:*:*",
              "versionEndExcluding": "3.41.2.2",
              "versionStartIncluding": "3.6.14.1",
              "vulnerable": true
            }
          ],
          "operator": "OR"
        }
      ]
    },
    "impact": {
      "baseMetricV3": {
        "cvssV3": {
          "attackComplexity": "LOW",
          "attackVector": "NETWORK",
          "availabilityImpact": "HIGH",
          "baseScore": 9.8,
          "baseSeverity": "CRITICAL",
          "confidentialityImpact": "HIGH",
          "integrityImpact": "HIGH",
          "privilegesRequired": "NONE",
          "scope": "UNCHANGED",
          "userInteraction": "NONE",
          "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
          "version": "3.1"
        },
        "exploitabilityScore": 3.9,
        "impactScore": 5.9
      }
    },
    "lastModifiedDate": "2023-05-31T18:10Z",
    "publishedDate": "2023-05-23T23:15Z"
  },
JSON output from NVD API

Output from: curl -sS -H "apiKey: $NVD_API_KEY" https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2023-32697 | jq

{
  "resultsPerPage": 1,
  "startIndex": 0,
  "totalResults": 1,
  "format": "NVD_CVE",
  "version": "2.0",
  "timestamp": "2024-04-04T16:46:42.043",
  "vulnerabilities": [
    {
      "cve": {
        "id": "CVE-2023-32697",
        "sourceIdentifier": "security-advisories@github.com",
        "published": "2023-05-23T23:15:09.337",
        "lastModified": "2023-05-31T18:10:04.943",
        "vulnStatus": "Analyzed",
        "descriptions": [
          {
            "lang": "en",
            "value": "SQLite JDBC is a library for accessing and creating SQLite database files in Java. Sqlite-jdbc addresses a remote code execution vulnerability via JDBC URL. This issue impacting versions 3.6.14.1 through 3.41.2.1 and has been fixed in version 3.41.2.2.\n"
          }
        ],
        "metrics": {
          "cvssMetricV31": [
            {
              "source": "nvd@nist.gov",
              "type": "Primary",
              "cvssData": {
                "version": "3.1",
                "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
                "attackVector": "NETWORK",
                "attackComplexity": "LOW",
                "privilegesRequired": "NONE",
                "userInteraction": "NONE",
                "scope": "UNCHANGED",
                "confidentialityImpact": "HIGH",
                "integrityImpact": "HIGH",
                "availabilityImpact": "HIGH",
                "baseScore": 9.8,
                "baseSeverity": "CRITICAL"
              },
              "exploitabilityScore": 3.9,
              "impactScore": 5.9
            },
            {
              "source": "security-advisories@github.com",
              "type": "Secondary",
              "cvssData": {
                "version": "3.1",
                "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
                "attackVector": "NETWORK",
                "attackComplexity": "LOW",
                "privilegesRequired": "LOW",
                "userInteraction": "NONE",
                "scope": "UNCHANGED",
                "confidentialityImpact": "HIGH",
                "integrityImpact": "HIGH",
                "availabilityImpact": "HIGH",
                "baseScore": 8.8,
                "baseSeverity": "HIGH"
              },
              "exploitabilityScore": 2.8,
              "impactScore": 5.9
            }
          ]
        },
        "weaknesses": [
          {
            "source": "security-advisories@github.com",
            "type": "Primary",
            "description": [
              {
                "lang": "en",
                "value": "CWE-94"
              }
            ]
          }
        ],
        "configurations": [
          {
            "nodes": [
              {
                "operator": "OR",
                "negate": false,
                "cpeMatch": [
                  {
                    "vulnerable": true,
                    "criteria": "cpe:2.3:a:sqlite_jdbc_project:sqlite_jdbc:*:*:*:*:*:*:*:*",
                    "versionStartIncluding": "3.6.14.1",
                    "versionEndExcluding": "3.41.2.2",
                    "matchCriteriaId": "47BF8145-F503-4906-B97C-F58153E21309"
                  }
                ]
              }
            ]
          }
        ],
        "references": [
          {
            "url": "https://github.com/xerial/sqlite-jdbc/releases/tag/3.41.2.2",
            "source": "security-advisories@github.com",
            "tags": [
              "Release Notes"
            ]
          },
          {
            "url": "https://github.com/xerial/sqlite-jdbc/security/advisories/GHSA-6phf-6h5g-97j2",
            "source": "security-advisories@github.com",
            "tags": [
              "Vendor Advisory"
            ]
          }
        ]
      }
    }
  ]
}

Testing

Created image quay.io/rhacs-eng/qa:sqlite-jdbc-CVE-2023-32697 and added E2E test:

❯ go test -tags e2e -count=1 -timeout=20m -v -run='TestImageSanity/^quay.io/rhacs-eng/qa:sqlite*' ./e2etests/...
=== RUN   TestImageSanity
=== RUN   TestImageSanity/quay.io/rhacs-eng/qa:sqlite-jdbc-CVE-2023-32697
=== RUN   TestImageSanity/quay.io/rhacs-eng/qa:sqlite-jdbc-CVE-2023-32697/sqlite-jdbc/3.41.2.1
--- PASS: TestImageSanity (4.60s)
    --- PASS: TestImageSanity/quay.io/rhacs-eng/qa:sqlite-jdbc-CVE-2023-32697 (4.60s)
        --- PASS: TestImageSanity/quay.io/rhacs-eng/qa:sqlite-jdbc-CVE-2023-32697/sqlite-jdbc/3.41.2.1 (0.00s)
Also verified via the local dev utility

Before adding manual entry:

$ go run ./localdev/
INFO[0000] Loading NVD definitions into cache           
INFO[0000] Loading definitions directory                 dir=/Users/dcaravel/dev/stackrox/scanner/image/scanner/dump/nvd
INFO[0017] Total vulns in "/Users/dcaravel/dev/stackrox/scanner/image/scanner/dump/nvd": 168634 
INFO[0018] Done loading NVD definitions into cache      
dignore/jdbc.tar
&{{0} rhel:8 rpm}
RHELv2 Components (0): rhel:8 - [ ][ ]
Removed components: []
182ebcf44f9194d116dce494b9036b87fe6b1496bed826a3c8e0eaa4158b93c6/layer.tar (0 components)
RHELv2 Components (0): rhel:8 - [ ][ ]
Removed components: []
0f25cb3bd57225cecc7d0d6091bb4629edec37720562a97477759f8da5712d8b/layer.tar (1 components)

0.0001 seconds took Checking for vulns

After adding manual entry and re-running updater:

$ go run ./localdev/
INFO[0000] Loading NVD definitions into cache           
INFO[0000] Loading definitions directory                 dir=/Users/dcaravel/dev/stackrox/scanner/image/scanner/dump/nvd
INFO[0017] Total vulns in "/Users/dcaravel/dev/stackrox/scanner/image/scanner/dump/nvd": 168634 
INFO[0018] Done loading NVD definitions into cache      
dignore/jdbc.tar
&{{0} rhel:8 rpm}
RHELv2 Components (0): rhel:8 - [ ][ ]
Removed components: []
182ebcf44f9194d116dce494b9036b87fe6b1496bed826a3c8e0eaa4158b93c6/layer.tar (0 components)
RHELv2 Components (0): rhel:8 - [ ][ ]
Removed components: []
0f25cb3bd57225cecc7d0d6091bb4629edec37720562a97477759f8da5712d8b/layer.tar (1 components)
	 sqlite-jdbc 3.41.2.1 JavaSourceType sqlite-jdbc-3.41.2.1.jar (1 vulns)
		 CVE-2023-32697 3.41.2.2

0.0001 seconds took Checking for vulns

@RTann RTann added the generate-dumps-on-pr Generates the image based on dumps from the PR label Apr 4, 2024
@RTann
Copy link
Collaborator

RTann commented Apr 4, 2024

@dcaravel can you add your sample image to quay.io/rhacs-eng/qa:<whatever> and then add that as a testcase in testcases_test.go? From there, you can add the generate-dumps-on-pr to ensure everything is good to go

Copy link
Collaborator

@RTann RTann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requested to add test for this

@dcaravel
Copy link
Contributor Author

dcaravel commented Apr 4, 2024

@dcaravel can you add your sample image to quay.io/rhacs-eng/qa:<whatever> and then add that as a testcase in testcases_test.go? From there, you can add the generate-dumps-on-pr to ensure everything is good to go

Excellent idea, will do.

@dcaravel
Copy link
Contributor Author

dcaravel commented Apr 5, 2024

Hrm, failure confuses me, works outside of CI...

❯ go test -tags e2e -count=1 -timeout=20m -v -run='TestImageSanity/^quay.io/rhacs-eng/qa:sqlite*' ./e2etests/...
=== RUN   TestImageSanity
=== RUN   TestImageSanity/quay.io/rhacs-eng/qa:sqlite-jdbc-CVE-2023-32697
=== RUN   TestImageSanity/quay.io/rhacs-eng/qa:sqlite-jdbc-CVE-2023-32697/sqlite-jdbc/3.41.2.1
--- PASS: TestImageSanity (4.60s)
    --- PASS: TestImageSanity/quay.io/rhacs-eng/qa:sqlite-jdbc-CVE-2023-32697 (4.60s)
        --- PASS: TestImageSanity/quay.io/rhacs-eng/qa:sqlite-jdbc-CVE-2023-32697/sqlite-jdbc/3.41.2.1 (0.00s)

@RTann
Copy link
Collaborator

RTann commented Apr 5, 2024

/retest

@dcaravel
Copy link
Contributor Author

dcaravel commented Apr 5, 2024

Manual entry not making it into the image, assuming with the PR label the image should have a fresh genesis dump baked in (notice missing additional CPE below):

docker save quay.io/rhacs-eng/scanner:2.33.x-29-g2dfc5cc703 > img.tar
tar -xvf img.tar
# find layer with `dive`
cd 8707d58bc14c1fa3dd569c241faf81fbfc0b2d5490af5928450200c0bf1a0dea
tar -xvf layer.tar
cd nvd_definitions
$ CVE="CVE-2023-32697"
$ grep -il "CVE-2023-32697" *
10.json

$ cat 10.json | jq ".CVE_Items[] | select( .cve.CVE_data_meta.ID == \"$CVE\")"
{
  "cve": {
    "affects": null,
    "CVE_data_meta": {
      "ASSIGNER": "",
      "ID": "CVE-2023-32697"
    },
    "data_format": "",
    "data_type": "",
    "data_version": "",
    "description": {
      "description_data": [
        {
          "lang": "en",
          "value": "SQLite JDBC is a library for accessing and creating SQLite database files in Java. Sqlite-jdbc addresses a remote code execution vulnerability via JDBC URL. This issue impacting versions 3.6.14.1 through 3.41.2.1 and has been fixed in version 3.41.2.2.\n"
        }
      ]
    },
    "problemtype": null,
    "references": null
  },
  "configurations": {
    "CVE_data_version": "",
    "nodes": [
      {
        "cpe_match": [
          {
            "cpe23Uri": "cpe:2.3:a:sqlite_jdbc_project:sqlite_jdbc:*:*:*:*:*:*:*:*",
            "versionEndExcluding": "3.41.2.2",
            "versionStartIncluding": "3.6.14.1",
            "vulnerable": true
          }
        ],
        "operator": "OR"
      }
    ]
  },
  "impact": {
    "baseMetricV3": {
      "cvssV3": {
        "attackComplexity": "LOW",
        "attackVector": "NETWORK",
        "availabilityImpact": "HIGH",
        "baseScore": 9.8,
        "baseSeverity": "CRITICAL",
        "confidentialityImpact": "HIGH",
        "integrityImpact": "HIGH",
        "privilegesRequired": "NONE",
        "scope": "UNCHANGED",
        "userInteraction": "NONE",
        "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
        "version": "3.1"
      },
      "exploitabilityScore": 3.9,
      "impactScore": 5.9
    }
  },
  "lastModifiedDate": "2023-05-31T18:10Z",
  "publishedDate": "2023-05-23T23:15Z"
}

@dcaravel
Copy link
Contributor Author

dcaravel commented Apr 5, 2024

Looks like made it into the genesis dump (https://github.com/stackrox/scanner/actions/runs/8575012414/artifacts/1389590520)

$ grep -il "CVE-2023-32697" *
0.json
1.json
10.json
11.json
2.json
3.json
4.json
5.json
6.json
7.json
8.json
9.json

$ cat 10.json | jq ".CVE_Items[] | select( .cve.CVE_data_meta.ID == \"$CVE\")" | jq '.configurations.nodes'
[
  {
    "cpe_match": [
      {
        "cpe23Uri": "cpe:2.3:a:sqlite_jdbc_project:sqlite_jdbc:*:*:*:*:*:*:*:*",
        "versionEndExcluding": "3.41.2.2",
        "versionStartIncluding": "3.6.14.1",
        "vulnerable": true
      },
      {
        "cpe23Uri": "cpe:2.3:a:xerial:sqlite-jdbc:*:*:*:*:*:*:*:*",
        "versionEndExcluding": "3.41.2.2",
        "versionStartIncluding": "3.6.14.1",
        "vulnerable": true
      }
    ],
    "operator": "OR"
  }
]

@dcaravel
Copy link
Contributor Author

dcaravel commented Apr 5, 2024

Hrm, perhaps this is the cause, in generate-scanner-bundle job: https://github.com/stackrox/scanner/actions/runs/8575012414/job/23505773248?pr=1464

INFO: Fri Apr  5 20:10:34 UTC 2024: Label generate-dumps-on-pr not set. Pulling dumps from GCS bucket

More context:

INFO: Fri Apr  5 20:10:34 UTC 2024: Warning: checking for a label in a non PR context
parse error: Invalid numeric literal at line 1, column 7

INFO: Fri Apr  5 20:10:34 UTC 2024: Label generate-dumps-on-pr not set. Pulling dumps from GCS bucket

@BradLugo Seen this before? Looks like this job isn't able to detect the generate-dumps-on-pr label

@dcaravel
Copy link
Contributor Author

dcaravel commented Apr 8, 2024

/retest

@dcaravel dcaravel requested a review from RTann April 8, 2024 18:32
Comment on lines 1334 to 1335
LastModifiedDate: "2024-04-04T00:00Z",
PublishedDate: "2024-04-04T00:00Z",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe change these to the NVD dates since this CVE was published back in 2023

Copy link
Contributor Author

@dcaravel dcaravel Apr 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the published date to be in sync with NVD, LastModifiedDate needs to be more recent then the last genesis dump or it will not appear in diff dumps (ran into this before in #1211). In that last PR it was requested to update PublishedDate as well which is why I did that here, but I agree keeping the PublishedDate in sync with NVD will be less confusing.

@dcaravel
Copy link
Contributor Author

dcaravel commented Apr 9, 2024

/retest

@dcaravel dcaravel merged commit ddb1423 into master Apr 9, 2024
18 checks passed
@dcaravel dcaravel deleted the dc/CVE-2023-32697 branch April 9, 2024 17:30
dcaravel added a commit that referenced this pull request Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generate-dumps-on-pr Generates the image based on dumps from the PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants