Seventy-four problems on one web server
A CVE is the public name of one security flaw, and CVSS is the score that says how severe it is. A scanner that finds 74 problems on a web server reports each one with both.
Nobody fixes 74 things at once. Reading these two names well is the first step to choosing what comes first.
By the end of this lesson
Note
I can read a CVSS vector string and work out its base score.
Key words
| Word | What it means | Example |
|---|---|---|
| Vulnerability | a weakness an attacker could use | |
| CVE | a public identifier for one known vulnerability | CVE-2024-6119 |
| CVSS | a standard way to score how severe a vulnerability is | |
| Vector string | the metric values a CVSS score is worked out from | AV:N/AC:L |
| Base score | a number from 0 to 10 for the flaw itself | |
| Severity | the band a score falls in, from low to critical |
The cells students fill in are left blank in this preview.
Starter
Have a go
Starter
4 questionsA CVE names one flaw
A CVE identifier is the year and a number, such as CVE-2024-6119. A CVE Numbering Authority, often the software's own maker, assigns it. The US National Vulnerability Database, NVD, then adds its own analysis.
A scanner such as Trivy reads which packages an image holds and their versions. It compares them with advisories that say which versions each CVE affects and which version fixes it.
Which database is the scanner using?
docker exec scanner trivy --versionShown here, not run. Press Start lab to type it into your own lab’s terminal.
List the critical findings in the old image
docker exec scanner trivy image --input /targets/web-1.25.3.tar --severity CRITICALShown here, not run. Press Start lab to type it into your own lab’s terminal.
The three critical findings Trivy printed
| Package | CVE | Installed | Fixed in |
|---|---|---|---|
| libexpat | CVE-2024-45491 | 2.5.0-r1 | 2.6.3-r0 |
| libexpat | CVE-2024-45492 | 2.5.0-r1 | 2.6.3-r0 |
| libxml2 | CVE-2024-56171 | 2.11.6-r0 | 2.11.8-r1 |
The cells students fill in are left blank in this preview.
Check
Have a go
Check
3 questionsNow ask for high and critical together
docker exec scanner trivy image --input /targets/web-1.25.3.tar --severity HIGH,CRITICALShown here, not run. Press Start lab to type it into your own lab’s terminal.
A vector string says how a flaw works
A CVSS 3.1 vector string holds eight base metrics. Four say how an attack happens: attack vector (AV), attack complexity (AC), privileges required (PR) and user interaction (UI). Scope (S) says whether the attack reaches beyond the vulnerable part.
Three say what is lost: confidentiality (C), integrity (I) and availability (A). Each metric has a weight, and a formula turns them into the base score.
One vector string, read metric by metric
| Metric | Value | In words | Weight |
|---|---|---|---|
| AV | N | From anywhere on the network | 0.85 |
| AC | L | No special conditions | 0.77 |
| PR | N | No account needed | 0.85 |
| UI | N | Nobody has to click | 0.85 |
| S | U | Stays in the vulnerable part | - |
| C, I, A | N, N, H | Only availability is lost, fully | 0, 0, 0.56 |
The cells students fill in are left blank in this preview.
Try it: a CVSS 3.1 base score
AV = {"N": 0.85, "A": 0.62, "L": 0.55, "P": 0.2}
AC = {"L": 0.77, "H": 0.44}
CIA = {"H": 0.56, "L": 0.22, "N": 0}
# Scope unchanged, no privileges and no user action needed.
av, ac = "N", "L"
c, i, a = "N", "N", "H"
pr, ui = 0.85, 0.85
iss = 1 - (1 - CIA[c]) * (1 - CIA[i]) * (1 - CIA[a])
impact = 6.42 * iss
exploitability = 8.22 * AV[av] * AC[ac] * pr * ui
score = min(impact + exploitability, 10)
print("impact", round(impact, 2), "exploitability", round(exploitability, 2))
print("base score, before rounding up", round(score, 3))
# Change ac to "H". The score should become 5.9 once rounded up.
Make a free account to save your work and track your progress.
Check
Have a go
Check
3 questionsOne flaw, two scores
NVD scores a flaw for the software in general. A Linux distribution may score it again for its own build, because its settings differ. Trivy keeps every source it knows.
In this snapshot, CVE-2024-45492 scores 9.8 from NVD, reachable over the network. Red Hat scores it 6.2, reachable only locally. Both are base scores, and neither knows your server.
Write the helper that reads reports, part 1
docker exec tools sh -c "printf '%s\n' 'import csv' 'import gzip' 'import json' '' 'EPSS_FILE = \"/work/snapshot/epss-2026-11-20.csv.gz\"' 'KEV_FILE = \"/work/snapshot/kev-2026-11-20.json\"' '' 'def findings(name):' ' with open(\"/work/reports/\" + name + \".json\") as f:' ' report = json.load(f)' ' rows = []' ' for result in report.get(\"Results\", []):' ' rows = rows + (result.get(\"Vulnerabilities\") or [])' ' return rows' '' 'def cve_list(rows):' ' cves = []' ' for v in rows:' ' if v[\"VulnerabilityID\"] not in cves:' ' cves.append(v[\"VulnerabilityID\"])' > steps/snap.py"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the helper that reads reports, part 2
docker exec tools sh -c "printf '%s\n' ' return cves' '' 'def epss(wanted):' ' scores = {}' ' with gzip.open(EPSS_FILE, \"rt\") as f:' ' for row in csv.reader(f):' ' if row[0] in wanted:' ' scores[row[0]] = [float(row[1]), float(row[2])]' ' return scores' '' 'def kev():' ' with open(KEV_FILE) as f:' ' catalogue = json.load(f)' ' return {v[\"cveID\"]: v for v in catalogue[\"vulnerabilities\"]}' '' 'def nvd(v):' ' return v.get(\"CVSS\", {}).get(\"nvd\", {}).get(\"V3Score\")' >> steps/snap.py"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Save the old image's scan as JSON
docker exec scanner trivy image --input /targets/web-1.25.3.tar --format json -o /work/reports/web.jsonShown here, not run. Press Start lab to type it into your own lab’s terminal.
Write the script that compares sources
docker exec tools sh -c "printf '%s\n' 'import snap' '' 'WANTED = [\"CVE-2024-6119\", \"CVE-2024-45492\", \"CVE-2024-56171\"]' 'seen = []' 'for v in snap.findings(\"web\"):' ' cve = v[\"VulnerabilityID\"]' ' if cve in WANTED and cve not in seen:' ' seen.append(cve)' ' print(cve, v[\"PkgName\"], v[\"Severity\"])' ' for source in [\"nvd\", \"redhat\"]:' ' score = v[\"CVSS\"][source]' ' print(\" \", source, score[\"V3Score\"], score[\"V3Vector\"])' > steps/sources.py"Shown here, not run. Press Start lab to type it into your own lab’s terminal.
Compare NVD and Red Hat scores
docker exec tools python3 steps/sources.pyShown here, not run. Press Start lab to type it into your own lab’s terminal.
What sources.py printed
| CVE | Package | NVD | Red Hat | What differs |
|---|---|---|---|---|
| CVE-2024-6119 | libcrypto3 | 7.5 | 5.9 | AC:L against AC:H |
| CVE-2024-45492 | libexpat | 9.8 | 6.2 | AV:N against AV:L, and C and I |
| CVE-2024-56171 | libxml2 | 9.8 | 8.1 | AV, AC and scope |
The cells students fill in are left blank in this preview.
A common mistake
Warning
Many people think a base score of 9.8 means an attack is likely. The base score measures how bad the flaw is if it is used. It says nothing about whether anyone is using it, which lesson 2 measures.
Check
Have a go
Check
3 questionsAssignment: a CVSS calculator
Write a CVSS 3.1 base score calculator. WEIGHTS holds the weights of attack vector, attack complexity, user interaction and the three impacts.
parse_vector(text) returns a dictionary of the eight metrics, such as {"AV": "N", ...}. roundup(x) rounds up to one decimal place: multiply by 100000 and round; if that is a whole multiple of 10000 divide it by 100000, otherwise take the next tenth up.
base_score(text) follows the formula. Privileges are 0.85 for N, 0.62 for L and 0.27 for H, or 0.68 and 0.5 when scope is changed. The impact sub-score is 1 minus the product of (1 minus each of C, I and A). Impact is 6.42 times it, or with scope changed 7.52 times (it minus 0.029) minus 3.25 times (it minus 0.02) to the power 15. Exploitability is 8.22 times AV, AC, PR and UI. An impact of 0 or less scores 0. Otherwise round up the smaller of 10 and impact plus exploitability, multiplying the sum by 1.08 first when scope is changed.
import math
WEIGHTS = {
"AV": {"N": 0.85, "A": 0.62, "L": 0.55, "P": 0.2},
"AC": {"L": 0.77, "H": 0.44},
"UI": {"N": 0.85, "R": 0.62},
"CIA": {"H": 0.56, "L": 0.22, "N": 0},
}
def parse_vector(text):
return {}
def roundup(x):
return 0
def base_score(text):
return 0
Make a free account to save your work and track your progress.
Exit quiz
Have a go