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