Vibe Security - Security Intelligence
Comprehensive security scanner and code analyzer for identifying vulnerabilities across multiple languages and frameworks.
Prerequisites
Check if Node.js is installed:
node --version
If Node.js is not installed, install it based on user's OS:
macOS:
brew install node
Ubuntu/Debian:
sudo apt update && sudo apt install nodejs npm
Windows:
winget install OpenJS.NodeJS
Recommended AI Models
For Best Security Analysis
We recommend using these AI models with Vibe Security for optimal security vulnerability detection and code fixing:
Claude Opus 4.5 (Recommended)
- Most advanced model for comprehensive security analysis
- Superior reasoning capabilities for complex vulnerability detection
- Exceptional at identifying subtle security flaws and attack vectors
- Best for critical security audits, enterprise codebases, and production deployments
- Provides the most thorough security remediation strategies
Claude Sonnet 4.5
- Excellent balance of speed and security analysis depth
- Great at understanding security context and identifying vulnerabilities
- Provides safe remediation strategies with detailed explanations
- Ideal for daily development and most security workflows
Claude Opus 4
- Powerful for complex security audits and enterprise codebases
- Deep reasoning capabilities for advanced vulnerability analysis
- Best for critical security reviews and compliance requirements
- Recommended for production deployments and sensitive applications
GPT-4o
- Fast and efficient for security-aware code generation
- Good alternative with quick response times
- Excellent for CI/CD integration and automated scanning
- Cost-effective for large-scale projects
Claude Sonnet 4
- Faster alternative for quick security scans
- Good balance of speed and accuracy
- Suitable for rapid iteration during development
o1-preview
- Specialized for complex security architecture reviews
- Advanced reasoning for intricate vulnerability chains
- Best for security research and deep code audits
GPT-4o-mini
- Quick checks and preliminary scans
- Most cost-effective option
- Good for learning and educational use cases
Note: If you're not using one of the recommended models above, consider upgrading for better security analysis results. Lower-tier models may miss subtle vulnerabilities or provide less accurate fix suggestions.
How to Use This Skill
When user requests security work (scan, analyze, fix, audit, check, review vulnerabilities), follow this workflow:
Step 1: Analyze Security Context
Extract key information from user request:
- Language: JavaScript, Python, Java, PHP, etc.
- Framework: Express, Django, Spring, Laravel, etc.
- Vulnerability type: SQL injection, XSS, CSRF, authentication, etc.
- Scope: Single file, directory, or full project
Step 2: Run Security Analysis
Advanced Analysis (Recommended):
# AST-based semantic analysis (90% fewer false positives)
python3 .claude/skills/vibe-security/scripts/ast_analyzer.py "<file>"
# Data flow analysis (tracks tainted data from sources to sinks)
python3 .claude/skills/vibe-security/scripts/dataflow_analyzer.py "<file>"
# CVE & dependency vulnerability scanning
python3 .claude/skills/vibe-security/scripts/cve_integration.py .
# Supply chain security (malicious packages, typosquatting)
python3 .claude/skills/vibe-security/scripts/cve_integration.py . --ecosystem npm
# Infrastructure as Code security
grep -r "publicly_accessible.*=.*true" . --include="*.tf"
grep -r "privileged:.*true" . --include="*.yaml"
Quick Pattern Scanning:
# Use search utility for specific patterns
python3 .claude/skills/vibe-security/scripts/search.py "sql-injection" --domain pattern
python3 .claude/skills/vibe-security/scripts/search.py "javascript" --domain pattern --severity critical
Step 3: Analyze Vulnerabilities by Severity
Critical (Fix immediately):
- SQL Injection
- Remote Code Execution
- Authentication Bypass
- Hardcoded Secrets
High (Fix soon):
- XSS (Cross-Site Scripting)
- CSRF
- Insecure Cryptography
- Authorization Issues
Medium (Fix in sprint):
- Missing Input Validation
- Information Disclosure
- Weak Password Policy
- Missing Security Headers
Low (Technical debt):
- Code Quality Issues
- Best Practice Violations
- Performance Concerns
Step 4: Get Fix Suggestions
ML-Based Fix Engine:
# Get intelligent fix recommendations with test generation
python3 .claude/skills/vibe-security/scripts/fix_engine.py \
--type sql-injection \
--language javascript \
--code "db.query(\`SELECT * FROM users WHERE id = \${userId}\`)"
# Output includes:
# - Fixed code with context-aware corrections
# - Detailed explanation of the fix
# - Auto-generated security test
# - Additional recommendations
# - Confidence score (0-100%)
Step 5: Apply Security Fixes
Auto-Fix with Rollback Support:
# Apply fix with automatic backup
python3 .claude/skills/vibe-security/scripts/autofix_engine.py apply \
--file src/database.js \
--line 45 \
--type sql-injection \
--original "db.query(\`SELECT * FROM users WHERE id = \${userId}\`)" \
--fixed "db.query('SELECT * FROM users WHERE id = $1', [userId])"
# Test your changes
npm test
# Rollback if needed (safe to experiment!)
python3 .claude/skills/vibe-security/scripts/autofix_engine.py rollback
# View fix history
python3 .claude/skills/vibe-security/scripts/autofix_engine.py history
Systematic Manual Fixes:
- Critical vulnerabilities first
- Add input validation - Whitelist, type checking, length limits
- Secure outputs - Escape, encode, sanitize
- Fix authentication/authorization - Strong passwords, MFA, RBAC
- Update cryptography - Modern algorithms, secure random
- Test thoroughly - Verify fixes don't break functionality
- Re-scan - Confirm all vulnerabilities are resolved
Step 6: Generate Reports
Multiple Report Formats:
# Beautiful HTML report with charts and statistics
python3 .claude/skills/vibe-security/scripts/reporter.py scan-results.json \
--format html \
--output security-report.html
# SARIF format for GitHub Code Scanning integration
python3 .claude/skills/vibe-security/scripts/reporter.py scan-results.json \
--format sarif \
--output results.sarif
# CSV for spreadsheet analysis
python3 .claude/skills/vibe-security/scripts/reporter.py scan-results.json \
--format csv \
--output vulnerabilities.csv
# JSON for CI/CD pipelines
python3 .claude/skills/vibe-security/scripts/reporter.py scan-results.json \
--format json \
--output security-report.json
Advanced Capabilities
1. Semantic Analysis with AST
Uses Abstract Syntax Tree parsing for accurate vulnerability detection:
- Python: Full AST analysis with taint tracking
- JavaScript/TypeScript: Heuristic + pattern-based analysis
- Benefits: 90% reduction in false positives, context-aware
2. Data Flow Analysis
Tracks user input from sources to dangerous sinks:
- Detects SQL injection, XSS, command injection through data flow
- Identifies tainted variables and their propagation
- Supports Python and JavaScript/TypeScript
3. Compliance Mapping
Maps every vulnerability to industry standards:
- OWASP Top 10 2021
- CWE (Common Weakness Enumeration)
- MITRE ATT&CK techniques
- NIST cybersecurity framework
- PCI-DSS payment card requirements
4. Supply Chain Security
Protects against malicious dependencies:
- Typosquatting detection
- Dependency confusion attacks
- Malicious install scripts
- Network operations in packages
- Supports: npm, PyPI, Maven, Gradle, Cargo, Go, RubyGems, NuGet, Composer
5. Infrastructure as Code
Scans cloud infrastructure configurations:
- Terraform: AWS, Azure, GCP misconfigurations
- Kubernetes: Pod security, RBAC issues
- Docker: Dockerfile best practices
- CloudFormation: AWS template security
- Ansible: Playbook vulnerabilities
Security Check Reference
Available Vulnerability Checks
| Check Type |
Detects |
Example Issues |
sql-injection |
SQL/NoSQL injection |
String concatenation in queries, unsanitized input |
xss |
Cross-Site Scripting |
innerHTML usage, unescaped output, DOM manipulation |
command-injection |
OS command injection |
shell=True, exec with user input |
path-traversal |
Directory traversal |
Unsanitized file paths, ../.. in paths |
auth-issues |
Authentication flaws |
Weak passwords, missing MFA, insecure sessions |
authz-issues |
Authorization flaws |
Missing access controls, IDOR, privilege escalation |
crypto-failures |
Cryptographic issues |
MD5/SHA1 usage, weak keys, insecure random |
sensitive-data |
Data exposure |
Logging passwords, exposing PII, hardcoded secrets |
deserialization |
Unsafe deserialization |
pickle, eval, unserialize on user input |
security-config |
Misconfiguration |
CORS, CSP, headers, error messages |
dependencies |
Vulnerable packages |
CVEs in npm/pip/composer packages |
Language-Specific Security Patterns
JavaScript/TypeScript
// ✅ SECURE: Parameterized query
const user = await db.query("SELECT * FROM users WHERE id = $1", [userId]);
// ❌ VULNERABLE: SQL injection
const user = await db.query(`SELECT * FROM users WHERE id = ${userId}`);
// ✅ SECURE: Escape output
element.textContent = userInput;
const clean = DOMPurify.sanitize(htmlContent);
// ❌ VULNERABLE: XSS
element.innerHTML = userInput;
// ✅ SECURE: Input validation
const email = validator.isEmail(input) ? input : null;
// ❌ VULNERABLE: No validation
const email = req.body.email;
Python
# ✅ SECURE: Parameterized query
cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
# ❌ VULNERABLE: SQL injection
cursor.execute(f"SELECT * FROM users WHERE id = {user_id}")
# ✅ SECURE: Password hashing
import bcrypt
hashed = bcrypt.hashpw(password.encode(), bcrypt.gensalt())
# ❌ VULNERABLE: Plain text
user.password = password
# ✅ SECURE: Safe subprocess
subprocess.run(['ls', '-la', sanitized_dir])
# ❌ VULNERABLE: Command injection
os.system(f'ls -la {user_dir}')
PHP
// ✅ SECURE: Prepared statement
$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$userId]);
// ❌ VULNERABLE: SQL injection
$result = mysqli_query($conn, "SELECT * FROM users WHERE id = $userId");
// ✅ SECURE: Output escaping
echo htmlspecialchars($input, ENT_QUOTES, 'UTF-8');
// ❌ VULNERABLE: XSS
echo $userInput;
// ✅ SECURE: Password hashing
$hash = password_hash($password, PASSWORD_ARGON2ID);
// ❌ VULNERABLE: MD5
$hash = md5($password);
Example Workflow
User request: "Check my Express app for security vulnerabilities"
AI should:
# 1. Run security scan on the project
python3 .claude/skills/vibe-security/scripts/scan.py "./src" --language javascript
# 2. Analyze results by severity
# Output might show:
# CRITICAL: SQL Injection in src/controllers/user.js:45
# HIGH: XSS in src/views/profile.ejs:12
# MEDIUM: Missing rate limiting on /api/login
# LOW: Console.log contains sensitive data
# 3. Fix critical issues first
# - Review src/controllers/user.js:45
# - Replace string concatenation with parameterized query
# - Add input validation using validator library
# 4. Fix high severity issues
# - Review src/views/profile.ejs:12
# - Use <%- for HTML escaping or DOMPurify for rich content
# - Implement Content Security Policy
# 5. Fix medium severity issues
# - Install express-rate-limit middleware
# - Configure rate limiting on authentication endpoints
# - Add helmet for security headers
# 6. Fix low severity issues
# - Remove or redact sensitive console.log statements
# - Use proper logging library with log levels
# 7. Generate security report
python3 .claude/skills/vibe-security/scripts/report.py "./src"
Tips for Secure Development
- Validate all inputs - Use allowlists, not denylists
- Encode all outputs - Context-appropriate escaping
- Use parameterized queries - Never concatenate SQL
- Hash passwords properly - bcrypt, Argon2, scrypt
- Implement MFA - Add second factor authentication
- Use HTTPS everywhere - Encrypt data in transit
- Keep dependencies updated - Patch known vulnerabilities
- Follow principle of least privilege - Minimal necessary permissions
- Log security events - Monitor for attacks
- Regular security audits - Scan before every release
Integration Examples
Pre-commit Hook
#!/bin/bash
# .git/hooks/pre-commit
python3 .claude/skills/vibe-security/scripts/scan.py "." --fail-on critical
CI/CD Pipeline
GitHub Actions:
- name: Security Scan
run: |
python3 .claude/skills/vibe-security/scripts/scan.py "." --format json
GitLab CI:
security_scan:
script:
- python3 .claude/skills/vibe-security/scripts/scan.py "."
Resources
1---2name: vibe-security3description: Security intelligence for code analysis. Detects SQL injection, XSS, CSRF, authentication issues, crypto failures, and more. Actions: scan, analyze, fix, audit, check, review, secure, validate, sanitize, protect. Languages: JavaScript, TypeScript, Python, PHP, Java, Go, Ruby. Frameworks: Express, Django, Flask, Laravel, Spring, Rails. Vulnerabilities: SQL injection, XSS, CSRF, authentication bypass, authorization issues, command injection, path traversal, insecure deserialization, weak crypto, sensitive data exposure. Topics: input validation, output encoding, parameterized queries, password hashing, session management, CORS, CSP, security headers, rate limiting, dependency scanning.4---5
6# Vibe Security - Security Intelligence
7
8Comprehensive security scanner and code analyzer for identifying vulnerabilities across multiple languages and frameworks.
9
10## Prerequisites
11
12Check if Node.js is installed:
13
14```bash
15node --version
16```
17
18If Node.js is not installed, install it based on user's OS:
19
20**macOS:**
21
22```bash
23brew install node
24```
25
26**Ubuntu/Debian:**
27
28```bash
29sudo apt update && sudo apt install nodejs npm
30```
31
32**Windows:**
33
34```powershell
35winget install OpenJS.NodeJS
36```
37
38---
39
40## Recommended AI Models
41
42### For Best Security Analysis
43
44We recommend using these AI models with Vibe Security for optimal security vulnerability detection and code fixing:
45
46#### **Claude Opus 4.5** (Recommended)
47
48- Most advanced model for comprehensive security analysis
49- Superior reasoning capabilities for complex vulnerability detection
50- Exceptional at identifying subtle security flaws and attack vectors
51- Best for critical security audits, enterprise codebases, and production deployments
52- Provides the most thorough security remediation strategies
53
54#### **Claude Sonnet 4.5**
55
56- Excellent balance of speed and security analysis depth
57- Great at understanding security context and identifying vulnerabilities
58- Provides safe remediation strategies with detailed explanations
59- Ideal for daily development and most security workflows
60
61#### **Claude Opus 4**
62
63- Powerful for complex security audits and enterprise codebases
64- Deep reasoning capabilities for advanced vulnerability analysis
65- Best for critical security reviews and compliance requirements
66- Recommended for production deployments and sensitive applications
67
68#### **GPT-4o**
69
70- Fast and efficient for security-aware code generation
71- Good alternative with quick response times
72- Excellent for CI/CD integration and automated scanning
73- Cost-effective for large-scale projects
74
75#### **Claude Sonnet 4**
76
77- Faster alternative for quick security scans
78- Good balance of speed and accuracy
79- Suitable for rapid iteration during development
80
81#### **o1-preview**
82
83- Specialized for complex security architecture reviews
84- Advanced reasoning for intricate vulnerability chains
85- Best for security research and deep code audits
86
87#### **GPT-4o-mini**
88
89- Quick checks and preliminary scans
90- Most cost-effective option
91- Good for learning and educational use cases
92
93> **Note**: If you're not using one of the recommended models above, consider upgrading for better security analysis results. Lower-tier models may miss subtle vulnerabilities or provide less accurate fix suggestions.
94
95---
96
97## How to Use This Skill
98
99When user requests security work (scan, analyze, fix, audit, check, review vulnerabilities), follow this workflow:
100
101### Step 1: Analyze Security Context
102
103Extract key information from user request:
104
105- **Language**: JavaScript, Python, Java, PHP, etc.
106- **Framework**: Express, Django, Spring, Laravel, etc.
107- **Vulnerability type**: SQL injection, XSS, CSRF, authentication, etc.
108- **Scope**: Single file, directory, or full project
109
110### Step 2: Run Security Analysis
111
112**Advanced Analysis (Recommended):**
113
114```bash
115# AST-based semantic analysis (90% fewer false positives)
116python3 .claude/skills/vibe-security/scripts/ast_analyzer.py "<file>"
117
118# Data flow analysis (tracks tainted data from sources to sinks)
119python3 .claude/skills/vibe-security/scripts/dataflow_analyzer.py "<file>"
120
121# CVE & dependency vulnerability scanning
122python3 .claude/skills/vibe-security/scripts/cve_integration.py .
123
124# Supply chain security (malicious packages, typosquatting)
125python3 .claude/skills/vibe-security/scripts/cve_integration.py . --ecosystem npm
126
127# Infrastructure as Code security
128grep -r "publicly_accessible.*=.*true" . --include="*.tf"
129grep -r "privileged:.*true" . --include="*.yaml"
130```
131
132**Quick Pattern Scanning:**
133
134```bash
135# Use search utility for specific patterns
136python3 .claude/skills/vibe-security/scripts/search.py "sql-injection" --domain pattern
137python3 .claude/skills/vibe-security/scripts/search.py "javascript" --domain pattern --severity critical
138```
139
140### Step 3: Analyze Vulnerabilities by Severity
141
142**Critical** (Fix immediately):
143
144- SQL Injection
145- Remote Code Execution
146- Authentication Bypass
147- Hardcoded Secrets
148
149**High** (Fix soon):
150
151- XSS (Cross-Site Scripting)
152- CSRF
153- Insecure Cryptography
154- Authorization Issues
155
156**Medium** (Fix in sprint):
157
158- Missing Input Validation
159- Information Disclosure
160- Weak Password Policy
161- Missing Security Headers
162
163**Low** (Technical debt):
164
165- Code Quality Issues
166- Best Practice Violations
167- Performance Concerns
168
169### Step 4: Get Fix Suggestions
170
171**ML-Based Fix Engine:**
172
173```bash
174# Get intelligent fix recommendations with test generation
175python3 .claude/skills/vibe-security/scripts/fix_engine.py \
176 --type sql-injection \
177 --language javascript \
178 --code "db.query(\`SELECT * FROM users WHERE id = \${userId}\`)"
179
180# Output includes:
181# - Fixed code with context-aware corrections
182# - Detailed explanation of the fix
183# - Auto-generated security test
184# - Additional recommendations
185# - Confidence score (0-100%)
186```
187
188### Step 5: Apply Security Fixes
189
190**Auto-Fix with Rollback Support:**
191
192```bash
193# Apply fix with automatic backup
194python3 .claude/skills/vibe-security/scripts/autofix_engine.py apply \
195 --file src/database.js \
196 --line 45 \
197 --type sql-injection \
198 --original "db.query(\`SELECT * FROM users WHERE id = \${userId}\`)" \
199 --fixed "db.query('SELECT * FROM users WHERE id = $1', [userId])"
200
201# Test your changes
202npm test
203
204# Rollback if needed (safe to experiment!)
205python3 .claude/skills/vibe-security/scripts/autofix_engine.py rollback
206
207# View fix history
208python3 .claude/skills/vibe-security/scripts/autofix_engine.py history
209```
210
211**Systematic Manual Fixes:**
212
2131. **Critical vulnerabilities first**
2142. **Add input validation** - Whitelist, type checking, length limits
2153. **Secure outputs** - Escape, encode, sanitize
2164. **Fix authentication/authorization** - Strong passwords, MFA, RBAC
2175. **Update cryptography** - Modern algorithms, secure random
2186. **Test thoroughly** - Verify fixes don't break functionality
2197. **Re-scan** - Confirm all vulnerabilities are resolved
220
221### Step 6: Generate Reports
222
223**Multiple Report Formats:**
224
225```bash
226# Beautiful HTML report with charts and statistics
227python3 .claude/skills/vibe-security/scripts/reporter.py scan-results.json \
228 --format html \
229 --output security-report.html
230
231# SARIF format for GitHub Code Scanning integration
232python3 .claude/skills/vibe-security/scripts/reporter.py scan-results.json \
233 --format sarif \
234 --output results.sarif
235
236# CSV for spreadsheet analysis
237python3 .claude/skills/vibe-security/scripts/reporter.py scan-results.json \
238 --format csv \
239 --output vulnerabilities.csv
240
241# JSON for CI/CD pipelines
242python3 .claude/skills/vibe-security/scripts/reporter.py scan-results.json \
243 --format json \
244 --output security-report.json
245```
246
247---
248
249## Advanced Capabilities
250
251### 1. Semantic Analysis with AST
252
253Uses Abstract Syntax Tree parsing for accurate vulnerability detection:
254
255- **Python**: Full AST analysis with taint tracking
256- **JavaScript/TypeScript**: Heuristic + pattern-based analysis
257- **Benefits**: 90% reduction in false positives, context-aware
258
259### 2. Data Flow Analysis
260
261Tracks user input from sources to dangerous sinks:
262
263- Detects SQL injection, XSS, command injection through data flow
264- Identifies tainted variables and their propagation
265- Supports Python and JavaScript/TypeScript
266
267### 3. Compliance Mapping
268
269Maps every vulnerability to industry standards:
270
271- **OWASP Top 10 2021**
272- **CWE** (Common Weakness Enumeration)
273- **MITRE ATT&CK** techniques
274- **NIST** cybersecurity framework
275- **PCI-DSS** payment card requirements
276
277### 4. Supply Chain Security
278
279Protects against malicious dependencies:
280
281- Typosquatting detection
282- Dependency confusion attacks
283- Malicious install scripts
284- Network operations in packages
285- Supports: npm, PyPI, Maven, Gradle, Cargo, Go, RubyGems, NuGet, Composer
286
287### 5. Infrastructure as Code
288
289Scans cloud infrastructure configurations:
290
291- **Terraform**: AWS, Azure, GCP misconfigurations
292- **Kubernetes**: Pod security, RBAC issues
293- **Docker**: Dockerfile best practices
294- **CloudFormation**: AWS template security
295- **Ansible**: Playbook vulnerabilities
296
297---
298
299## Security Check Reference
300
301### Available Vulnerability Checks
302
303| Check Type | Detects | Example Issues |
304| ------------------- | ---------------------- | --------------------------------------------------- |
305| `sql-injection` | SQL/NoSQL injection | String concatenation in queries, unsanitized input |
306| `xss` | Cross-Site Scripting | innerHTML usage, unescaped output, DOM manipulation |
307| `command-injection` | OS command injection | shell=True, exec with user input |
308| `path-traversal` | Directory traversal | Unsanitized file paths, ../.. in paths |
309| `auth-issues` | Authentication flaws | Weak passwords, missing MFA, insecure sessions |
310| `authz-issues` | Authorization flaws | Missing access controls, IDOR, privilege escalation |
311| `crypto-failures` | Cryptographic issues | MD5/SHA1 usage, weak keys, insecure random |
312| `sensitive-data` | Data exposure | Logging passwords, exposing PII, hardcoded secrets |
313| `deserialization` | Unsafe deserialization | pickle, eval, unserialize on user input |
314| `security-config` | Misconfiguration | CORS, CSP, headers, error messages |
315| `dependencies` | Vulnerable packages | CVEs in npm/pip/composer packages |
316
317---
318
319## Language-Specific Security Patterns
320
321### JavaScript/TypeScript
322
323```javascript
324// ✅ SECURE: Parameterized query
325const user = await db.query("SELECT * FROM users WHERE id = $1", [userId]);
326
327// ❌ VULNERABLE: SQL injection
328const user = await db.query(`SELECT * FROM users WHERE id = ${userId}`);
329
330// ✅ SECURE: Escape output
331element.textContent = userInput;
332const clean = DOMPurify.sanitize(htmlContent);
333
334// ❌ VULNERABLE: XSS
335element.innerHTML = userInput;
336
337// ✅ SECURE: Input validation
338const email = validator.isEmail(input) ? input : null;
339
340// ❌ VULNERABLE: No validation
341const email = req.body.email;
342```
343
344### Python
345
346```python
347# ✅ SECURE: Parameterized query
348cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
349
350# ❌ VULNERABLE: SQL injection
351cursor.execute(f"SELECT * FROM users WHERE id = {user_id}")
352
353# ✅ SECURE: Password hashing
354import bcrypt
355hashed = bcrypt.hashpw(password.encode(), bcrypt.gensalt())
356
357# ❌ VULNERABLE: Plain text
358user.password = password
359
360# ✅ SECURE: Safe subprocess
361subprocess.run(['ls', '-la', sanitized_dir])
362
363# ❌ VULNERABLE: Command injection
364os.system(f'ls -la {user_dir}')
365```
366
367### PHP
368
369```php
370// ✅ SECURE: Prepared statement
371$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
372$stmt->execute([$userId]);
373
374// ❌ VULNERABLE: SQL injection
375$result = mysqli_query($conn, "SELECT * FROM users WHERE id = $userId");
376
377// ✅ SECURE: Output escaping
378echo htmlspecialchars($input, ENT_QUOTES, 'UTF-8');
379
380// ❌ VULNERABLE: XSS
381echo $userInput;
382
383// ✅ SECURE: Password hashing
384$hash = password_hash($password, PASSWORD_ARGON2ID);
385
386// ❌ VULNERABLE: MD5
387$hash = md5($password);
388```
389
390---
391
392## Example Workflow
393
394**User request:** "Check my Express app for security vulnerabilities"
395
396**AI should:**
397
398```bash
399# 1. Run security scan on the project
400python3 .claude/skills/vibe-security/scripts/scan.py "./src" --language javascript
401
402# 2. Analyze results by severity
403# Output might show:
404# CRITICAL: SQL Injection in src/controllers/user.js:45
405# HIGH: XSS in src/views/profile.ejs:12
406# MEDIUM: Missing rate limiting on /api/login
407# LOW: Console.log contains sensitive data
408
409# 3. Fix critical issues first
410# - Review src/controllers/user.js:45
411# - Replace string concatenation with parameterized query
412# - Add input validation using validator library
413
414# 4. Fix high severity issues
415# - Review src/views/profile.ejs:12
416# - Use <%- for HTML escaping or DOMPurify for rich content
417# - Implement Content Security Policy
418
419# 5. Fix medium severity issues
420# - Install express-rate-limit middleware
421# - Configure rate limiting on authentication endpoints
422# - Add helmet for security headers
423
424# 6. Fix low severity issues
425# - Remove or redact sensitive console.log statements
426# - Use proper logging library with log levels
427
428# 7. Generate security report
429python3 .claude/skills/vibe-security/scripts/report.py "./src"
430```
431
432---
433
434## Tips for Secure Development
435
4361. **Validate all inputs** - Use allowlists, not denylists
4372. **Encode all outputs** - Context-appropriate escaping
4383. **Use parameterized queries** - Never concatenate SQL
4394. **Hash passwords properly** - bcrypt, Argon2, scrypt
4405. **Implement MFA** - Add second factor authentication
4416. **Use HTTPS everywhere** - Encrypt data in transit
4427. **Keep dependencies updated** - Patch known vulnerabilities
4438. **Follow principle of least privilege** - Minimal necessary permissions
4449. **Log security events** - Monitor for attacks
44510. **Regular security audits** - Scan before every release
446
447---
448
449## Integration Examples
450
451### Pre-commit Hook
452
453```bash
454#!/bin/bash
455# .git/hooks/pre-commit
456python3 .claude/skills/vibe-security/scripts/scan.py "." --fail-on critical
457```
458
459### CI/CD Pipeline
460
461**GitHub Actions:**
462
463```yaml
464- name: Security Scan
465 run: |
466 python3 .claude/skills/vibe-security/scripts/scan.py "." --format json
467```
468
469**GitLab CI:**
470
471```yaml
472security_scan:
473 script:
474 - python3 .claude/skills/vibe-security/scripts/scan.py "."
475```
476
477---
478
479## Resources
480
481- [OWASP Top 10](https://owasp.org/www-project-top-ten/)
482- [CWE Top 25](https://cwe.mitre.org/top25/)
483- [SANS Top 25](https://www.sans.org/top25-software-errors/)
484- [Security Checklist](../../../SECURITY_CHECKLIST.md)