Lesson 09 · 45 minutes
Read vulnerability records and join them with exploitation data
- Say what a CVE, a CWE, a CVSS score, the KEV catalogue and an EPSS score are
- Split a CVSS vector into its metrics and give a score its severity band
- Join severity and exploitation data in one table, and show where they disagree
The lab folder as it stands after this lesson. Unzip it in ~/krlab.
More
The zip holds every file that the course has printed up to here. To start this lesson with the files of the earlier lessons only, take the zip of the lesson before. Type the code yourself first: you learn more.
Scenario
On Tuesday the vendor notices of the week arrive: fourteen new vulnerabilities, five of them "Critical". The team lead asks: "A 9.8 does not tell me whether I must wake someone up. Make me a table with the score, whether the flaw is already used by attackers, and how likely that is. And teach me which word means what, because the notices use them as if they were the same." Lesson 10 turns the table into a patch order for your own systems. This lesson makes the table.
Recall
Lesson 4: severity and priority are not the same. Which one is set before you look at the context?
Severity. It is what the rule author decided for one alert of the rule. Priority is what you do first, and you set it after the context (who is it, is it expected, did it work).
Lesson 4: an alert is a true positive and nothing got in. What priority does it get, and why not none?
P2 or P3, by the severity of the rule. The activity is real, and the same address may return, so it is not closed, but nothing was lost, so it is not urgent.
The idea
Five public names appear in every vulnerability notice. Each answers a different question.
| Name | Question it answers | Facts |
|---|---|---|
| CVE | Which flaw is it? | An identifier for one publicly known vulnerability, in the form CVE-YEAR-NUMBER. The number has four or more digits. |
| CWE | What kind of weakness is it? | The Common Weakness Enumeration, a community list of types of software and hardware weaknesses. CWE-89 is SQL injection, CWE-79 is cross-site scripting, CWE-787 is a write outside a buffer. |
| CVSS | How bad is the flaw by itself? | A score from 0.0 to 10.0 from the properties of the flaw. It comes with a vector, a text that lists the metrics. |
| KEV | Is it used in attacks now? | The Known Exploited Vulnerabilities Catalog of the US agency CISA (the Cybersecurity and Infrastructure Security Agency). It lists flaws that are exploited in the wild. |
| EPSS | How likely is that? | The Exploit Prediction Scoring System of FIRST (the Forum of Incident Response and Security Teams). For each CVE it gives the probability from 0 to 1 of exploitation in the next 30 days, and a percentile. |
CVSS has two versions in use. Version 3.1 has eight base metrics. This is the vector of LAB-2026-0001, the first record of the lab:
The metrics are attack vector (AV), attack complexity (AC), privileges required (PR), user interaction (UI), scope (S) and the impact on confidentiality, integrity and availability (C, I, A). Version 4.0 (prefix CVSS:4.0/) removes scope, adds attack requirements (AT), and splits impact into the vulnerable system (VC, VI, VA) and later systems (SC, SI, SA). A score is named after the groups that it uses: CVSS-B is the base only, CVSS-BT adds threat data. Both versions give the same bands: None 0.0, Low 0.1 to 3.9, Medium 4.0 to 6.9, High 7.0 to 8.9, Critical 9.0 to 10.0.
Three more words are often mixed up. A vulnerability is a weakness in software or in a setting. Exposure is whether an attacker can reach it: a service on the internet is exposed, a service on an isolated network much less. Risk is the chance that harm happens and how large it is, for you. The same flaw is a high risk on a public server with customer data and a low risk on an unused test machine. A CVSS score knows nothing about your systems.
Worked example
1. Make the lab files
All records in this course are invented. The ids start with LAB- so that they cannot be mixed up with real CVE ids. vulns.json has fourteen records in the style of a vulnerability feed: id, product, the version that fixes it, the CWE, the score, the vector and a summary. kev.json has the shape of the CISA catalogue (the field names cveID, dateAdded, dueDate and knownRansomwareCampaignUse are real ones), with three lab entries. epss.csv has the columns of the public EPSS file: cve, epss and percentile. The scores are given: this course does not calculate them.
cat > vulns.json <<'EOT'
[
{"id": "LAB-2026-0001", "product": "shopkit", "fixed_in": "4.3.0", "cwe": "CWE-89", "cvss": 9.8,
"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "summary": "SQL injection in the search page"},
{"id": "LAB-2026-0002", "product": "shopkit", "fixed_in": "4.2.0", "cwe": "CWE-79", "cvss": 6.1,
"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N", "summary": "Script injection in a review"},
{"id": "LAB-2026-0003", "product": "edgeproxy", "fixed_in": "2.9.0", "cwe": "CWE-787", "cvss": 8.1,
"vector": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H", "summary": "Memory write outside a buffer"},
{"id": "LAB-2026-0004", "product": "dbstore", "fixed_in": "9.5.0", "cwe": "CWE-306", "cvss": 9.1,
"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N", "summary": "Admin port needs no login"},
{"id": "LAB-2026-0005", "product": "buildrunner", "fixed_in": "5.2.0", "cwe": "CWE-798", "cvss": 9.8,
"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "summary": "Hard-coded service password"},
{"id": "LAB-2026-0006", "product": "fileshare", "fixed_in": "3.1.0", "cwe": "CWE-22", "cvss": 7.5,
"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N", "summary": "Path traversal reads any file"},
{"id": "LAB-2026-0007", "product": "wikilite", "fixed_in": "2.0.0", "cwe": "CWE-79", "cvss": 5.4,
"vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N", "summary": "Script injection in a page title"},
{"id": "LAB-2026-0008", "product": "vpngate", "fixed_in": "7.2.1", "cwe": "CWE-287", "cvss": 9.8,
"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "summary": "Login check can be skipped"},
{"id": "LAB-2026-0009", "product": "mailrelay", "fixed_in": "3.4.0", "cwe": "CWE-400", "cvss": 7.5,
"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "summary": "One message can use all memory"},
{"id": "LAB-2026-0010", "product": "docview", "fixed_in": "11.1.0", "cwe": "CWE-787", "cvss": 7.8,
"vector": "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H", "summary": "A crafted file runs code"},
{"id": "LAB-2026-0011", "product": "shopkit", "fixed_in": "4.4.0", "cwe": "CWE-352", "cvss": 6.5,
"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:H/A:N", "summary": "Forged request changes an order"},
{"id": "LAB-2026-0012", "product": "vpngate", "fixed_in": "7.0.0", "cwe": "CWE-79", "cvss": 6.1,
"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N", "summary": "Script injection in the login page"},
{"id": "LAB-2026-0013", "product": "buildrunner", "fixed_in": "5.1.2", "cwe": "CWE-306", "cvss": 9.3,
"vector": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N", "summary": "Job API needs no login"},
{"id": "LAB-2026-0014", "product": "printspool", "fixed_in": "1.8.0", "cwe": "CWE-787", "cvss": 8.8,
"vector": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "summary": "Memory write in the print queue"}
]
EOTcat > kev.json <<'EOT'
{
"title": "Lab catalogue of known exploited vulnerabilities",
"catalogVersion": "lab-1",
"count": 3,
"vulnerabilities": [
{"cveID": "LAB-2026-0001", "vendorProject": "Lab", "product": "shopkit", "dateAdded": "2026-11-02",
"dueDate": "2026-11-23", "knownRansomwareCampaignUse": "Unknown"},
{"cveID": "LAB-2026-0006", "vendorProject": "Lab", "product": "fileshare", "dateAdded": "2026-10-20",
"dueDate": "2026-11-10", "knownRansomwareCampaignUse": "Known"},
{"cveID": "LAB-2026-0008", "vendorProject": "Lab", "product": "vpngate", "dateAdded": "2026-11-15",
"dueDate": "2026-12-06", "knownRansomwareCampaignUse": "Unknown"}
]
}
EOTcat > epss.csv <<'EOT'
cve,epss,percentile
LAB-2026-0001,0.93,0.99
LAB-2026-0002,0.02,0.61
LAB-2026-0003,0.41,0.97
LAB-2026-0004,0.12,0.94
LAB-2026-0005,0.77,0.98
LAB-2026-0006,0.64,0.98
LAB-2026-0007,0.02,0.60
LAB-2026-0008,0.97,0.99
LAB-2026-0009,0.05,0.88
LAB-2026-0010,0.30,0.96
LAB-2026-0011,0.01,0.40
LAB-2026-0012,0.01,0.38
LAB-2026-0013,0.55,0.98
LAB-2026-0014,0.08,0.91
EOT2. Split a vector
A vector is CVSS:, the version, and then pairs METRIC:VALUE separated by /. split("/") cuts a text at every slash, head, *parts = ... puts the first item in head and the rest in parts, and dict(...) makes a dictionary from pairs. The record of LAB-2026-0013 has a 4.0 vector and the record of LAB-2026-0001 a 3.1 vector.
python3 - <<'PYEND'
import json
for record in json.load(open("vulns.json")):
if record["id"] in ("LAB-2026-0001", "LAB-2026-0013"):
head, *parts = record["vector"].split("/")
metrics = dict(part.split(":") for part in parts)
print(record["id"], head, len(metrics), "metrics", metrics["AV"], metrics["PR"])
PYENDLAB-2026-0001 CVSS:3.1 8 metrics N N
LAB-2026-0013 CVSS:4.0 11 metrics N NAV:N means that the attack comes over the network, and PR:N that the attacker needs no privileges. Version 3.1 has 8 base metrics and version 4.0 has 11.
3. Save the reader
vulns.py has three jobs. parse_vector is the code of step 2. band turns a score into its severity name. load joins the three files by id and returns one row for each vulnerability. The main part prints two lists.
vulns.py
"""vulns.py: read the vulnerability files and join them by id.
python3 vulns.py [vulns.json] [kev.json] [epss.csv]
"""
import csv
import json
import sys
BANDS = [(9.0, "Critical"), (7.0, "High"), (4.0, "Medium"), (0.1, "Low")]
def band(score):
"""The name of the severity band of a CVSS score."""
for low, name in BANDS:
if score >= low:
return name
return "None"
def parse_vector(vector):
"""Split a CVSS vector such as CVSS:3.1/AV:N/AC:L/... into its version and a dictionary of metrics."""
head, *parts = vector.split("/")
return head.split(":")[1], dict(part.split(":") for part in parts)
def load(vulns="vulns.json", kev="kev.json", epss="epss.csv"):
"""One row for each vulnerability, with the band, the metrics, the KEV flag and the EPSS score added."""
exploited = {item["cveID"] for item in json.load(open(kev))["vulnerabilities"]}
with open(epss, newline="") as src:
probability = {row["cve"]: float(row["epss"]) for row in csv.DictReader(src)}
rows = []
for v in json.load(open(vulns)):
version, metrics = parse_vector(v["vector"])
rows.append({**v, "version": version, "metrics": metrics, "band": band(v["cvss"]),
"kev": v["id"] in exploited, "epss": probability.get(v["id"], 0.0)})
return rows
if __name__ == "__main__":
rows = load(*sys.argv[1:4])
print("by CVSS score")
for r in sorted(rows, key=lambda r: -r["cvss"]):
print(f" {r['id']} {r['band']:8s} {r['cvss']:4.1f} {'KEV' if r['kev'] else ' '} {r['epss']:.2f} {r['cwe']}")
print("by EPSS score")
for r in sorted(rows, key=lambda r: -r["epss"])[:5]:
print(f" {r['id']} {r['band']:8s} {r['cvss']:4.1f} {'KEV' if r['kev'] else ' '} {r['epss']:.2f} {r['cwe']}")4. Compare the two orders
python3 vulns.pyby CVSS score
LAB-2026-0001 Critical 9.8 KEV 0.93 CWE-89
LAB-2026-0005 Critical 9.8 0.77 CWE-798
LAB-2026-0008 Critical 9.8 KEV 0.97 CWE-287
LAB-2026-0013 Critical 9.3 0.55 CWE-306
LAB-2026-0004 Critical 9.1 0.12 CWE-306
LAB-2026-0014 High 8.8 0.08 CWE-787
LAB-2026-0003 High 8.1 0.41 CWE-787
LAB-2026-0010 High 7.8 0.30 CWE-787
LAB-2026-0006 High 7.5 KEV 0.64 CWE-22
LAB-2026-0009 High 7.5 0.05 CWE-400
LAB-2026-0011 Medium 6.5 0.01 CWE-352
LAB-2026-0002 Medium 6.1 0.02 CWE-79
LAB-2026-0012 Medium 6.1 0.01 CWE-79
LAB-2026-0007 Medium 5.4 0.02 CWE-79
by EPSS score
LAB-2026-0008 Critical 9.8 KEV 0.97 CWE-287
LAB-2026-0001 Critical 9.8 KEV 0.93 CWE-89
LAB-2026-0005 Critical 9.8 0.77 CWE-798
LAB-2026-0006 High 7.5 KEV 0.64 CWE-22
LAB-2026-0013 Critical 9.3 0.55 CWE-306Read the two lists next to each other. By score, LAB-2026-0005 (a hard-coded password, 9.8) is as high as the two flaws in the catalogue, but it is not in the catalogue. LAB-2026-0006 is only High (7.5), yet it is in the catalogue, and its entry says that ransomware groups use it. LAB-2026-0004 is Critical (9.1), and its EPSS is 0.12. The three words "critical", "exploited" and "likely" are three different facts.
5. Ask the data a question
How many Critical flaws are not in KEV and have an EPSS below 0.5? A one-line program answers it.
python3 -c "
from vulns import load
rows = [r for r in load() if r['band'] == 'Critical' and not r['kev'] and r['epss'] < 0.5]
print(len(rows), [r['id'] for r in rows])
"1 ['LAB-2026-0004']One of five Critical flaws is neither listed nor likely. It still needs a fix, but it is not the one that wakes anybody. The next lesson uses these facts, and the facts about your own machines, for a patch order.
Your turn
A second list of six records came with the next notice. Save it as v2.json, k2.json and e2.csv, and read it with load("v2.json", "k2.json", "e2.csv") from your vulns.py. Do not change vulns.py.
cat > v2.json <<'EOT'
[
{"id": "LAB-2026-0101", "product": "vpnd", "fixed_in": "2.0.0", "cwe": "CWE-287", "cvss": 9.8,
"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H", "summary": "Login check can be skipped"},
{"id": "LAB-2026-0102", "product": "dbx", "fixed_in": "5.1.0", "cwe": "CWE-306", "cvss": 9.3,
"vector": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N", "summary": "Admin port needs no login"},
{"id": "LAB-2026-0103", "product": "viewer", "fixed_in": "8.2.0", "cwe": "CWE-787", "cvss": 7.8,
"vector": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H", "summary": "Memory write in the file reader"},
{"id": "LAB-2026-0104", "product": "webkit", "fixed_in": "3.3.0", "cwe": "CWE-400", "cvss": 5.3,
"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L", "summary": "A long request slows the server"},
{"id": "LAB-2026-0105", "product": "mailer", "fixed_in": "6.0.2", "cwe": "CWE-89", "cvss": 7.3,
"vector": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L", "summary": "SQL injection in the address book"},
{"id": "LAB-2026-0106", "product": "printd", "fixed_in": "1.4.0", "cwe": "CWE-787", "cvss": 6.5,
"vector": "CVSS:3.1/AV:A/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H", "summary": "Memory write in the print queue"}
]
EOTcat > k2.json <<'EOT'
{
"title": "Lab catalogue of known exploited vulnerabilities, second list",
"catalogVersion": "lab-2",
"count": 2,
"vulnerabilities": [
{"cveID": "LAB-2026-0101", "vendorProject": "Lab", "product": "vpnd", "dateAdded": "2026-11-18",
"dueDate": "2026-12-09", "knownRansomwareCampaignUse": "Known"},
{"cveID": "LAB-2026-0104", "vendorProject": "Lab", "product": "webkit", "dateAdded": "2026-11-19",
"dueDate": "2026-12-10", "knownRansomwareCampaignUse": "Unknown"}
]
}
EOTcat > e2.csv <<'EOT'
cve,epss,percentile
LAB-2026-0101,0.88,0.99
LAB-2026-0102,0.04,0.80
LAB-2026-0103,0.02,0.62
LAB-2026-0104,0.50,0.97
LAB-2026-0105,0.07,0.90
LAB-2026-0106,0.01,0.40
EOTCheck yourself
A notice says "critical, CVSS 9.8". What do you still not know?
You do not know whether it is exploited (KEV, EPSS), whether you run the product and which version, and whether the system can be reached by an attacker. The score describes the flaw. It does not describe your risk.
A flaw has a CVSS score of 5.3 and is in the KEV catalogue. How do you treat it?
As more urgent than its score says, if you run the product: attackers use it now. The catalogue is evidence of real use, and a medium score does not cancel that. Check exposure and the value of the asset, and fix it soon.
What is the difference between the EPSS score and the EPSS percentile?
The score is a probability from 0 to 1 that the flaw will be exploited in the next 30 days. The percentile says how that probability ranks among all scored flaws. A flaw with a score of 0.12 can still be in a high percentile, because most flaws have a very low score.
Why can one CVSS score not rank your patch work by itself?
It looks at the flaw alone. Two systems with the same flaw have the same score, whether one is on the internet with customer data and the other is an unused test machine. You also need exposure, asset value and evidence of use.
Field notes
- Take the real data from the source and check its header and its version: the CISA catalogue is a JSON file with a list called
vulnerabilities, and the EPSS file is a CSV file. The shapes can change, and a parser that assumes them will fail without a message. - CISA's catalogue page points its readers to a Binding Operational Directive on prioritising security updates by risk (BOD 26-04). The directive sets rules for US federal agencies, not for you, but it shows that a public body now ranks by risk and exploitation and not by severity alone. Read the current text on the CISA site for its rules and dates.
- Both CVSS versions will appear in feeds for years. Store the version with the score.
- EPSS is a prediction and the catalogue is a record. Use the catalogue for "now" and EPSS for "next", and tell a reader which one a number comes from.
- A record can change: a flaw is added to the catalogue next week. Run the join again every day.