CVE, CWE, CPE and the NVD
A scan says OpenSSH 8.9p1 Ubuntu 3ubuntu0.10. To decide whether that is a problem, a tester needs the public record of known vulnerabilities, a way to name products precisely enough to search it, and a vocabulary for kinds of weakness. Those are three different systems with confusingly similar acronyms: CVE names individual vulnerabilities, CPE names products and versions, CWE names weakness types. The NVD joins them together. This lesson explains each, matches an inventory against a small vulnerability feed in Python, and shows where the matching goes wrong.
The four systems
| What it identifies | Example | Maintained by | |
|---|---|---|---|
| CVE (Common Vulnerabilities and Exposures) | one specific vulnerability in specific software | CVE-2024-6387 (a race condition in OpenSSH's server) |
the CVE Program (MITRE as Secretariat, with hundreds of CVE Numbering Authorities such as vendors and CERTs that assign IDs) |
| CWE (Common Weakness Enumeration) | a type of weakness, independent of product | CWE-22 path traversal, CWE-89 SQL injection, CWE-79 XSS |
MITRE, with a yearly "Top 25 Most Dangerous Software Weaknesses" list |
| CPE (Common Platform Enumeration) | a product and version, as a structured name | cpe:2.3:a:openbsd:openssh:8.9:p1:*:*:*:*:*:* |
NIST, in the NVD's CPE dictionary |
| NVD (National Vulnerability Database) | enriches CVE records with CVSS scores, CWE and CPE applicability | the NVD page for a CVE | NIST |
A CVE record contains a description, references (advisories, patches) and, increasingly, data from the CNA itself (affected versions, CVSS, CWE). The NVD adds its own analysis; since 2024 its analysis has lagged behind the flow of new CVEs, so many records carry only the CNA's data for a while. Vendor advisories and distribution security trackers (Debian, Ubuntu, Red Hat) are usually the most precise source for which package versions are affected.
The ID format is CVE-<year>-<sequence>, where the year is when the ID was reserved (not when the bug was found or published) and the sequence has four or more digits.
Matching an inventory against a feed
The core of every vulnerability scanner is a matcher: product and version from the inventory, against affected version ranges from the feed. The feed below has real CVE identifiers with their affected upstream ranges, simplified; the inventory is the lab's.
import re
def ver(s):
"""'8.9p1' -> (8, 9, 1); '2.4.49' -> (2, 4, 49); upstream versions only."""
return tuple(int(x) for x in re.findall(r"\d+", s))
FEED = [ # (cve, product, affected ranges [start, end), cwe, summary)
("CVE-2024-6387", "openssh", [("0", "4.4p1"), ("8.5p1", "9.8p1")], "CWE-364",
"signal handler race in sshd (regreSSHion), glibc-based Linux"),
("CVE-2021-41773", "apache_http_server", [("2.4.49", "2.4.50")], "CWE-22",
"path traversal in 2.4.49"),
("CVE-2011-2523", "vsftpd", [("2.3.4", "2.3.5")], "CWE-506",
"backdoored 2.3.4 source archive distributed in 2011"),
]
inventory = [ # host, product, upstream version, distribution package (if known)
("www", "openssh", "8.9p1", "1:8.9p1-3ubuntu0.10"),
("legacy01", "openssh", "4.7p1", "1:4.7p1-8ubuntu1"),
("legacy01", "vsftpd", "2.3.4", None),
("legacy01", "apache_http_server", "2.2.8", None),
("web02", "apache_http_server", "2.4.49", None),
]
for host, product, v, pkg in inventory:
hits = []
for cve, prod, ranges, cwe, summary in FEED:
if prod == product and any(ver(lo) <= ver(v) < ver(hi) for lo, hi in ranges):
hits.append(f"{cve} ({cwe})")
tag = f" [package {pkg}]" if pkg else ""
print(f"{host:<9} {product} {v}{tag}: {', '.join(hits) or 'no match in feed'}")www openssh 8.9p1 [package 1:8.9p1-3ubuntu0.10]: CVE-2024-6387 (CWE-364)
legacy01 openssh 4.7p1 [package 1:4.7p1-8ubuntu1]: no match in feed
legacy01 vsftpd 2.3.4: CVE-2011-2523 (CWE-506)
legacy01 apache_http_server 2.2.8: no match in feed
web02 apache_http_server 2.4.49: CVE-2021-41773 (CWE-22)
Three of five rows match, and every match is a candidate, not a finding:
wwwOpenSSH 8.9p1 is inside the upstream range of CVE-2024-6387. But the host runs Ubuntu's package1:8.9p1-3ubuntu0.10, and Ubuntu's security notice for this CVE lists that exact package revision as the fix for Ubuntu 22.04: the upstream version number was kept and the patch backported. A version matcher that ignores the distribution reports a false positive; the triage lesson compares package versions properly.legacy01vsftpd 2.3.4 matches CVE-2011-2523 (the feed uses CWE-506 for the backdoor itself; the NVD record lists CWE-78, OS command injection, for what it does). Here the version string is not even the issue: only copies built from the tampered archive contain the backdoor, and the service-scan lesson showed that a banner can claim 2.3.4 without any vsftpd behind it. Safe validation decides.web02Apache 2.4.49 matches CVE-2021-41773, whose exploitability also depends on configuration (the defaultRequire all deniedon the file system blocks the traversal to files outside the document root). Again: candidate.legacy01OpenSSH 4.7p1 and Apache 2.2.8 match nothing in this tiny feed. With the full feed they would match many entries: both are long out of support. "End of life" is a finding in itself, whatever the CVE list says.
CWE in reports
CWE gives each finding a stable type, which is what clients aggregate across tests ("we keep having CWE-639 authorization bypass through user-controlled key; train the API team"). Use the most specific CWE that fits: CWE-89 rather than its parent CWE-74 injection. The OWASP Top 10 2025 lesson maps CWEs to Top 10 categories for web findings.
How unknown-vulnerable software is detected
Defenders run the same matching continuously: authenticated scanners and endpoint agents read installed package versions (not banners) and compare them with vendor advisories; SBOMs list library versions inside applications; and feeds such as the NVD, vendor advisories and the CISA KEV catalog are pulled daily. Package-level data is far more accurate than a network banner, which is why credentialed scans produce fewer false positives.
How it is fixed
Update to a fixed version from the vendor or distribution; where that is impossible, apply the vendor's documented mitigation (a configuration change, disabling a module) and record it; and for end-of-life software, plan replacement, because no future CVE will be fixed. The retest then checks the package version or the mitigation, not the banner.
Pitfalls
- Upstream version ≠ package version. Distributions backport. Compare against the distribution's tracker.
- Banner ≠ installed version. Proxies, fakes and custom builds mislead.
- CVE count as a measure of risk. One exploited CVE on an Internet-facing host matters more than fifty theoretical ones on an isolated test box.
- Citing the NVD score as the severity. It is a base score with no knowledge of the client's context; see CVSS and prioritisation.
Practice
- Add
("files02", "openssh", "9.8p1", None)and("bastion", "openssh", "4.3p2", None)to the inventory. Which match, and why? - Which CWE would you give to (a) an API that returns another customer's invoice when the id is changed, (b) a password stored in a file in the web root, (c) the vsftpd backdoor?
Answers
9.8p1is the fixed upstream release (the range ends before it): no match.4.3p2is below4.4p1, in the old range of the same bug (the regression reintroduced a flaw fixed in 2006): match.- (a) CWE-639 Authorization Bypass Through User-Controlled Key; (b) CWE-538 Insertion of Sensitive Information into Externally-Accessible File or Directory (or CWE-256 for plaintext storage of a password); (c) CWE-506 Embedded Malicious Code, the class this lesson's feed uses. Databases sometimes classify a CVE differently (the NVD gives CWE-78 for CVE-2011-2523, and CWE-362 where the assigning CNA, Red Hat, gave CWE-364 for CVE-2024-6387); cite the CWE you can justify and say so.
Test yourself
Which system names a type of weakness rather than a specific vulnerability?
- CVE
- CWE
- CPE
- CVSS
Ubuntu's OpenSSH package 1:8.9p1-3ubuntu0.10 is inside the upstream range of CVE-2024-6387. Is the host vulnerable?
- Yes, the upstream version matches
- Not necessarily: Ubuntu backported the fix into that package revision; check the distribution's notice
- No, Ubuntu is never affected
- Only if the banner says so
What does the year in CVE-2011-2523 indicate?
- The year the bug was introduced
- The year the ID was reserved
- The year it was fixed
- The CVSS version
Who usually gives the most precise list of affected package versions for a Linux server?
- The NVD's CPE match alone
- The distribution's security tracker or advisory
- A port scanner
- The CVE ID