@neyugn/agent-kits 0.1.0
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.
- package/LICENSE +21 -0
- package/README.md +514 -0
- package/README.vi.md +410 -0
- package/README.zh.md +410 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +422 -0
- package/kits/coder/ARCHITECTURE.md +289 -0
- package/kits/coder/agents/ai-engineer.md +344 -0
- package/kits/coder/agents/backend-specialist.md +270 -0
- package/kits/coder/agents/cloud-architect.md +363 -0
- package/kits/coder/agents/code-reviewer.md +284 -0
- package/kits/coder/agents/data-engineer.md +401 -0
- package/kits/coder/agents/database-specialist.md +251 -0
- package/kits/coder/agents/debugger.md +209 -0
- package/kits/coder/agents/devops-engineer.md +281 -0
- package/kits/coder/agents/documentation-writer.md +296 -0
- package/kits/coder/agents/frontend-specialist.md +298 -0
- package/kits/coder/agents/i18n-specialist.md +348 -0
- package/kits/coder/agents/integration-specialist.md +314 -0
- package/kits/coder/agents/mobile-developer.md +271 -0
- package/kits/coder/agents/multi-tenant-architect.md +281 -0
- package/kits/coder/agents/orchestrator.md +263 -0
- package/kits/coder/agents/performance-analyst.md +327 -0
- package/kits/coder/agents/project-planner.md +277 -0
- package/kits/coder/agents/queue-specialist.md +282 -0
- package/kits/coder/agents/realtime-specialist.md +267 -0
- package/kits/coder/agents/security-auditor.md +253 -0
- package/kits/coder/agents/test-engineer.md +315 -0
- package/kits/coder/agents/ux-researcher.md +388 -0
- package/kits/coder/rules/.cursorrules +287 -0
- package/kits/coder/rules/CLAUDE.md +287 -0
- package/kits/coder/rules/CODEX.md +287 -0
- package/kits/coder/rules/GEMINI.md +287 -0
- package/kits/coder/scripts/checklist.py +318 -0
- package/kits/coder/scripts/kit_status.py +292 -0
- package/kits/coder/scripts/skills_manager.py +243 -0
- package/kits/coder/scripts/verify_all.py +391 -0
- package/kits/coder/skills/accessibility-patterns/SKILL.md +372 -0
- package/kits/coder/skills/accessibility-patterns/scripts/a11y_checker.py +211 -0
- package/kits/coder/skills/ai-rag-patterns/SKILL.md +444 -0
- package/kits/coder/skills/api-patterns/SKILL.md +316 -0
- package/kits/coder/skills/api-patterns/assets/.gitkeep +1 -0
- package/kits/coder/skills/api-patterns/references/deep-dive.md +21 -0
- package/kits/coder/skills/api-patterns/scripts/api_validator.py +253 -0
- package/kits/coder/skills/api-patterns/scripts/validate.py +56 -0
- package/kits/coder/skills/auth-patterns/SKILL.md +267 -0
- package/kits/coder/skills/aws-patterns/SKILL.md +576 -0
- package/kits/coder/skills/brainstorming/SKILL.md +370 -0
- package/kits/coder/skills/brainstorming/assets/.gitkeep +1 -0
- package/kits/coder/skills/brainstorming/references/deep-dive.md +21 -0
- package/kits/coder/skills/brainstorming/scripts/validate.py +56 -0
- package/kits/coder/skills/clean-code/SKILL.md +240 -0
- package/kits/coder/skills/clean-code/assets/.gitkeep +1 -0
- package/kits/coder/skills/clean-code/references/deep-dive.md +21 -0
- package/kits/coder/skills/clean-code/scripts/lint_runner.py +186 -0
- package/kits/coder/skills/clean-code/scripts/validate.py +56 -0
- package/kits/coder/skills/database-design/SKILL.md +255 -0
- package/kits/coder/skills/database-design/assets/.gitkeep +1 -0
- package/kits/coder/skills/database-design/references/deep-dive.md +21 -0
- package/kits/coder/skills/database-design/scripts/schema_validator.py +272 -0
- package/kits/coder/skills/database-design/scripts/validate.py +56 -0
- package/kits/coder/skills/docker-patterns/SKILL.md +240 -0
- package/kits/coder/skills/documentation-templates/SKILL.md +441 -0
- package/kits/coder/skills/e2e-testing/SKILL.md +457 -0
- package/kits/coder/skills/flutter-patterns/SKILL.md +330 -0
- package/kits/coder/skills/frontend-design/SKILL.md +127 -0
- package/kits/coder/skills/github-actions/SKILL.md +349 -0
- package/kits/coder/skills/gitlab-ci-patterns/SKILL.md +466 -0
- package/kits/coder/skills/graphql-patterns/SKILL.md +558 -0
- package/kits/coder/skills/i18n-localization/SKILL.md +345 -0
- package/kits/coder/skills/i18n-localization/scripts/i18n_checker.py +267 -0
- package/kits/coder/skills/kubernetes-patterns/SKILL.md +357 -0
- package/kits/coder/skills/mermaid-diagrams/SKILL.md +351 -0
- package/kits/coder/skills/mobile-design/SKILL.md +305 -0
- package/kits/coder/skills/monitoring-observability/SKILL.md +458 -0
- package/kits/coder/skills/multi-tenancy/SKILL.md +317 -0
- package/kits/coder/skills/multi-tenancy/assets/.gitkeep +1 -0
- package/kits/coder/skills/multi-tenancy/references/deep-dive.md +21 -0
- package/kits/coder/skills/multi-tenancy/scripts/validate.py +56 -0
- package/kits/coder/skills/nodejs-best-practices/SKILL.md +220 -0
- package/kits/coder/skills/performance-profiling/SKILL.md +333 -0
- package/kits/coder/skills/performance-profiling/assets/.gitkeep +1 -0
- package/kits/coder/skills/performance-profiling/references/deep-dive.md +21 -0
- package/kits/coder/skills/performance-profiling/scripts/validate.py +56 -0
- package/kits/coder/skills/plan-writing/SKILL.md +360 -0
- package/kits/coder/skills/plan-writing/assets/.gitkeep +1 -0
- package/kits/coder/skills/plan-writing/references/deep-dive.md +21 -0
- package/kits/coder/skills/plan-writing/scripts/validate.py +56 -0
- package/kits/coder/skills/postgres-patterns/SKILL.md +361 -0
- package/kits/coder/skills/prompt-engineering/SKILL.md +277 -0
- package/kits/coder/skills/queue-patterns/SKILL.md +359 -0
- package/kits/coder/skills/queue-patterns/assets/.gitkeep +1 -0
- package/kits/coder/skills/queue-patterns/references/deep-dive.md +21 -0
- package/kits/coder/skills/queue-patterns/scripts/validate.py +56 -0
- package/kits/coder/skills/react-native-patterns/SKILL.md +393 -0
- package/kits/coder/skills/react-patterns/SKILL.md +319 -0
- package/kits/coder/skills/realtime-patterns/SKILL.md +506 -0
- package/kits/coder/skills/realtime-patterns/assets/.gitkeep +1 -0
- package/kits/coder/skills/realtime-patterns/references/deep-dive.md +21 -0
- package/kits/coder/skills/realtime-patterns/scripts/validate.py +56 -0
- package/kits/coder/skills/redis-patterns/SKILL.md +484 -0
- package/kits/coder/skills/security-fundamentals/SKILL.md +363 -0
- package/kits/coder/skills/security-fundamentals/assets/.gitkeep +1 -0
- package/kits/coder/skills/security-fundamentals/references/deep-dive.md +21 -0
- package/kits/coder/skills/security-fundamentals/scripts/security_scan.py +326 -0
- package/kits/coder/skills/security-fundamentals/scripts/validate.py +56 -0
- package/kits/coder/skills/seo-patterns/SKILL.md +262 -0
- package/kits/coder/skills/seo-patterns/scripts/seo_checker.py +211 -0
- package/kits/coder/skills/systematic-debugging/SKILL.md +478 -0
- package/kits/coder/skills/systematic-debugging/assets/.gitkeep +1 -0
- package/kits/coder/skills/systematic-debugging/references/deep-dive.md +21 -0
- package/kits/coder/skills/systematic-debugging/scripts/validate.py +56 -0
- package/kits/coder/skills/tailwind-patterns/SKILL.md +395 -0
- package/kits/coder/skills/terraform-patterns/SKILL.md +470 -0
- package/kits/coder/skills/testing-patterns/SKILL.md +285 -0
- package/kits/coder/skills/testing-patterns/assets/.gitkeep +1 -0
- package/kits/coder/skills/testing-patterns/references/deep-dive.md +21 -0
- package/kits/coder/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/kits/coder/skills/testing-patterns/scripts/validate.py +56 -0
- package/kits/coder/skills/typescript-patterns/SKILL.md +417 -0
- package/kits/coder/skills/ui-ux-pro-max/SKILL.md +364 -0
- package/kits/coder/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/kits/coder/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/kits/coder/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/kits/coder/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/kits/coder/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/kits/coder/skills/ui-ux-pro-max/data/prompts.csv +24 -0
- package/kits/coder/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/kits/coder/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/kits/coder/skills/ui-ux-pro-max/data/styles.csv +59 -0
- package/kits/coder/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/kits/coder/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/kits/coder/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/kits/coder/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/__pycache__/core.cpython-314.pyc +0 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/__pycache__/design_system.cpython-314.pyc +0 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/core.py +257 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/design_system.py +488 -0
- package/kits/coder/skills/ui-ux-pro-max/scripts/search.py +76 -0
- package/kits/coder/workflows/.gitkeep +20 -0
- package/kits/coder/workflows/create.md +152 -0
- package/kits/coder/workflows/debug.md +223 -0
- package/kits/coder/workflows/deploy.md +283 -0
- package/kits/coder/workflows/orchestrate.md +243 -0
- package/kits/coder/workflows/plan.md +134 -0
- package/kits/coder/workflows/test.md +237 -0
- package/kits/coder/workflows/ui-ux-pro-max.md +109 -0
- package/package.json +49 -0
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: security-fundamentals
|
|
3
|
+
description: Security coding principles and decision-making. Use when reviewing code for vulnerabilities, implementing validation/sanitization, designing authentication, or analyzing threats. Covers OWASP 2025, input handling, secure architecture patterns.
|
|
4
|
+
allowed-tools: Read, Edit, Glob, Grep
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Security Fundamentals - Thinking Like an Attacker
|
|
8
|
+
|
|
9
|
+
> **Philosophy:** Security is a mindset, not a checklist. Every line of code should assume input is hostile.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 🎯 Core Principle: Zero Trust
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
❌ WRONG: "This input comes from our backend, so it's safe"
|
|
17
|
+
✅ CORRECT: "All input is untrusted until explicitly validated"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Every data source is potentially compromised:
|
|
21
|
+
|
|
22
|
+
- User forms → Direct attack vector
|
|
23
|
+
- API responses → Server could be compromised
|
|
24
|
+
- Database reads → Data could be poisoned
|
|
25
|
+
- File uploads → Executable content
|
|
26
|
+
- Environment variables → Misconfiguration
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 🔒 Security Decision Framework
|
|
31
|
+
|
|
32
|
+
### When to Apply Security Measures
|
|
33
|
+
|
|
34
|
+
| Data Type | Validation | Sanitization | Encoding | Rate Limit |
|
|
35
|
+
| ---------------- | ------------------ | ----------------- | --------- | ---------- |
|
|
36
|
+
| User form input | ✅ ALWAYS | ✅ ALWAYS | ✅ Output | Consider |
|
|
37
|
+
| API request body | ✅ ALWAYS | ✅ ALWAYS | ✅ Output | ✅ ALWAYS |
|
|
38
|
+
| URL parameters | ✅ ALWAYS | ✅ ALWAYS | ✅ Output | ✅ ALWAYS |
|
|
39
|
+
| File uploads | ✅ ALWAYS | N/A | N/A | ✅ ALWAYS |
|
|
40
|
+
| Database reads | Verify integrity | ✅ Before display | ✅ Output | N/A |
|
|
41
|
+
| Third-party APIs | ✅ Response schema | ✅ ALWAYS | ✅ Output | N/A |
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 📋 OWASP Top 10 - 2025 Reference
|
|
46
|
+
|
|
47
|
+
### Quick Decision: Which vulnerability applies?
|
|
48
|
+
|
|
49
|
+
| Symptom | Likely Vulnerability | First Action |
|
|
50
|
+
| ------------------------ | --------------------------- | ------------------------- |
|
|
51
|
+
| User input in SQL | SQL Injection (A03) | Use parameterized queries |
|
|
52
|
+
| User input in HTML | XSS (A03) | Encode output, CSP |
|
|
53
|
+
| User input in file paths | Path Traversal | Validate, use allowlist |
|
|
54
|
+
| Secrets in code | Sensitive Data (A02) | Move to env vars |
|
|
55
|
+
| No auth on endpoint | Broken Access (A01) | Add auth + authz checks |
|
|
56
|
+
| Old dependencies | Vulnerable Components (A06) | Audit + update |
|
|
57
|
+
| User-controlled redirect | SSRF / Open Redirect | Validate destination |
|
|
58
|
+
|
|
59
|
+
### A01: Broken Access Control
|
|
60
|
+
|
|
61
|
+
**Decision Tree:**
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
Is user authenticated?
|
|
65
|
+
├── No → Deny access (401)
|
|
66
|
+
└── Yes → Is user authorized for THIS resource?
|
|
67
|
+
├── No → Deny access (403)
|
|
68
|
+
└── Yes → Also check:
|
|
69
|
+
├── Resource belongs to user's tenant?
|
|
70
|
+
├── Action allowed on this resource state?
|
|
71
|
+
└── Rate limit exceeded?
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Implementation Pattern:**
|
|
75
|
+
|
|
76
|
+
```typescript
|
|
77
|
+
// ✅ CORRECT: Always verify ownership
|
|
78
|
+
async getResource(userId: string, resourceId: string) {
|
|
79
|
+
const resource = await this.repo.findById(resourceId);
|
|
80
|
+
|
|
81
|
+
if (!resource) throw new NotFoundException();
|
|
82
|
+
if (resource.ownerId !== userId) throw new ForbiddenException();
|
|
83
|
+
|
|
84
|
+
return resource;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// ❌ WRONG: Trust resourceId from request
|
|
88
|
+
async getResource(resourceId: string) {
|
|
89
|
+
return this.repo.findById(resourceId); // IDOR vulnerability!
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### A03: Injection
|
|
94
|
+
|
|
95
|
+
**Input Handling Decision:**
|
|
96
|
+
|
|
97
|
+
| Context | Technique | Example |
|
|
98
|
+
| ---------- | --------------------- | ---------------------------------------- |
|
|
99
|
+
| SQL | Parameterized queries | `WHERE id = $1` not `WHERE id = '${id}'` |
|
|
100
|
+
| NoSQL | Sanitize operators | Remove `$where`, `$gt`, etc. |
|
|
101
|
+
| OS Command | Avoid if possible | Use APIs instead of `exec()` |
|
|
102
|
+
| LDAP | Escape special chars | Escape `*`, `(`, `)`, `\` |
|
|
103
|
+
| HTML | Encode output | `<` not `<` |
|
|
104
|
+
| JavaScript | Never eval user input | No `eval()`, `new Function()` |
|
|
105
|
+
|
|
106
|
+
**Validation Strategy:**
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
Syntactic Validation Semantic Validation
|
|
110
|
+
(Format is correct) → (Value makes sense)
|
|
111
|
+
|
|
112
|
+
- Email regex match - Email domain exists
|
|
113
|
+
- Date format valid - Date is in future
|
|
114
|
+
- Phone digits only - Phone length correct
|
|
115
|
+
- URL is well-formed - URL domain is whitelisted
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 🛡️ Input Validation Patterns
|
|
121
|
+
|
|
122
|
+
### Allow-List vs Block-List
|
|
123
|
+
|
|
124
|
+
```
|
|
125
|
+
❌ Block-list (Deny known bad)
|
|
126
|
+
- "Block <script> tags"
|
|
127
|
+
- Attackers find bypass: "><script>, <scr<script>ipt>
|
|
128
|
+
|
|
129
|
+
✅ Allow-list (Allow known good)
|
|
130
|
+
- "Accept only [a-zA-Z0-9 ] for username"
|
|
131
|
+
- Unknown patterns automatically rejected
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Validation Implementation
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
// Define explicit rules (Allow-list approach)
|
|
138
|
+
const usernameSchema = z
|
|
139
|
+
.string()
|
|
140
|
+
.min(3, "Too short")
|
|
141
|
+
.max(20, "Too long")
|
|
142
|
+
.regex(/^[a-zA-Z0-9_]+$/, "Invalid characters");
|
|
143
|
+
|
|
144
|
+
// Validate as early as possible
|
|
145
|
+
function createUser(input: unknown) {
|
|
146
|
+
const validated = usernameSchema.parse(input.username); // Throws if invalid
|
|
147
|
+
// Now `validated` is safe to use
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Common Validation Rules
|
|
152
|
+
|
|
153
|
+
| Field Type | Validation Rules |
|
|
154
|
+
| ---------- | ------------------------------------------ |
|
|
155
|
+
| Username | ^[a-zA-Z0-9_]{3,20}$ |
|
|
156
|
+
| Email | RFC 5322 regex + domain check |
|
|
157
|
+
| Password | Min 12 chars, complexity rules |
|
|
158
|
+
| Phone | Digits only, length 10-15 |
|
|
159
|
+
| UUID | ^[0-9a-f]{8}-... pattern |
|
|
160
|
+
| URL | Scheme allowlist (https), domain allowlist |
|
|
161
|
+
| File | Extension allowlist, magic bytes, max size |
|
|
162
|
+
| Date | ISO 8601, reasonable range |
|
|
163
|
+
| Number | Min/max bounds, integer vs float |
|
|
164
|
+
| Free text | Max length, no control chars |
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## 🧹 Sanitization Patterns
|
|
169
|
+
|
|
170
|
+
### When to Sanitize
|
|
171
|
+
|
|
172
|
+
```
|
|
173
|
+
Validation → Accept or Reject
|
|
174
|
+
Sanitization → Clean and Transform
|
|
175
|
+
|
|
176
|
+
Use sanitization when:
|
|
177
|
+
- You must accept rich content (HTML emails)
|
|
178
|
+
- Transforming data format (trim whitespace)
|
|
179
|
+
- Removing known-dangerous patterns
|
|
180
|
+
|
|
181
|
+
Do NOT use sanitization as primary defense:
|
|
182
|
+
- "Sanitize SQL" → Use prepared statements instead
|
|
183
|
+
- "Sanitize for XSS" → Encode output instead
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### HTML Sanitization
|
|
187
|
+
|
|
188
|
+
```typescript
|
|
189
|
+
// Using DOMPurify for user-generated HTML
|
|
190
|
+
import DOMPurify from "dompurify";
|
|
191
|
+
|
|
192
|
+
const dirtyHTML = userInput;
|
|
193
|
+
const cleanHTML = DOMPurify.sanitize(dirtyHTML, {
|
|
194
|
+
ALLOWED_TAGS: ["p", "b", "i", "a", "ul", "li"],
|
|
195
|
+
ALLOWED_ATTR: ["href"],
|
|
196
|
+
ALLOW_DATA_ATTR: false,
|
|
197
|
+
});
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Output Encoding
|
|
201
|
+
|
|
202
|
+
| Context | Encoding |
|
|
203
|
+
| ----------------- | --------------------------------- |
|
|
204
|
+
| HTML body | HTML entity encode (`<` → `<`) |
|
|
205
|
+
| HTML attribute | Attribute encode + quote |
|
|
206
|
+
| JavaScript string | JS escape + avoid eval |
|
|
207
|
+
| CSS value | CSS escape, avoid `url()` |
|
|
208
|
+
| URL parameter | URL encode (`%20`) |
|
|
209
|
+
| JSON | JSON.stringify (auto-escapes) |
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## 🔐 Authentication Security
|
|
214
|
+
|
|
215
|
+
### Password Storage
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
❌ Plain text, MD5, SHA1, SHA256 (fast = bad)
|
|
219
|
+
✅ bcrypt, scrypt, Argon2 (slow = good)
|
|
220
|
+
|
|
221
|
+
Cost factor: ~100ms per hash (adjust for hardware)
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Session Security
|
|
225
|
+
|
|
226
|
+
| Aspect | Requirement |
|
|
227
|
+
| ------------ | ----------------------------------- |
|
|
228
|
+
| Session ID | Cryptographically random, 128+ bits |
|
|
229
|
+
| Storage | HttpOnly cookie (not localStorage) |
|
|
230
|
+
| Transmission | Secure flag (HTTPS only) |
|
|
231
|
+
| Expiration | Reasonable timeout, absolute + idle |
|
|
232
|
+
| Rotation | New ID after privilege change |
|
|
233
|
+
|
|
234
|
+
### JWT Security
|
|
235
|
+
|
|
236
|
+
```
|
|
237
|
+
❌ Algorithm "none" accepted
|
|
238
|
+
❌ Weak secret (dictionary words)
|
|
239
|
+
❌ Sensitive data in payload (tokens are base64, not encrypted)
|
|
240
|
+
❌ Long-lived tokens (days/weeks)
|
|
241
|
+
|
|
242
|
+
✅ RS256 or ES256 (asymmetric)
|
|
243
|
+
✅ Short expiration (15 min) + refresh tokens
|
|
244
|
+
✅ Verify issuer, audience, expiration
|
|
245
|
+
✅ Store refresh token securely (httpOnly cookie)
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## 🌐 API Security
|
|
251
|
+
|
|
252
|
+
### Rate Limiting Strategy
|
|
253
|
+
|
|
254
|
+
| Endpoint Type | Limit | Window | Action on Exceed |
|
|
255
|
+
| -------------------- | ---------- | ------ | ----------------- |
|
|
256
|
+
| Authentication | 5 attempts | 15 min | Lock + notify |
|
|
257
|
+
| Password reset | 3 requests | 1 hour | Delay response |
|
|
258
|
+
| API general | 100 req | 1 min | 429 + Retry-After |
|
|
259
|
+
| Expensive operations | 10 req | 1 hour | Queue + notify |
|
|
260
|
+
|
|
261
|
+
### CORS Configuration
|
|
262
|
+
|
|
263
|
+
```typescript
|
|
264
|
+
// ❌ DANGEROUS: Allow all origins
|
|
265
|
+
app.use(cors({ origin: "*" }));
|
|
266
|
+
|
|
267
|
+
// ✅ CORRECT: Explicit allowlist
|
|
268
|
+
app.use(
|
|
269
|
+
cors({
|
|
270
|
+
origin: ["https://app.example.com", "https://admin.example.com"],
|
|
271
|
+
credentials: true,
|
|
272
|
+
methods: ["GET", "POST", "PUT", "DELETE"],
|
|
273
|
+
allowedHeaders: ["Content-Type", "Authorization"],
|
|
274
|
+
}),
|
|
275
|
+
);
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Security Headers
|
|
279
|
+
|
|
280
|
+
```typescript
|
|
281
|
+
const securityHeaders = {
|
|
282
|
+
"Content-Security-Policy": "default-src 'self'; script-src 'self'",
|
|
283
|
+
"X-Content-Type-Options": "nosniff",
|
|
284
|
+
"X-Frame-Options": "DENY",
|
|
285
|
+
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
|
|
286
|
+
"Referrer-Policy": "strict-origin-when-cross-origin",
|
|
287
|
+
"Permissions-Policy": "geolocation=(), microphone=()",
|
|
288
|
+
};
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
## 🚨 Anti-Patterns
|
|
294
|
+
|
|
295
|
+
| ❌ Don't | ✅ Do |
|
|
296
|
+
| --------------------------------------- | ---------------------------------- |
|
|
297
|
+
| Store passwords in plain text | Use bcrypt/Argon2 with proper cost |
|
|
298
|
+
| Concatenate SQL strings | Use parameterized queries |
|
|
299
|
+
| Disable SSL verification | Fix certificate issues properly |
|
|
300
|
+
| Log sensitive data | Mask/redact before logging |
|
|
301
|
+
| Use `eval()` with user input | Find alternative approach |
|
|
302
|
+
| Trust client-side validation | Always validate server-side |
|
|
303
|
+
| Commit secrets to repo | Use environment variables |
|
|
304
|
+
| Use `*` for CORS origin | Explicit domain allowlist |
|
|
305
|
+
| Disable security features "temporarily" | Never—find proper solution |
|
|
306
|
+
| Roll your own crypto | Use established libraries |
|
|
307
|
+
|
|
308
|
+
---
|
|
309
|
+
|
|
310
|
+
## 📊 Security Review Checklist
|
|
311
|
+
|
|
312
|
+
### For Code Review
|
|
313
|
+
|
|
314
|
+
```markdown
|
|
315
|
+
## Security Review: [Feature/PR Name]
|
|
316
|
+
|
|
317
|
+
### Input Handling
|
|
318
|
+
|
|
319
|
+
- [ ] All user input validated (type, format, length, range)
|
|
320
|
+
- [ ] Validation uses allow-list approach
|
|
321
|
+
- [ ] Output properly encoded for context
|
|
322
|
+
|
|
323
|
+
### Authentication & Authorization
|
|
324
|
+
|
|
325
|
+
- [ ] Every endpoint has auth check
|
|
326
|
+
- [ ] Resource ownership verified (no IDOR)
|
|
327
|
+
- [ ] Sensitive actions require re-authentication
|
|
328
|
+
|
|
329
|
+
### Data Protection
|
|
330
|
+
|
|
331
|
+
- [ ] No secrets in code or logs
|
|
332
|
+
- [ ] Sensitive data encrypted at rest
|
|
333
|
+
- [ ] PII handling follows regulations
|
|
334
|
+
|
|
335
|
+
### API Security
|
|
336
|
+
|
|
337
|
+
- [ ] Rate limiting in place
|
|
338
|
+
- [ ] CORS properly configured
|
|
339
|
+
- [ ] Security headers set
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
---
|
|
343
|
+
|
|
344
|
+
## 🔗 Related Skills
|
|
345
|
+
|
|
346
|
+
| Need | Skill |
|
|
347
|
+
| --------------------- | ------------------ |
|
|
348
|
+
| API design patterns | `api-patterns` |
|
|
349
|
+
| Database security | `database-design` |
|
|
350
|
+
| Testing for security | `testing-patterns` |
|
|
351
|
+
| Clean code principles | `clean-code` |
|
|
352
|
+
|
|
353
|
+
---
|
|
354
|
+
|
|
355
|
+
## 📚 References
|
|
356
|
+
|
|
357
|
+
- [OWASP Top 10 2025](https://owasp.org/www-project-top-ten/)
|
|
358
|
+
- [OWASP Cheat Sheet Series](https://cheatsheetseries.owasp.org/)
|
|
359
|
+
- [OWASP Secure Coding Practices](https://owasp.org/www-project-secure-coding-practices-quick-reference-guide/)
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
|
|
363
|
+
> **Remember:** Security is everyone's responsibility. When in doubt, assume the input is malicious.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Assets directory - add templates, images, etc.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Reference Documentation for Security Fundamentals
|
|
2
|
+
|
|
3
|
+
[TODO: Add detailed reference content here]
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
[Detailed explanation of concepts]
|
|
8
|
+
|
|
9
|
+
## Deep Dive Topics
|
|
10
|
+
|
|
11
|
+
### Topic 1
|
|
12
|
+
|
|
13
|
+
[Content]
|
|
14
|
+
|
|
15
|
+
### Topic 2
|
|
16
|
+
|
|
17
|
+
[Content]
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
[Real-world examples]
|