when-auditing-security-use-security-analyzer
Comprehensive security auditing across static analysis, dynamic testing, dependency vulnerabilities, secrets detection, and OWASP compliance
What this skill does
# Security Analyzer - Comprehensive Security Auditing Skill
## Overview
This skill provides multi-vector security analysis combining static code analysis, dynamic testing, dependency auditing, secrets detection, and OWASP Top 10 compliance checking. Uses coordinated agents with validation gates between phases.
## Architecture
```
Security Manager (Coordinator)
├─→ Phase 1: Static Analysis (Code Analyzer)
├─→ Phase 2: Dynamic Testing (Tester)
├─→ Phase 3: Dependency Audit (Security Manager)
├─→ Phase 4: Secrets Detection (Code Analyzer)
└─→ Phase 5: Compliance Check (Security Manager)
```
## Phase 1: Static Code Analysis
### Objective
Identify code-level vulnerabilities, security anti-patterns, and unsafe practices.
### Security Manager Setup
```bash
# Initialize security audit session
npx claude-flow@alpha hooks pre-task --description "Security static analysis initialization"
npx claude-flow@alpha hooks session-restore --session-id "security-audit-${DATE}"
# Set up memory namespace
npx claude-flow@alpha memory store \
--key "swarm/security/config" \
--value '{
"scan_type": "static",
"severity_threshold": "medium",
"frameworks": ["owasp", "cwe"],
"timestamp": "'$(date -Iseconds)'"
}'
```
### Code Analyzer Execution
```bash
# Spawn code analyzer agent for static analysis
# Agent performs:
# 1. SQL Injection Detection
npx claude-flow@alpha hooks pre-task --description "SQL injection vulnerability scan"
# Scan patterns:
# ❌ VULNERABLE:
# const query = "SELECT * FROM users WHERE id = " + userId;
# db.query("SELECT * FROM " + tableName);
#
# ✅ SECURE:
# const query = "SELECT * FROM users WHERE id = ?";
# db.query(query, [userId]);
grep -rn "\.query\|\.exec" --include="*.js" --include="*.ts" . | \
grep -v "?" | grep -v "\$[0-9]" > /tmp/sql-findings.txt
# 2. XSS Vulnerability Detection
# ❌ VULNERABLE:
# element.innerHTML = userInput;
# eval(userInput);
# new Function(userInput)();
#
# ✅ SECURE:
# element.textContent = userInput;
# JSON.parse(sanitizedInput);
grep -rn "innerHTML\|eval\|new Function" --include="*.js" --include="*.jsx" . > /tmp/xss-findings.txt
# 3. Path Traversal Detection
# ❌ VULNERABLE:
# fs.readFile(userPath);
# require(userInput);
#
# ✅ SECURE:
# const safePath = path.join(baseDir, path.normalize(userPath));
# if (!safePath.startsWith(baseDir)) throw new Error('Invalid path');
grep -rn "readFile\|writeFile\|require.*\+" --include="*.js" . > /tmp/path-traversal-findings.txt
# 4. Insecure Cryptography
# ❌ VULNERABLE:
# crypto.createHash('md5');
# crypto.createCipher('des', key);
#
# ✅ SECURE:
# crypto.createHash('sha256');
# crypto.createCipheriv('aes-256-gcm', key, iv);
grep -rn "md5\|sha1\|des\|rc4" --include="*.js" --include="*.ts" . > /tmp/crypto-findings.txt
# Store findings in memory
npx claude-flow@alpha memory store \
--key "swarm/security/static-analysis" \
--value "$(cat /tmp/*-findings.txt | jq -Rs '{findings: ., timestamp: now}')"
npx claude-flow@alpha hooks post-task --task-id "static-analysis"
```
### Validation Gate 1
```bash
# Check if critical vulnerabilities found
CRITICAL_COUNT=$(cat /tmp/*-findings.txt | grep -c ".")
if [ "$CRITICAL_COUNT" -gt 0 ]; then
echo "⚠️ GATE FAILED: $CRITICAL_COUNT potential vulnerabilities found"
npx claude-flow@alpha hooks notify --message "Static analysis found $CRITICAL_COUNT issues - review required"
# Continue but flag for review
fi
```
## Phase 2: Dynamic Security Testing
### Objective
Runtime vulnerability detection through active testing and fuzzing.
### Tester Agent Execution
```bash
npx claude-flow@alpha hooks pre-task --description "Dynamic security testing"
# 1. Authentication Bypass Testing
cat > /tmp/auth-test.js << 'EOF'
// Test suite for authentication vulnerabilities
const axios = require('axios');
async function testAuthBypass() {
const tests = [
// SQL Injection in auth
{ username: "admin'--", password: "anything" },
{ username: "admin' OR '1'='1", password: "" },
// JWT manipulation
{ token: "eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0..." }, // None algorithm
// Session fixation
{ session: "../../admin-session" },
// NoSQL injection
{ username: { "$ne": null }, password: { "$ne": null } }
];
const vulnerabilities = [];
for (const test of tests) {
try {
const response = await axios.post('http://localhost:3000/login', test);
if (response.status === 200) {
vulnerabilities.push({
type: 'AUTH_BYPASS',
severity: 'CRITICAL',
payload: test,
description: 'Authentication bypass successful'
});
}
} catch (e) {
// Expected - auth failed
}
}
return vulnerabilities;
}
module.exports = { testAuthBypass };
EOF
# 2. CSRF Testing
cat > /tmp/csrf-test.js << 'EOF'
async function testCSRF() {
const response = await axios.post('http://localhost:3000/api/transfer', {
to: 'attacker',
amount: 1000
}, {
headers: {
'Origin': 'http://evil.com',
'Referer': 'http://evil.com'
}
});
// Should be rejected without CSRF token
if (response.status === 200) {
return {
type: 'CSRF',
severity: 'HIGH',
description: 'Missing CSRF protection on state-changing operation'
};
}
}
EOF
# 3. Rate Limiting Test
cat > /tmp/rate-limit-test.js << 'EOF'
async function testRateLimit() {
const requests = [];
for (let i = 0; i < 1000; i++) {
requests.push(axios.get('http://localhost:3000/api/data'));
}
const responses = await Promise.all(requests);
const successCount = responses.filter(r => r.status === 200).length;
if (successCount > 100) {
return {
type: 'NO_RATE_LIMIT',
severity: 'MEDIUM',
description: `No rate limiting detected - ${successCount}/1000 requests succeeded`
};
}
}
EOF
# Execute dynamic tests
node /tmp/auth-test.js > /tmp/dynamic-findings.json
node /tmp/csrf-test.js >> /tmp/dynamic-findings.json
node /tmp/rate-limit-test.js >> /tmp/dynamic-findings.json
npx claude-flow@alpha memory store \
--key "swarm/security/dynamic-testing" \
--value "$(cat /tmp/dynamic-findings.json)"
npx claude-flow@alpha hooks post-task --task-id "dynamic-testing"
```
### Validation Gate 2
```bash
CRITICAL_RUNTIME=$(jq '[.[] | select(.severity == "CRITICAL")] | length' /tmp/dynamic-findings.json)
if [ "$CRITICAL_RUNTIME" -gt 0 ]; then
echo "🚨 GATE FAILED: $CRITICAL_RUNTIME critical runtime vulnerabilities"
exit 1 # Hard stop for critical runtime issues
fi
```
## Phase 3: Dependency Security Audit
### Objective
Identify known vulnerabilities (CVEs) in dependencies and supply chain risks.
### Security Manager Execution
```bash
npx claude-flow@alpha hooks pre-task --description "Dependency vulnerability scan"
# 1. NPM Audit
npm audit --json > /tmp/npm-audit.json 2>&1 || true
# 2. Check for outdated packages with known vulnerabilities
npm outdated --json > /tmp/outdated.json 2>&1 || true
# 3. License compliance check
npx license-checker --json > /tmp/licenses.json 2>&1 || true
# 4. Check for malicious packages (typosquatting)
cat package.json | jq -r '.dependencies | keys[]' | while read pkg; do
# Check against known malicious package database
if grep -q "$pkg" /tmp/malicious-packages.txt 2>/dev/null; then
echo "⚠️ MALICIOUS PACKAGE DETECTED: $pkg"
fi
done > /tmp/malicious-check.txt
# 5. SBOM (Software Bill of Materials) generation
npx @cyclonedx/cyclonedx-npm --output-file /tmp/sbom.json
# Analyze CVE severity
jq '{
critical: [.vulnerabilities | to_entries[] | select(.value.severity == "critical")],
high: [.vulnerabilities | to_entries[] | select(.value.severity == "high")],
moderate: [.vulnerabilities | to_entries[] | select(.value.severity == "moderate")],
low: [.vulnerabilities | to_entries[] | select(.value.severity == "low")],
total: .metadata.vulnerabilities
}' /tmp/npm-audit.json > /tmp/dependency-summary.json
npx claude-flow@Related in Security
mac-ops
IncludedComprehensive macOS workstation operations — diagnose kernel panics, identify failing drives, audit launchd startup items, decode wake reasons, triage TCC permission denials, manage APFS snapshots, recover from no-boot. Use for: Mac is slow, slow bootup, won't boot, kernel panic, kernel_task hot, mds_stores CPU, photoanalysisd, cloudd, login loop, gray screen, sleep wake failure, drive failing, IO errors, APFS snapshots eating space, Time Machine local snapshots, Spotlight indexing, launchd, LaunchAgent, LaunchDaemon, login items, TCC permissions, Full Disk Access, Screen Recording denied, Gatekeeper, quarantine, com.apple.quarantine, app is damaged, helper tool, /Library/PrivilegedHelperTools, pmset, wake reasons, dark wake, sysdiagnose, panic.ips, DiagnosticReports, configuration profile, MDM profile, remote diagnostics over SSH.
a11y-audit
IncludedRun accessibility audits on web projects combining automated scanning (axe-core, Lighthouse) with WCAG 2.1 AA compliance mapping, manual check guidance, and structured reporting. Output is configurable: markdown report only, markdown plus machine-readable JSON, or markdown plus issue tracker integration. Use this skill whenever the user mentions "accessibility audit", "a11y audit", "WCAG audit", "accessibility check", "compliance scan", or asks to check a web project for accessibility issues. Also trigger when the user wants to verify WCAG conformance or map findings to a specific standard (CAN-ASC-6.2, EN 301 549, ADA/AODA).
erpclaw
IncludedAI-native ERP system with self-extending OS. Full accounting, invoicing, inventory, purchasing, tax, billing, HR, payroll, advanced accounting (ASC 606/842, intercompany, consolidation), and financial reporting. 413 actions across 14 domains, 43 expansion modules. Constitutional guardrails, adversarial audit, schema migration. Double-entry GL, immutable audit trail, US GAAP.
assess
IncludedAssesses and rates quality 0-10 across multiple dimensions (correctness, maintainability, security, performance, testability, simplicity) with pros/cons analysis. Compares against project conventions and prior decisions from memory. Produces structured evaluation reports with actionable improvement suggestions. Use when evaluating code, designs, architectures, or comparing alternative approaches.
spring-boot-security-jwt
IncludedProvides JWT authentication and authorization patterns for Spring Boot 3.5.x covering token generation with JJWT, Bearer/cookie authentication, database/OAuth2 integration, and RBAC/permission-based access control using Spring Security 6.x. Use when implementing authentication or authorization in Spring Boot applications.
code-hardcode-audit
IncludedDetect hardcoded values, magic numbers, and leaked secrets. TRIGGERS - hardcode audit, magic numbers, PLR2004, secret scanning.