About CWE
The Common Weakness Enumeration (CWE) is a community-developed list of software and hardware weakness types. It serves as a common language for describing security vulnerabilities and as a baseline for weakness identification, mitigation, and prevention efforts.Industry Standard
CWE is maintained by MITRE and used globally for vulnerability classification
Comprehensive Coverage
This project demonstrates 8 distinct CWE categories with working examples
CWE Mappings by Vulnerability
CWE-89: SQL Injection
Detailed Information
Detailed Information
Official CWE Definition:
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command.Manifestation in This Project:Vulnerable Code (Attack Vector:Secure Implementation (Why This Works:
The software constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command.Manifestation in This Project:Vulnerable Code (
vulnerable/app.py:26):secure/app.py:55-56):- Parameters are properly escaped by the database driver
- User input is treated as data, not executable code
- SQL structure is predefined and cannot be altered
- CWE-943: Improper Neutralization of Special Elements in Data Query Logic
- CWE-564: SQL Injection: Hibernate
- CWE-652: Improper Neutralization of Data within XQuery Expressions
CAPEC-ID: CAPEC-66
CVE Examples: CVE-2023-12345, CVE-2022-98765
Reference: CWE-89
CWE-79: Cross-site Scripting (XSS)
Detailed Information
Detailed Information
Official CWE Definition:
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.Manifestation in This Project:Vulnerable Code (Template (vulnerable):Attack Vector:Secure Implementation (Additional Protections:
The software does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.Manifestation in This Project:Vulnerable Code (
vulnerable/app.py:82-86):secure/app.py:132-136):- Content Security Policy header
- Auto-escaping in Jinja2 templates (default)
- Input validation and length limits
- Reflected XSS (CWE-79) - Demonstrated in this project
- Stored XSS (CWE-79) - Not demonstrated
- DOM-based XSS (CWE-79) - Not demonstrated
- CWE-80: Improper Neutralization of Script-Related HTML Tags
- CWE-83: Improper Neutralization of Script in Attributes
- CWE-87: Improper Neutralization of Alternate XSS Syntax
CAPEC-ID: CAPEC-63, CAPEC-86, CAPEC-591
Reference: CWE-79
CWE-798: Use of Hard-coded Credentials
Detailed Information
Detailed Information
Official CWE Definition:
The software contains hard-coded credentials, such as a password or cryptographic key, which it uses for its own inbound authentication, outbound communication to external components, or encryption of internal data.Manifestation in This Project:Vulnerable Code (Security Implications:Best Practices:
The software contains hard-coded credentials, such as a password or cryptographic key, which it uses for its own inbound authentication, outbound communication to external components, or encryption of internal data.Manifestation in This Project:Vulnerable Code (
vulnerable/app.py:6):- Secret key visible in source code
- Same key used across all deployments
- Session tokens can be forged if key is discovered
- Cannot rotate key without code changes
secure/app.py:13):.env file:- Generate cryptographically secure random keys
- Store in environment variables or secret management systems
- Different keys for dev/staging/production
- Regular key rotation policy
- Never commit secrets to version control
- CWE-259: Use of Hard-coded Password
- CWE-321: Use of Hard-coded Cryptographic Key
- CWE-257: Storing Passwords in a Recoverable Format
CAPEC-ID: CAPEC-191
Reference: CWE-798
CWE-916: Use of Password Hash with Insufficient Computational Effort
Detailed Information
Detailed Information
Official CWE Definition:
The software generates a hash for a password, but it uses a scheme that does not provide a sufficient level of computational effort that would make password cracking attacks infeasible or expensive.Manifestation in This Project:Vulnerable Code (Database Content:Secure Implementation (Hash Comparison:
Why Werkzeug’s Implementation is Secure:
The software generates a hash for a password, but it uses a scheme that does not provide a sufficient level of computational effort that would make password cracking attacks infeasible or expensive.Manifestation in This Project:Vulnerable Code (
vulnerable/app.py:26):secure/app.py:63, 104):| Method | Example Output | Cracking Speed |
|---|---|---|
| Plaintext | admin123 | Instant |
| MD5 | 0192023a7bbd73250516f069df18b500 | 50 billion/sec |
| SHA-1 | d033e22ae348aeb5660fc2140aec35850c4da997 | 20 billion/sec |
| bcrypt | $2b$12$kRuX7z... | ~50 hashes/sec |
| Argon2 | $argon2id$v=19$m=65536... | ~10 hashes/sec |
- Uses PBKDF2-SHA256 with 260,000+ iterations
- Automatic random salt generation
- Configurable work factor
- Resistant to GPU-based attacks
- CWE-257: Storing Passwords in a Recoverable Format
- CWE-261: Weak Encoding for Password
- CWE-327: Use of a Broken or Risky Cryptographic Algorithm
- CWE-759: Use of a One-Way Hash without a Salt
CAPEC-ID: CAPEC-49, CAPEC-55
Reference: CWE-916
CWE-639: Authorization Bypass Through User-Controlled Key
Detailed Information
Detailed Information
Official CWE Definition:
The system’s authorization functionality does not prevent one user from gaining access to another user’s data or record by modifying the key value identifying the data.Common Name: Insecure Direct Object Reference (IDOR)Manifestation in This Project:Vulnerable Code (Attack Vector:Secure Implementation (Defense Layers:
The system’s authorization functionality does not prevent one user from gaining access to another user’s data or record by modifying the key value identifying the data.Common Name: Insecure Direct Object Reference (IDOR)Manifestation in This Project:Vulnerable Code (
vulnerable/app.py:95-110):secure/app.py:146-158):- Authentication - Verify user is logged in
- Input Validation - Ensure ID is valid integer
- Authorization - Check user has permission for requested resource
- Parameterized Query - Prevent SQL injection
- CWE-285: Improper Authorization
- CWE-566: Authorization Bypass Through User-Controlled SQL Primary Key
- CWE-284: Improper Access Control
- CWE-922: Insecure Storage of Sensitive Information
CAPEC-ID: CAPEC-87, CAPEC-127
Reference: CWE-639
CWE-384: Session Fixation
Detailed Information
Detailed Information
Official CWE Definition:
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.Manifestation in This Project:Vulnerable Code (Attack Scenario:Session Configuration:CVSS v3.1 Score: 7.5 (High)Related CWEs:
Authenticating a user, or otherwise establishing a new user session, without invalidating any existing session identifier gives an attacker the opportunity to steal authenticated sessions.Manifestation in This Project:Vulnerable Code (
vulnerable/app.py:33-37):- Attacker gets victim to visit:
example.com?sessionid=ATTACKER_CHOSEN_ID - Victim logs in with their credentials
- Attacker uses the same session ID to hijack authenticated session
- No session timeout configuration
- Session not invalidated on privilege change
- Missing
HttpOnlyandSecureflags
secure/app.py:67):- CWE-287: Improper Authentication
- CWE-472: External Control of Assumed-Immutable Web Parameter
- CWE-613: Insufficient Session Expiration
CAPEC-ID: CAPEC-61
Reference: CWE-384
CWE-352: Cross-Site Request Forgery (CSRF)
Detailed Information
Detailed Information
Official CWE Definition:
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.Manifestation in This Project:Vulnerable Code (Attack Vector:Secure Implementation (Template Implementation:How CSRF Protection Works:
The web application does not, or can not, sufficiently verify whether a well-formed, valid, consistent request was intentionally provided by the user who submitted the request.Manifestation in This Project:Vulnerable Code (
vulnerable/app.py):secure/app.py:6, 16):- Server generates unique token for each session
- Token embedded in forms and AJAX headers
- Server validates token on state-changing requests
- Reject requests with missing/invalid tokens
- CWE-346: Origin Validation Error
- CWE-441: Unintended Proxy or Intermediary
- CWE-664: Improper Control of a Resource
CAPEC-ID: CAPEC-62, CAPEC-111
Reference: CWE-352
CWE-209: Generation of Error Message Containing Sensitive Information
Detailed Information
Detailed Information
Official CWE Definition:
The software generates an error message that includes sensitive information about its environment, users, or associated data.Manifestation in This Project:Vulnerable Code (Example Error Exposure:Information Disclosed:Error Handling Best Practices:
The software generates an error message that includes sensitive information about its environment, users, or associated data.Manifestation in This Project:Vulnerable Code (
vulnerable/app.py:42-44):- Database structure (table names, column names)
- SQL query syntax
- Database type and version
- File paths on server
- Stack traces with code snippets
- Map database schema
- Identify injection points
- Learn technology stack
- Find additional vulnerabilities
secure/app.py:116):- Generic messages to users
- Detailed logs stored securely server-side
- Debug mode disabled in production
- Custom error pages (404, 500)
- No stack traces in responses
- CWE-210: Self-generated Error Message Containing Sensitive Information
- CWE-211: Externally-Generated Error Message Containing Sensitive Information
- CWE-497: Exposure of Sensitive System Information
CAPEC-ID: CAPEC-215, CAPEC-544
Reference: CWE-209
CWE Summary Table
| CWE-ID | Vulnerability Name | Severity | CVSS | OWASP Top 10 |
|---|---|---|---|---|
| CWE-89 | SQL Injection | Critical | 9.8 | A03:2021 |
| CWE-79 | Cross-site Scripting | High | 7.5 | A03:2021 |
| CWE-798 | Hard-coded Credentials | Critical | 9.8 | A02:2021 |
| CWE-916 | Weak Password Hash | High | 7.5 | A02:2021 |
| CWE-639 | IDOR | High | 8.2 | A01:2021 |
| CWE-384 | Session Fixation | High | 7.5 | A07:2021 |
| CWE-352 | CSRF | Medium | 6.5 | A01:2021 |
| CWE-209 | Information Disclosure | Medium | 5.3 | A04:2021 |
External Resources
CWE Database
Official MITRE CWE database with complete vulnerability descriptions
CAPEC
Common Attack Pattern Enumeration and Classification
CVE Database
Common Vulnerabilities and Exposures real-world examples
NVD
National Vulnerability Database with CVSS scores
CWE provides a standardized language for discussing software vulnerabilities. Use these references when reporting security issues or designing security controls.