cwe2
cwe2 is a CWE common weakness enumeration library for Python
What it is and what it does
cwe2 is a Python wrapper around the Common Weakness Enumeration (CWE) database maintained by MITRE. It bundles a vendored copy of the CWE data and exposes it through a simple query interface, letting you fetch weakness records by ID and access their structured attributes—name, description, related weaknesses, mitigation strategies, and more. The package is useful for security tools, vulnerability scanners, and code analysis systems that need to resolve CWE IDs to human-readable weakness information.
The library requires Python 3.7 or later and has minimal dependencies. It provides convenience methods to retrieve curated subsets like the top 25 CWEs, OWASP top ten 2021 weaknesses, and those used by the National Vulnerability Database (NVD). Maintenance is dormant but the package is stable and carries no known security vulnerabilities.
Use it for:
- Resolve CWE IDs in vulnerability reports to fetch full weakness descriptions and mitigation guidance.
- Build security dashboards or scanners that need to display MITRE CWE metadata alongside CVE findings.
- Analyze code or dependencies and map detected weakness categories to their MITRE definitions for compliance reporting.
- Query curated CWE lists like top 25 or OWASP top ten 2021 for security training or policy enforcement.
- Enrich vulnerability data pipelines with standardized CWE weakness context and related attack patterns.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
cwe2 provides programmatic access to the Common Weakness Enumeration (CWE) database, allowing you to look up vulnerability weakness categories by ID and retrieve their detailed attributes.
Yes, if you need to programmatically look up CWE weakness data in a Python application. The package is stable, has no known vulnerabilities, and low install friction. The main caveat is dormant maintenance—the vendored CWE data may lag behind MITRE's official updates, so verify the data freshness suits your use case before relying on it for critical security decisions.
Install
cwe2 on PyPI
pip
pip install cwe2uv
uv add cwe2poetry
poetry add cwe2Installing cwe2
Before you install
Low install friction with a single lightweight dependency (importlib-resources). Maintenance is dormant—last commit was 2024-08-29 and no releases in over a year, though the repository remains active and the package is marked Production/Stable.
License in practice
Dual-licensed under MIT and LicenseRef-scancode-cwe-tou. The CWE data itself carries MITRE's terms of use; permissive for code but you must respect MITRE's CWE usage terms when distributing or relying on the weakness data.
Quickstart
pip install cwe2
from cwe2.database import Database
db = Database()
weakness = db.get(15)
print(weakness.description)
Verify before relying
- Whether the vendored CWE data is kept current with MITRE's official CWE updates, given the dormant maintenance status.
- Performance characteristics when querying large numbers of weaknesses or iterating the full database.
Package facts
| License | MIT and LicenseRef-scancode-cwe-tou (permissive) |
| Python support | supports the current Python release (>=3.7) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — importlib-resources |
| Maintenance | dormant — 751 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 78,876/month — #14,400 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: cwe2-3.0.0-py3-none-any.whl
Keywords: utilities, CWE, weakness, CVE, vulnerabilities
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
nvdlibWrapper library for the NIST National…
permissive · top 15,000 on PyPI
cpeParses, compares, and evaluates Common Platform…
copyleft · top 15,000 on PyPI
flawfinderFlawfinder scans C/C++ source code to identify…
copyleft · top 15,000 on PyPI
safetySafety CLI scans Python project dependencies…
permissive · top 5,000 on PyPI
debsecan-mcpAn MCP server that scans Debian systems for…
unclear · top 15,000 on PyPI
pip-auditpip-audit scans Python environments and…
permissive · top 1,000 on PyPI
csaf-toolGenerates and analyzes CSAF 2.0 documents,…
permissive · top 15,000 on PyPI
amulet-leveldbProvides a Cython wrapper around Mojang's…
unclear · top 15,000 on PyPI
cloudsec-auditAudits AWS cloud security posture by checking…
permissive · top 15,000 on PyPI
spake2Implements SPAKE2, a password-authenticated key…
permissive · top 15,000 on PyPI