@kl-c/matrixos 0.3.40 → 0.3.41

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 (49) hide show
  1. package/dist/cli/index.js +1 -1
  2. package/dist/cli/skills/api-and-interface-design/SKILL.md +298 -0
  3. package/dist/cli/skills/browser-testing-with-devtools/SKILL.md +321 -0
  4. package/dist/cli/skills/ci-cd-and-automation/SKILL.md +394 -0
  5. package/dist/cli/skills/context-engineering/SKILL.md +293 -0
  6. package/dist/cli/skills/deprecation-and-migration/SKILL.md +251 -0
  7. package/dist/cli/skills/documentation-and-adrs/SKILL.md +292 -0
  8. package/dist/cli/skills/doubt-driven-development/SKILL.md +247 -0
  9. package/dist/cli/skills/incremental-implementation/SKILL.md +253 -0
  10. package/dist/cli/skills/interview-me/SKILL.md +229 -0
  11. package/dist/cli/skills/observability-and-instrumentation/SKILL.md +207 -0
  12. package/dist/cli/skills/performance-optimization/SKILL.md +354 -0
  13. package/dist/cli/skills/security-and-hardening/SKILL.md +471 -0
  14. package/dist/cli/skills/shipping-and-launch/SKILL.md +314 -0
  15. package/dist/cli/skills/source-driven-development/SKILL.md +198 -0
  16. package/dist/cli/skills/test-driven-development/SKILL.md +402 -0
  17. package/dist/cli-node/index.js +1 -1
  18. package/dist/index.js +1 -1
  19. package/dist/skills/api-and-interface-design/SKILL.md +298 -0
  20. package/dist/skills/browser-testing-with-devtools/SKILL.md +321 -0
  21. package/dist/skills/ci-cd-and-automation/SKILL.md +394 -0
  22. package/dist/skills/context-engineering/SKILL.md +293 -0
  23. package/dist/skills/deprecation-and-migration/SKILL.md +251 -0
  24. package/dist/skills/documentation-and-adrs/SKILL.md +292 -0
  25. package/dist/skills/doubt-driven-development/SKILL.md +247 -0
  26. package/dist/skills/incremental-implementation/SKILL.md +253 -0
  27. package/dist/skills/interview-me/SKILL.md +229 -0
  28. package/dist/skills/observability-and-instrumentation/SKILL.md +207 -0
  29. package/dist/skills/performance-optimization/SKILL.md +354 -0
  30. package/dist/skills/security-and-hardening/SKILL.md +471 -0
  31. package/dist/skills/shipping-and-launch/SKILL.md +314 -0
  32. package/dist/skills/source-driven-development/SKILL.md +198 -0
  33. package/dist/skills/test-driven-development/SKILL.md +402 -0
  34. package/package.json +1 -1
  35. package/packages/shared-skills/skills/api-and-interface-design/SKILL.md +298 -0
  36. package/packages/shared-skills/skills/browser-testing-with-devtools/SKILL.md +321 -0
  37. package/packages/shared-skills/skills/ci-cd-and-automation/SKILL.md +394 -0
  38. package/packages/shared-skills/skills/context-engineering/SKILL.md +293 -0
  39. package/packages/shared-skills/skills/deprecation-and-migration/SKILL.md +251 -0
  40. package/packages/shared-skills/skills/documentation-and-adrs/SKILL.md +292 -0
  41. package/packages/shared-skills/skills/doubt-driven-development/SKILL.md +247 -0
  42. package/packages/shared-skills/skills/incremental-implementation/SKILL.md +253 -0
  43. package/packages/shared-skills/skills/interview-me/SKILL.md +229 -0
  44. package/packages/shared-skills/skills/observability-and-instrumentation/SKILL.md +207 -0
  45. package/packages/shared-skills/skills/performance-optimization/SKILL.md +354 -0
  46. package/packages/shared-skills/skills/security-and-hardening/SKILL.md +471 -0
  47. package/packages/shared-skills/skills/shipping-and-launch/SKILL.md +314 -0
  48. package/packages/shared-skills/skills/source-driven-development/SKILL.md +198 -0
  49. package/packages/shared-skills/skills/test-driven-development/SKILL.md +402 -0
