← All posts

STAYCHARTED BLOG · SECURITY · VULNERABILITY MANAGEMENT

How to map CVEs to CWE weakness types with machine learning

Suggest CWE weakness types from CVE descriptions after NVD’s enrichment change. Train on labeled examples, test on later CVEs and review uncertain mappings.

By Manoj Mohandas · · Updated

What changed at NVD in April 2026

NIST announced risk-based enrichment on April 15, 2026. It prioritizes CVEs in CISA's Known Exploited Vulnerabilities catalog, software used by the US federal government, and critical software as defined under Executive Order 14028.

All submitted CVEs remain listed. Lower-priority records are not scheduled for immediate enrichment, and users can request enrichment for NIST to consider as resources allow. Backlogged CVEs with an NVD publication date before March 1, 2026 moved to “Not Scheduled”; NIST may still consider those under its prioritization criteria. This is not a permanent ban on analyzing older CVEs.

NVD enrichment includes CWE, CVSS and CPE information. A CVE may already have a CWE supplied by its CVE Numbering Authority (CNA), even when NVD has not enriched it. Check the existing record before filling a missing mapping.

Three ways to fill the gap

Approach How it works Trade-off
Read each one An analyst reads the description and picks a CWE Uses analyst judgment; consistency and time depend on the reviewer
Ask a general AI assistant Paste the description, ask for a CWE Needs evaluation against your mapping rules; answers can vary between runs
Train a classifier Learn from CVEs that already have a CWE, suggest one for the rest with a confidence Uses a published model; check uncertain mappings and a sample of confident ones

How a trained classifier does it

  1. Training data. Take CVEs that already carry a CWE, from the CNA or from NVD's earlier analysis, or from your own team's mappings. The input is the description; the answer is the CWE.
  2. Choose the categories. The full CWE list is long, and most CVEs fall into a few dozen weaknesses. Train on the weaknesses that matter in your environment, such as the CWE Top 25, and put the rest in "Other".
  3. Train. The report shows accuracy for each CWE on CVEs it never saw.
  4. Fill new CVEs. Each one gets a suggested CWE and a confidence. Your analyst checks the unsure ones.
  5. Keep it current. CVEs your analysts correct become training examples for the next version. How review and retraining work →

Test on later CVEs, not a random sample. Train on CVEs published before a date and test on CVEs published after it. New products and new bug classes appear over time, and a random split hides that. Why to train on the past and test on the future →

StayCharted AI Model Trainer lets you upload the descriptions and labels, train an AI Classifier Model and fill new rows without code. The Review Queue is on Essentials and Business. Keep duplicate CVEs and closely related variants out of both sides of your evaluation split.

Your own mapping is worth more than a public one

If your team keeps its own weakness categories, such as "auth bypass in our API gateway" or the categories your secure-code training uses, train on those instead. The model learns your scheme, and your reports stay consistent across teams.

What it doesn't do

  • It reads the description, not the code. A vague description may not support a reliable CWE, even if the model is confident. Do not treat confidence as proof.
  • It doesn't replace NVD or the CNA. Treat a suggested CWE as your team's working classification until an authoritative one appears.
  • It doesn't score severity or exploitability. Use CVSS, EPSS and the KEV catalog for those.

A CWE suggestion must not automatically close a finding or downgrade its response. Keep known exploited and critical findings with an analyst, and update training examples when your mapping policy changes.

What we measured

We prepared 28,795 CVEs published from July 2024 to September 2025 that already had a CWE from their CNA, and tested two StayCharted models on 10,000 published from October 2025 to March 2026. They chose among the 2025 CWE Top 25 and "Other".

  • 81.4% right overall for the AI Classifier Model, 83.4% for the Dedicated AI Model, against 33.4% for always answering "Other".
  • 95.0% right on the 61.9% the AI Classifier was surest about (confidence 0.9 or higher).
  • The Dedicated model found more of the Top 25 (81.7% against 75.5%) and had a projected review share of 22.6%, versus 29.7%, to reach 95% accuracy, assuming every reviewed mistake is corrected.
  • Clear weaknesses are easy: cross-site scripting 96.7%, SQL injection 94.8% (AI Classifier). Broad ones are hard: incorrect authorization 22.7%, improper access control 27.0%.
  • Accuracy varies over time: the AI Classifier was 85.1% right on October 2025 CVEs and 76.8% on March 2026 ones. Check recent examples and evaluate retraining.

Full benchmark →

“Right” means agreement with the CNA label. Review shares are projections, not measured analyst performance. The test excluded CVEs missing a CNA label and does not measure remediation or ownership decisions.

Common questions

What is CVE to CWE mapping?

Assigning each vulnerability (CVE) the weakness type (CWE) it comes from, such as CWE-79 for cross-site scripting. It's how teams group vulnerabilities by root cause.

Does NVD still assign CWEs?

Yes, for prioritized CVEs. NIST’s April 2026 policy leaves lower-priority CVEs unscheduled for immediate enrichment; requests can be considered as resources allow. A CNA may already have supplied a CWE.

Can machine learning assign CWE IDs?

Yes, as a suggestion with a confidence. A model trained on CVEs that already have a CWE can suggest one for new CVEs from the description. Check the unsure ones.

How accurate is automated CWE classification?

On 10,000 later CVEs, StayCharted’s AI Classifier Model matched CNA labels on 81.4% and its Dedicated AI Model on 83.4%. Top 25 recall was 75.5% and 81.7%. Projected review shares to reach 95% accuracy were 29.7% and 22.6%, assuming every reviewed mistake is corrected. Missing-CWE records were not scored. Read the full benchmark.

Can I use my own weakness categories instead of CWE?

Yes. Train on whatever categories your team uses.

Sources and further reading

Put it into practice with StayCharted

Start free →

Check plans and allowances · Security and your data

CWE is a trademark of The MITRE Corporation.