← CodeClarityLab Home
Browse by Category
+ added · updated 7d
← Back to glossary

CWE

security Beginner
debt(d5/e3/b3/t5)
d5 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'specialist tool catches' (d5). The term's detection_hints.tools lists semgrep, checkmarx, and sonarqube — these are specialist SAST tools that can flag security fixes without documented CWE references or missing vulnerability taxonomy. Not caught by default linters, but automated tooling can detect the absence of CWE classification in security-related code changes.

e3 Effort Remediation debt — work required to fix once spotted

Closest to 'simple parameterised fix' (e3). The quick_fix indicates adding CWE IDs to code comments and bug trackers — this is slightly more than a one-line patch since it requires identifying the correct CWE classification and updating documentation/tracking systems, but it's a straightforward pattern application within a single component or ticket.

b3 Burden Structural debt — long-term weight of choosing wrong

Closest to 'localised tax' (b3). CWE is a classification standard that applies to web and cli contexts per applies_to. The burden falls primarily on security documentation and vulnerability management workflows — it's not load-bearing across the entire codebase architecture, but teams that don't adopt consistent CWE usage pay a localized tax in vulnerability communication and tooling integration.

t5 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'notable trap' (t5). The misconception field explicitly states that developers confuse CWE (weakness class) with CVE (specific vulnerability instance). Common_mistakes reinforce this: using generic CWE-20 instead of specific child CWEs, and confusing CWE with CVE. This is a documented gotcha that most security-aware developers eventually learn, but the distinction is not obvious from the names alone.

About DEBT scoring →

Also Known As

Common Weakness Enumeration CWE ID weakness class

TL;DR

Common Weakness Enumeration — a community-maintained list of software weakness types with unique numeric IDs.

Explanation

CWE is maintained by MITRE and provides a standardised taxonomy of software and hardware weaknesses. Each weakness has a unique identifier (e.g. CWE-89 for SQL Injection) with a detailed description, extended description, demonstrative examples, and mitigations. CWEs describe the type of weakness, while CVEs describe specific vulnerability instances in real software. PHP Clarity Lab maps each detected issue to its CWE for precise classification.

Common Misconception

CWE and CVE are the same thing. CWE describes a class of weakness (e.g. CWE-89: SQL Injection) while CVE identifies a specific vulnerability instance in a specific product.

Why It Matters

CWE classifications enable consistent vulnerability communication, trending analysis, and tool integration — without a shared taxonomy, 'injection bug' means different things to different teams.

Common Mistakes

  • Mapping all injection vulnerabilities to the generic CWE-20 (Improper Input Validation) instead of specific child CWEs like CWE-89 (SQL) or CWE-79 (XSS).
  • Not including CWE IDs in vulnerability reports, making historical trending and tooling correlation impossible.
  • Confusing CWE (weakness type classification) with CVE (specific vulnerability instance).
  • Using top-level abstract CWEs that do not map to actionable fixes — use the most specific applicable CWE.

Code Examples

✗ Vulnerable
// Vulnerability report with no CWE — no actionable classification:
[
  'title' => 'User input not sanitised',
  'severity' => 'High',
  // Missing: 'cwe' => 'CWE-89', 'owasp' => 'A03:2021'
]
✓ Fixed
# Common Weakness Enumeration — key CWEs for PHP apps

# CWE-89  SQL Injection       — use prepared statements
# CWE-79  XSS                 — htmlspecialchars() on output
# CWE-22  Path Traversal      — realpath() + prefix check
# CWE-78  OS Command Injection — escapeshellarg() or proc_open array
# CWE-352 CSRF                — CSRF token + SameSite cookie
# CWE-434 Unrestricted Upload — finfo MIME check + random filename
# CWE-502 Insecure Deserialise— use JSON, not unserialize()
# CWE-798 Hard-coded Creds    — use environment variables
# CWE-611 XXE                 — LIBXML_NONET | LIBXML_NOENT
# CWE-918 SSRF                — allowlist outbound URLs

// Reference in docblocks:
/** @security CWE-89 — parameterised query, no string concat */
function findUser(int \$id): ?array {
    \$stmt = \$pdo->prepare('SELECT * FROM users WHERE id = ?');
    \$stmt->execute([\$id]);
    return \$stmt->fetch() ?: null;
}

Added 15 Mar 2026
Edited 22 Mar 2026
Views 29
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
0 pings F 0 pings S 0 pings S 1 ping M 0 pings T 0 pings W 0 pings T 0 pings F 1 ping S 1 ping S 0 pings M 0 pings T 0 pings W 3 pings T 0 pings F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 1 ping F 1 ping S 0 pings S 0 pings M 0 pings T 0 pings W 0 pings T 0 pings F 1 ping S
No pings yesterday
Perplexity 9 Amazonbot 7 Google 3 Unknown AI 3 Ahrefs 2 ChatGPT 2
crawler 22 crawler_json 3 pre-tracking 1
DEV INTEL Tools & Severity
🔵 Info ⚙ Fix effort: Low
⚡ Quick Fix
Reference CWE IDs in your code comments and bug tracker when fixing security issues — it creates a searchable audit trail and helps static analysis tools correlate findings
📦 Applies To
any web cli
🔗 Prerequisites
🔍 Detection Hints
Security fixes without documented CWE reference; no structured vulnerability taxonomy in issue tracker
Auto-detectable: ✓ Yes semgrep checkmarx sonarqube
⚠ Related Problems
🤖 AI Agent
Confidence: Low False Positives: High ✗ Manual fix Fix: Medium Context: File

✓ schema.org compliant