@@ -0,0 +1,471 @@
1
+ ---
2
+ name: security-and-hardening
3
+ description: Hardens code against vulnerabilities. Use when handling user input, authentication, data storage, or external integrations. Use when building any feature that accepts untrusted data, manages user sessions, or interacts with third-party services.
4
+ source: addyosmani/agent-skills (MIT)
5
+ ---
6
+
7
+ # Security and Hardening
8
+
9
+ ## Overview
10
+
11
+ Security-first development practices for web applications. Treat every external input as hostile, every secret as sacred, and every authorization check as mandatory. Security isn't a phase — it's a constraint on every line of code that touches user data, authentication, or external systems.
12
+
13
+ ## When to Use
14
+
15
+ - Building anything that accepts user input
16
+ - Implementing authentication or authorization
17
+ - Storing or transmitting sensitive data
18
+ - Integrating with external APIs or services
19
+ - Adding file uploads, webhooks, or callbacks
20
+ - Handling payment or PII data
21
+
22
+ ## Process: Threat Model First
23
+
24
+ Controls bolted on without a threat model are guesses. Before hardening, spend five minutes thinking like an attacker:
25
+
26
+ 1. **Map the trust boundaries.** Where does untrusted data cross into your system? HTTP requests, form fields, file uploads, webhooks, third-party APIs, message queues, and **LLM output**. Every boundary is attack surface.
27
+ 2. **Name the assets.** What's worth stealing or breaking? Credentials, PII, payment data, admin actions, money movement.
28
+ 3. **Run STRIDE over each boundary** — a quick lens, not a ceremony:
29
+
30
+ | Threat | Ask | Typical mitigation |
31
+ |---|---|---|
32
+ | **S**poofing | Can someone impersonate a user/service? | Authentication, signature verification |
33
+ | **T**ampering | Can data be altered in transit or at rest? | Integrity checks, parameterized queries, HTTPS |
34
+ | **R**epudiation | Can an action be denied later? | Audit logging of security events |
35
+ | **I**nformation disclosure | Can data leak? | Encryption, field allowlists, generic errors |
36
+ | **D**enial of service | Can it be overwhelmed? | Rate limiting, input size caps, timeouts |
37
+ | **E**levation of privilege | Can a user gain rights they shouldn't? | Authorization checks, least privilege |
38
+
39
+ 4. **Write abuse cases next to use cases.** For each feature, ask "how would I misuse this?" — then make that your first test.
40
+
41
+ If you can't name the trust boundaries for a feature, you're not ready to secure it. This is OWASP **A04: Insecure Design** — most breaches begin in design, not code.
42
+
43
+ ## The Three-Tier Boundary System
44
+
45
+ ### Always Do (No Exceptions)
46
+
47
+ - **Validate all external input** at the system boundary (API routes, form handlers)
48
+ - **Parameterize all database queries** — never concatenate user input into SQL
49
+ - **Encode output** to prevent XSS (use framework auto-escaping, don't bypass it)
50
+ - **Use HTTPS** for all external communication
51
+ - **Hash passwords** with bcrypt/scrypt/argon2 (never store plaintext)
52
+ - **Set security headers** (CSP, HSTS, X-Frame-Options, X-Content-Type-Options)
53
+ - **Use httpOnly, secure, sameSite cookies** for sessions
54
+ - **Run the detected package manager's native audit** against the committed lockfile before every release
55
+
56
+ ### Ask First (Requires Human Approval)
57
+
58
+ - Adding new authentication flows or changing auth logic
59
+ - Storing new categories of sensitive data (PII, payment info)
60
+ - Adding new external service integrations
61
+ - Changing CORS configuration
62
+ - Adding file upload handlers
63
+ - Modifying rate limiting or throttling
64
+ - Granting elevated permissions or roles
65
+
66
+ ### Never Do
67
+
68
+ - **Never commit secrets** to version control (API keys, passwords, tokens)
69
+ - **Never log sensitive data** (passwords, tokens, full credit card numbers)
70
+ - **Never trust client-side validation** as a security boundary
71
+ - **Never disable security headers** for convenience
72
+ - **Never use `eval()` or `innerHTML`** with user-provided data
73
+ - **Never store sessions in client-accessible storage** (localStorage for auth tokens)
74
+ - **Never expose stack traces** or internal error details to users
75
+
76
+ ## OWASP Top 10 Prevention Patterns
77
+
78
+ These are prevention patterns, not a ranking. For the 2021 ordering, see the quick-reference table in `references/security-checklist.md`.
79
+
80
+ ### Injection (SQL, NoSQL, OS Command)
81
+
82
+ ```typescript
83
+ // BAD: SQL injection via string concatenation
84
+ const query = `SELECT * FROM users WHERE id = '${userId}'`;
85
+
86
+ // GOOD: Parameterized query
87
+ const user = await db.query('SELECT * FROM users WHERE id = $1', [userId]);
88
+
89
+ // GOOD: ORM with parameterized input
90
+ const user = await prisma.user.findUnique({ where: { id: userId } });
91
+ ```
92
+
93
+ ### Broken Authentication
94
+
95
+ ```typescript
96
+ // Password hashing
97
+ import { hash, compare } from 'bcrypt';
98
+
99
+ const SALT_ROUNDS = 12;
100
+ const hashedPassword = await hash(plaintext, SALT_ROUNDS);
101
+ const isValid = await compare(plaintext, hashedPassword);
102
+
103
+ // Session management
104
+ app.use(session({
105
+ secret: process.env.SESSION_SECRET, // From environment, not code
106
+ resave: false,
107
+ saveUninitialized: false,
108
+ cookie: {
109
+ httpOnly: true, // Not accessible via JavaScript
110
+ secure: true, // HTTPS only
111
+ sameSite: 'lax', // CSRF protection
112
+ maxAge: 24 * 60 * 60 * 1000, // 24 hours
113
+ },
114
+ }));
115
+ ```
116
+
117
+ ### Cross-Site Scripting (XSS)
118
+
119
+ ```typescript
120
+ // BAD: Rendering user input as HTML
121
+ element.innerHTML = userInput;
122
+
123
+ // GOOD: Use framework auto-escaping (React does this by default)
124
+ return <div>{userInput}</div>;
125
+
126
+ // If you MUST render HTML, sanitize first
127
+ import DOMPurify from 'dompurify';
128
+ const clean = DOMPurify.sanitize(userInput);
129
+ ```
130
+
131
+ ### Broken Access Control
132
+
133
+ ```typescript
134
+ // Always check authorization, not just authentication
135
+ app.patch('/api/tasks/:id', authenticate, async (req, res) => {
136
+ const task = await taskService.findById(req.params.id);
137
+
138
+ // Check that the authenticated user owns this resource
139
+ if (task.ownerId !== req.user.id) {
140
+ return res.status(403).json({
141
+ error: { code: 'FORBIDDEN', message: 'Not authorized to modify this task' }
142
+ });
143
+ }
144
+
145
+ // Proceed with update
146
+ const updated = await taskService.update(req.params.id, req.body);
147
+ return res.json(updated);
148
+ });
149
+ ```
150
+
151
+ ### Security Misconfiguration
152
+
153
+ ```typescript
154
+ // Security headers (use helmet for Express)
155
+ import helmet from 'helmet';
156
+ app.use(helmet());
157
+
158
+ // Content Security Policy
159
+ app.use(helmet.contentSecurityPolicy({
160
+ directives: {
161
+ defaultSrc: ["'self'"],
162
+ scriptSrc: ["'self'"],
163
+ styleSrc: ["'self'", "'unsafe-inline'"], // Tighten if possible
164
+ imgSrc: ["'self'", 'data:', 'https:'],
165
+ connectSrc: ["'self'"],
166
+ },
167
+ }));
168
+
169
+ // CORS — restrict to known origins
170
+ app.use(cors({
171
+ origin: process.env.ALLOWED_ORIGINS?.split(',') || 'http://localhost:3000',
172
+ credentials: true,
173
+ }));
174
+ ```
175
+
176
+ ### Sensitive Data Exposure
177
+
178
+ ```typescript
179
+ // Never return sensitive fields in API responses
180
+ function sanitizeUser(user: UserRecord): PublicUser {
181
+ const { passwordHash, resetToken, ...publicFields } = user;
182
+ return publicFields;
183
+ }
184
+
185
+ // Use environment variables for secrets
186
+ const API_KEY = process.env.STRIPE_API_KEY;
187
+ if (!API_KEY) throw new Error('STRIPE_API_KEY not configured');
188
+ ```
189
+
190
+ ### Server-Side Request Forgery (SSRF)
191
+
192
+ Any time the server fetches a URL the user influenced — webhooks, "import from URL", image proxies, link previews — an attacker can aim it at internal services (cloud metadata, `localhost`, private IPs).
193
+
194
+ ```typescript
195
+ // BAD: fetch whatever the user gives you
196
+ await fetch(req.body.webhookUrl);
197
+
198
+ // GOOD: allowlist scheme + host, reject if ANY resolved IP is private, forbid redirects
199
+ import { lookup } from 'node:dns/promises';
200
+ import ipaddr from 'ipaddr.js';
201
+
202
+ const ALLOWED_HOSTS = new Set(['hooks.example.com']);
203
+
204
+ async function assertSafeUrl(raw: string): Promise<URL> {
205
+ const url = new URL(raw);
206
+ if (url.protocol !== 'https:') throw new Error('https only');
207
+ if (!ALLOWED_HOSTS.has(url.hostname)) throw new Error('host not allowed');
208
+ // Resolve ALL records; a single private/reserved address fails the check.
209
+ const addrs = await lookup(url.hostname, { all: true });
210
+ if (addrs.some((a) => ipaddr.parse(a.address).range() !== 'unicast')) {
211
+ throw new Error('private/reserved IP');
212
+ }
213
+ return url;
214
+ }
215
+
216
+ await fetch(await assertSafeUrl(req.body.webhookUrl), { redirect: 'error' });
217
+ ```
218
+
219
+ The `range() !== 'unicast'` check covers loopback, link-local `169.254.169.254` (cloud metadata, the #1 SSRF target), private, and unique-local ranges across IPv4 and IPv6.
220
+
221
+ **Caveat — this still has a TOCTOU gap.** `fetch` resolves DNS again after the check, so an attacker using a short-TTL record can rebind to an internal IP between validation and connection. For high-risk surfaces, resolve once and connect to the pinned IP, or put a filtering agent in front (`request-filtering-agent` / `ssrf-req-filter`).
222
+
223
+ ## Input Validation Patterns
224
+
225
+ ### Schema Validation at Boundaries
226
+
227
+ ```typescript
228
+ import { z } from 'zod';
229
+
230
+ const CreateTaskSchema = z.object({
231
+ title: z.string().min(1).max(200).trim(),
232
+ description: z.string().max(2000).optional(),
233
+ priority: z.enum(['low', 'medium', 'high']).default('medium'),
234
+ dueDate: z.string().datetime().optional(),
235
+ });
236
+
237
+ // Validate at the route handler
238
+ app.post('/api/tasks', async (req, res) => {
239
+ const result = CreateTaskSchema.safeParse(req.body);
240
+ if (!result.success) {
241
+ return res.status(422).json({
242
+ error: {
243
+ code: 'VALIDATION_ERROR',
244
+ message: 'Invalid input',
245
+ details: result.error.flatten(),
246
+ },
247
+ });
248
+ }
249
+ // result.data is now typed and validated
250
+ const task = await taskService.create(result.data);
251
+ return res.status(201).json(task);
252
+ });
253
+ ```
254
+
255
+ ### File Upload Safety
256
+
257
+ ```typescript
258
+ // Restrict file types and sizes
259
+ const ALLOWED_TYPES = ['image/jpeg', 'image/png', 'image/webp'];
260
+ const MAX_SIZE = 5 * 1024 * 1024; // 5MB
261
+
262
+ function validateUpload(file: UploadedFile) {
263
+ if (!ALLOWED_TYPES.includes(file.mimetype)) {
264
+ throw new ValidationError('File type not allowed');
265
+ }
266
+ if (file.size > MAX_SIZE) {
267
+ throw new ValidationError('File too large (max 5MB)');
268
+ }
269
+ // Don't trust the file extension — check magic bytes if critical
270
+ }
271
+ ```
272
+
273
+ ## Triaging Dependency Audit Results
274
+
275
+ Package-manager audits report known advisories; they do not prove a package is trustworthy or that vulnerable code is reachable. Use this decision tree:
276
+
277
+ ```
278
+ The native package-manager audit reports a vulnerability
279
+ ├── Severity: critical or high
280
+ │ ├── Is the vulnerable code reachable in runtime, build, test, or deployment paths?
281
+ │ │ ├── YES --> Fix immediately (update, patch, or replace the dependency)
282
+ │ │ └── NO (confirmed unused across those paths) --> Fix soon, but not a blocker
283
+ │ └── Is a fix available?
284
+ │ ├── YES --> Update to the patched version
285
+ │ └── NO --> Check for workarounds, consider replacing the dependency, or add to allowlist with a review date
286
+ ├── Severity: moderate
287
+ │ ├── Reachable in production? --> Fix in the next release cycle
288
+ │ └── Dev-only? --> Fix when convenient, track in backlog
289
+ └── Severity: low
290
+ └── Track and fix during regular dependency updates
291
+ ```
292
+
293
+ **Key questions:**
294
+ - Is the vulnerable function actually called in your code path?
295
+ - Is the dependency a runtime dependency or dev-only?
296
+ - Is the vulnerability exploitable given your deployment context (e.g., a server-side vulnerability in a client-only app)?
297
+
298
+ When you defer a fix, document the reason and set a review date.
299
+
300
+ ### Supply-Chain Hygiene
301
+
302
+ Do not assume npm or treat the nearest manifest as the install root. Apply this order:
303
+
304
+ 1. **Find the installation boundary and manager.** Use the workspace root that owns the lockfile, or an independent nested project only when it is outside that workspace. There, corroborate `packageManager` (when present), the lockfile, and CI; stop on disagreement or competing lockfiles. Pin the manager version and use the matrix in `references/security-checklist.md`.
305
+ 2. **Block dependency scripts before first execution.** Bootstrap with scripts disabled or a documented fail-closed policy, inspect the pending script source, approve only the minimum required packages, commit the policy, then verify with a clean frozen/immutable install. Never blanket-approve scripts.
306
+
307
+ Audits only find known advisories; they do not catch a newly malicious or typosquatted package. Therefore:
308
+
309
+ - **Never apply forced audit remediation automatically** (`npm audit fix --force` or equivalent). Preview the remediation, read changelogs, and test each resulting upgrade; forced fixes may cross declared dependency ranges.
310
+ - **Verify registry signatures and provenance where supported** (`npm audit signatures`, `pnpm audit signatures`) and treat absence as a signal to investigate, not automatic proof of compromise.
311
+ - **Review new dependencies, lockfile diffs, and script-policy changes together** — ownership, maintenance, release age, provenance, transitive graph, and typosquats such as `cross-env` vs `crossenv` (OWASP **A06**, **LLM03**).
312
+
313
+ ## Rate Limiting
314
+
315
+ ```typescript
316
+ import rateLimit from 'express-rate-limit';
317
+
318
+ // General API rate limit
319
+ app.use('/api/', rateLimit({
320
+ windowMs: 15 * 60 * 1000, // 15 minutes
321
+ max: 100, // 100 requests per window
322
+ standardHeaders: true,
323
+ legacyHeaders: false,
324
+ }));
325
+
326
+ // Stricter limit for auth endpoints
327
+ app.use('/api/auth/', rateLimit({
328
+ windowMs: 15 * 60 * 1000,
329
+ max: 10, // 10 attempts per 15 minutes
330
+ }));
331
+ ```
332
+
333
+ ## Secrets Management
334
+
335
+ ```
336
+ .env files:
337
+ ├── .env.example → Committed (template with placeholder values)
338
+ ├── .env → NOT committed (contains real secrets)
339
+ └── .env.local → NOT committed (local overrides)
340
+
341
+ .gitignore must include:
342
+ .env
343
+ .env.local
344
+ .env.*.local
345
+ *.pem
346
+ *.key
347
+ ```
348
+
349
+ **Always check before committing:**
350
+ ```bash
351
+ # Check for accidentally staged secrets
352
+ git diff --cached | grep -i "password\|secret\|api_key\|token"
353
+ ```
354
+
355
+ **If a secret is ever committed, rotate it.** Deleting the line or rewriting history is not enough — assume it's compromised the moment it reaches a remote. Revoke and reissue the key first, then purge it from history.
356
+
357
+ ## Securing AI / LLM Features
358
+
359
+ If your app calls an LLM — chatbots, summarizers, agents, RAG — it inherits a new attack surface. Map it to the [OWASP Top 10 for LLM Applications (2025)](https://genai.owasp.org/llm-top-10/):
360
+
361
+ - **Treat all model output as untrusted input (LLM05: Improper Output Handling).** Never pass LLM output straight into `eval`, SQL, a shell, `innerHTML`, or a file path. Validate and encode it exactly as you would raw user input.
362
+ - **Assume prompts can be hijacked (LLM01: Prompt Injection).** Untrusted text in the context window — a user message, a fetched web page, a PDF — can carry instructions. The system prompt is not a security boundary; enforce permissions in code, not in the prompt.
363
+ - **Keep secrets and other users' data out of prompts (LLM02 / LLM07).** Anything in the context can be echoed back. Don't put API keys, cross-tenant data, or the full system prompt where the model can repeat it.
364
+ - **Constrain tool and agent permissions (LLM06: Excessive Agency).** Scope tools to the minimum, require confirmation for destructive or irreversible actions, and validate every tool argument.
365
+ - **Bound consumption (LLM10: Unbounded Consumption).** Cap tokens, request rate, and loop/recursion depth so a crafted input can't run up cost or hang the system.
366
+ - **Isolate retrieval data (LLM08: Vector and Embedding Weaknesses).** In RAG, treat the vector store as a trust boundary: partition embeddings per tenant so one user can't retrieve another's data, and validate documents before indexing so poisoned content can't steer answers.
367
+
368
+ ```typescript
369
+ // BAD: trusting model output as a command or as markup
370
+ const sql = await llm.generate(`Write SQL for: ${userQuestion}`);
371
+ await db.query(sql); // arbitrary query execution
372
+ container.innerHTML = await llm.reply(userMessage); // stored XSS, via the model
373
+
374
+ // GOOD: model output is data — parse defensively, then validate, then encode
375
+ let intent;
376
+ try {
377
+ intent = CommandSchema.parse(JSON.parse(await llm.replyJson(userMessage)));
378
+ } catch {
379
+ throw new ValidationError('unexpected model output'); // JSON.parse or schema failed
380
+ }
381
+ await runAllowlistedAction(intent.action, intent.params);
382
+ container.textContent = await llm.reply(userMessage);
383
+ ```
384
+
385
+ ## Security Review Checklist
386
+
387
+ ```markdown
388
+ ### Authentication
389
+ - [ ] Passwords hashed with bcrypt/scrypt/argon2 (salt rounds ≥ 12)
390
+ - [ ] Session tokens are httpOnly, secure, sameSite
391
+ - [ ] Login has rate limiting
392
+ - [ ] Password reset tokens expire
393
+
394
+ ### Authorization
395
+ - [ ] Every endpoint checks user permissions
396
+ - [ ] Users can only access their own resources
397
+ - [ ] Admin actions require admin role verification
398
+
399
+ ### Input
400
+ - [ ] All user input validated at the boundary
401
+ - [ ] SQL queries are parameterized
402
+ - [ ] HTML output is encoded/escaped
403
+ - [ ] Server-side URL fetches are allowlisted (no SSRF to internal services)
404
+
405
+ ### Data
406
+ - [ ] No secrets in code or version control
407
+ - [ ] Sensitive fields excluded from API responses
408
+ - [ ] PII encrypted at rest (if applicable)
409
+
410
+ ### Infrastructure
411
+ - [ ] Security headers configured (CSP, HSTS, etc.)
412
+ - [ ] CORS restricted to known origins
413
+ - [ ] Dependencies audited for vulnerabilities
414
+ - [ ] Error messages don't expose internals
415
+
416
+ ### Supply Chain
417
+ - [ ] One authoritative lockfile committed; CI uses that manager's frozen/immutable install
418
+ - [ ] Native audit triaged by reachability and fix risk; dependency install scripts blocked unless explicitly approved
419
+ - [ ] New dependencies reviewed (ownership, provenance, release age, transitive graph)
420
+
421
+ ### AI / LLM (if used)
422
+ - [ ] Model output treated as untrusted (no eval/SQL/innerHTML/shell)
423
+ - [ ] Secrets and other users' data kept out of prompts
424
+ - [ ] Tool/agent permissions scoped; destructive actions require confirmation
425
+ ```
426
+ ## See Also
427
+
428
+ For detailed security checklists and pre-commit verification steps, see `references/security-checklist.md`.
429
+
430
+ ## Common Rationalizations
431
+
432
+ | Rationalization | Reality |
433
+ |---|---|
434
+ | "This is an internal tool, security doesn't matter" | Internal tools get compromised. Attackers target the weakest link. |
435
+ | "We'll add security later" | Security retrofitting is 10x harder than building it in. Add it now. |
436
+ | "No one would try to exploit this" | Automated scanners will find it. Security by obscurity is not security. |
437
+ | "The framework handles security" | Frameworks provide tools, not guarantees. You still need to use them correctly. |
438
+ | "It's just a prototype" | Prototypes become production. Security habits from day one. |
439
+ | "Threat modeling is overkill here" | Five minutes of "how would I attack this?" prevents the design flaws no control can patch later. |
440
+ | "It's just LLM output, it's only text" | That "text" can be a SQL statement, a script tag, or a shell command. Treat it like any untrusted input. |
441
+ | "The audit passed, so the dependency is safe" | Audits match known advisories. They do not detect a newly malicious package or make unreviewed install scripts safe to execute. |
442
+
443
+ ## Red Flags
444
+
445
+ - User input passed directly to database queries, shell commands, or HTML rendering
446
+ - Secrets in source code or commit history
447
+ - API endpoints without authentication or authorization checks
448
+ - Missing CORS configuration or wildcard (`*`) origins
449
+ - No rate limiting on authentication endpoints
450
+ - Stack traces or internal errors exposed to users
451
+ - Dependencies with known critical vulnerabilities, competing lockfiles at one installation boundary, non-reproducible installs, or blanket-approved scripts
452
+ - Server fetches user-supplied URLs without an allowlist (SSRF)
453
+ - LLM/model output passed into a query, the DOM, a shell, or `eval`
454
+ - Secrets, PII, or the full system prompt placed inside an LLM context window
455
+
456
+ ## Verification
457
+
458
+ After implementing security-relevant code:
459
+
460
+ - [ ] The native audit has no unmitigated reachable critical/high findings; CI preserves the authoritative lockfile and blocks unreviewed dependency scripts
461
+ - [ ] No secrets in source code or git history
462
+ - [ ] All user input validated at system boundaries
463
+ - [ ] Authentication and authorization checked on every protected endpoint
464
+ - [ ] Security headers present in response (check with browser DevTools)
465
+ - [ ] Error responses don't expose internal details
466
+ - [ ] Rate limiting active on auth endpoints
467
+ - [ ] Server-side URL fetches validated against an allowlist (no SSRF)
468
+ - [ ] LLM/model output validated and encoded before use (if AI features present)
469
+
470
+ ---
471
+ *Source: addyosmani/agent-skills (MIT). Ported into MaTrixOS shared-skills bundle.*