Using the NIST Database and API to Keep Up with Vulnerabilities and Patches - Playing with Code (Part 2 of 3)
Building on yesterday's story - now that we have an inventory built in CPE format, let's take an example CVE from that and write some code. What's in the NVD database (and API) that you can access, then use in your organization?
First, let's play with CVE-2020-24436, which is an Acrobat Reader vulnerability. In PowerShell, let's construct our query, then from the results pull out all the bits that we're interested in.
$request = "https://services.nvd.nist.gov/rest/json/cve/1.0/CVE-2020-24436" |
Let's start with the Published Date. Note again that there's also a "last modified" date - the idea being that if a CVE gets updated that the modified date will reflect that. Even looking at that briefly though that "last modified" date seems to be programatic, so I think it's getting changed when folks don't intend it - my first check was a Peoplesoft vuln from 2017, it had a 2020 last modified date for no reason I could see. Anyway, here's the published date:
$PublishedDate = $cvemetadata.result.cve_items.publishedDate 2020-11-05T20:15Z |
Next, the text description. This is where the "traditional" CVE delivery paths fall down - they generally give you get the CVE number, then this text description, maybe a severity score. This is fine for news stories or your report to management, but it's not something you can "monitor" when hundreds of them fly by every day. Sorry about the rant, but I guess that's why we're playing with this code, so that you can build your own delivery mechanism for your organization. Anyway, back to the text description:
$CVEDesc = $cvemetadata.result.cve_items.cve.description.description_data.value $CVEDesc |
The Reference URLs that may have more detail (usually there's a vendor URL in this list):
$CVEURLs=$cvemetadata.result.cve_items.cve.references.reference_data.url |
The data on severity and scope. This is what we used to call the CVSS score, but you can see there's a lot more detail in this metadata now:
$CVE_CVSSv3Data = $cvemetadata.result.CVE_items.impact.basemetricv3.cvssv3
|
We know what's installed on our affected host, but what versions of the application are affected by this CVE? Note that list gives you both vulnerable and unaffected versions (True or False in the "vulnerable" field):
$CVEAffectedApps=$cvemetadata.result.CVE_items.configurations.nodes.children.cpe_match $CVEAffectedApps vulnerable cpe23Uri versionEndIncluding |
Winnowing this down to just the vulnerable versions:
($cvemetadata.result.CVE_items.configurations.nodes.children.cpe_match) | where {$_.vulnerable -eq "true" } vulnerable cpe23Uri versionEndIncluding
|
Now with some code written, on Monday we'll string everything together into a useful, complete reporting tool that you can use.
===============
Rob VandenBrink
rob@coherentconsulting.com
Comments