Guides / Basics

CWE explained: weakness types behind CVEs

beginnerUpdated 26 Nov 2026758 words

A CVE ID names one vulnerability in one product. A CWE ID names the kind of mistake behind it, such as SQL injection (CWE-89) or a heap-based buffer overflow (CWE-122).

What CWE is

CWE (Common Weakness Enumeration) is a catalog of software and hardware weakness types maintained by MITRE. Each entry has an ID, a description, examples, typical consequences and ways to prevent it, and one of these abstraction levels:

Level What it covers
Pillar, Class broad types, such as CWE-664 (improper control of a resource through its lifetime)
Base specific enough to point at a fix, such as CWE-89 (SQL injection)
Variant a weakness tied to a language or technology

The catalog groups entries into views. The Research Concepts view (CWE-1000) is the full tree. The Software Development view (CWE-699) is organised for developers. CWE-1003 is a reduced view for mapping published vulnerabilities, used by the National Vulnerability Database.

CWE in CVE records

A CVE record lists its weakness types under "problem types". The CNA sets them, and the CISA ADP container may add one. Known Linux cases:

CVE CWE
CVE-2021-44228 Log4Shell CWE-502 Deserialization of Untrusted Data, plus CWE-400 and CWE-20
CVE-2024-3094 xz backdoor CWE-506 Embedded Malicious Code
CVE-2024-6387 regreSSHion CWE-364 Signal Handler Race Condition
CVE-2023-4911 Looney Tunables CWE-122 Heap-based Buffer Overflow
CVE-2014-0160 Heartbleed CWE-125 Out-of-bounds Read (added by CISA)
CVE-2014-6271 Shellshock CWE-78 OS Command Injection (added by CISA)

Older records often do not have a CWE from the CNA. The NVD uses two placeholders when it cannot map one: NVD-CWE-Other and NVD-CWE-noinfo.

Read the CWE of a record from the CVE List:

curl -s https://raw.githubusercontent.com/CVEProject/cvelistV5/main/cves/2023/4xxx/CVE-2023-4911.json \
  | jq -r '.containers.cna.problemTypes[].descriptions[] | "\(.cweId) \(.description)"'
CWE-122 Heap-based Buffer Overflow

The CWE Top 25

Every year MITRE publishes the "CWE Top 25 Most Dangerous Software Weaknesses". The 2025 list is ranked from the 39,080 CVE records published between 2024-06-01 and 2025-06-01. Its first ten entries:

Rank CWE Weakness CVEs in KEV
1 CWE-79 Cross-site scripting 7
2 CWE-89 SQL injection 4
3 CWE-352 Cross-site request forgery 0
4 CWE-862 Missing authorization 0
5 CWE-787 Out-of-bounds write 12
6 CWE-22 Path traversal 10
7 CWE-416 Use after free 14
8 CWE-125 Out-of-bounds read 3
9 CWE-78 OS command injection 20
10 CWE-94 Code injection 7

The score multiplies how often a weakness is mapped to a CVE in the NVD by the average CVSS score of those CVEs. OS command injection ranks 9th, but of all 25 entries it has the most CVEs on the KEV list. For a server owner, the KEV column is the more useful one.

How to use CWE

In your own code

For web applications, the Top 25 is a short checklist. Cross-site scripting, SQL injection, CSRF, missing authorization and path traversal are the first five web entries, and each CWE page lists ways to prevent them. Content-Security-Policy (HTTP security headers) limits the damage of cross-site scripting but does not fix it.

For findings on your servers

CWE says little about urgency. A CWE-787 out-of-bounds write can be a remote code execution in a TLS library or a crash in a file parser that never sees untrusted input. Rank by exploitation and exposure, and use the CWE to see what kind of fix to expect: a memory safety bug needs a new package, while a missing authorization check can sometimes be mitigated in a reverse proxy.

Mapping errors

People map CVEs to CWEs, and they make mistakes. Broad entries such as CWE-20 (improper input validation) say little. When the CWE and the description disagree, trust the description.

Look up any entry at https://cwe.mitre.org/data/definitions/<number>.html, for example CWE-79 at https://cwe.mitre.org/data/definitions/79.html.

Sources

Check your servers every day

The Vulnpocalypse agent reports the packages and settings of a server once a day, and the digest lists what to fix, most urgent first.

Start free