I’ll be doing several posts tonight. First, I will explain how the data is stored in the database. For our vulnerability information, we use the XML feed from NIST. One of my team members wrote a parser for it that puts it into a database:
mysql> describe nvd_cve;
+-----------------------------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------------------------+-------------+------+-----+---------+-------+
| cve | varchar(15) | NO | PRI | NULL | |
| cvss_score | float | YES | | NULL | |
| cvss_access_vector | varchar(25) | YES | | NULL | |
| cvss_access_complexity | varchar(15) | YES | | NULL | |
| cvss_authentication | varchar(25) | YES | | NULL | |
| cvss_confidentiality_impact | varchar(15) | YES | | NULL | |
| cvss_integrity_impact | varchar(15) | YES | | NULL | |
| cvss_availability_impact | varchar(15) | YES | | NULL | |
| cvss_source | text | YES | | NULL | |
| cvss_generated_on_datetime | tinytext | YES | | NULL | |
| cve_summary | text | YES | | NULL | |
| cve_published | tinytext | YES | | NULL | |
| cve_last_modified | tinytext | YES | | NULL | |
| cpe | mediumtext | YES | | NULL | |
+-----------------------------+-------------+------+-----+---------+-------+
All the information in the above table is from the NVD XML file at NIST. We are still in the process of working out a better way to use CPE, but that’s another blog post.
Next, our SCAP scanner checks every system every night, and writes the results to the database. It creates an entry for every vulnerability every night, and provides a “color”: Either Red if it’s vulnerable, or Green if it’s remediated.
mysql> describe vulns;
+--------------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------------+-------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| server | varchar(40) | YES | | NULL | |
| color | varchar(7) | YES | | NULL | |
| report_date | date | YES | MUL | NULL | |
| cve_number | varchar(17) | YES | MUL | NULL | |
| cve_date | date | YES | | NULL | |
| cve_description | text | YES | | NULL | |
| cve_remediation | text | YES | | NULL | |
| CVSS_Environmental | double | YES | | NULL | |
+--------------------+-------------+------+-----+---------+----------------+
You’ll notice the CVSS_Environmental field in the table above. This is where the calculated Device-Specific CVSS Score is put. It uses information from the nvd_cve table, as well as the assets table.
And finally, we have a table for our assets. This is populated from our asset management system that our infrastructure group maintains.
mysql> describe assets;
+---------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| server | varchar(40) | NO | PRI | | |
| risk | int(1) | YES | | NULL | |
| environment | tinytext | YES | | NULL | |
| network | tinytext | YES | | NULL | |
| owner | tinytext | YES | | NULL | |
| os | varchar(100) | YES | | NULL | |
| status | varchar(25) | YES | | NULL | |
| business_risk | int(1) | YES | | NULL | |
| data_risk | int(1) | YES | | NULL | |
| location_risk | int(1) | YES | | NULL | |
+---------------+--------------+------+-----+---------+-------+
The business_risk, data_risk, and location_risk fields I have talked about in a previous post. They are an integer from 1 to 3 and map to Availability Requirement, Confidentiality Requirement, and Integrity Requirement, respectively.
My next post will contain the PHP code I wrote to calculate the Device-Specific CVSS Score. The “CVSS_Environmental” field in the vulns table is calculated using a perl script one of my team members wrote. We aren’t actively using the PHP code in production, but I maintain it incase I need to do some quick reporting or charting.