security-audit
Detect common security vulnerabilities in code. Covers OWASP patterns, SQL injection, bare excepts, shell injection. Framework-agnostic.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Detect common security vulnerabilities in code. Covers OWASP patterns, SQL injection, bare excepts, shell injection. Framework-agnostic.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Generic BAML patterns for type-safe LLM prompting. Covers schema design, DTO generation, client wrappers, and cross-language codegen. Framework-agnostic.
Browser automation for documentation discovery. Use when curl fails on JS-rendered sites, when detecting available browser tools, or when configuring browser-based documentation collection.
C4 architectural modeling for documenting software architecture. Use when creating architecture diagrams, planning new systems, communicating with stakeholders, or conducting architecture reviews.
Debug and analyze web applications using Chrome DevTools MCP. Use for console log inspection, network request monitoring, performance analysis, and debugging authenticated sessions. For basic browser automation (screenshots, form filling), use browser-discovery skill instead.
Patterns and techniques for analyzing brownfield codebases. Use when onboarding to unfamiliar code, preparing for refactoring, conducting architecture reviews, or identifying technical debt.
Detect new imports in modified files and auto-install missing dependencies. Works with npm, uv, pip, cargo, go mod, and other package managers. Triggers after code implementation to keep manifests in sync.
| name | security-audit |
| description | Detect common security vulnerabilities in code. Covers OWASP patterns, SQL injection, bare excepts, shell injection. Framework-agnostic. |
Detect common security vulnerabilities during code review and development. Based on OWASP guidelines and common vulnerability patterns.
This skill is framework-generic. It provides universal security patterns:
| Variable | Default | Description |
|---|---|---|
| SEVERITY_THRESHOLD | medium | Minimum severity to report |
| SCAN_DEPTH | 3 | Directory depth for scanning |
| INCLUDE_TESTS | false | Include test files in scan |
MANDATORY - Follow the Workflow steps below in order.
If you're about to:
except: blocksSTOP -> Use parameterized queries -> Add specific exception handling -> Then proceed
./cookbook/sql-injection.md./cookbook/bare-except.md./cookbook/shell-injection.mdBAD - String concatenation:
# VULNERABLE
query = f"SELECT * FROM users WHERE id = {user_id}"
cursor.execute(query)
query = "SELECT * FROM users WHERE name = '" + name + "'"
GOOD - Parameterized queries:
# SAFE
cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
# SQLAlchemy
session.query(User).filter(User.id == user_id).first()
# Prisma
await prisma.user.findUnique({ where: { id: userId } })
BAD - Catches everything:
# VULNERABLE - hides bugs, catches KeyboardInterrupt
try:
risky_operation()
except:
pass
# VULNERABLE - too broad
except Exception:
log.error("Something failed")
GOOD - Specific exceptions:
# SAFE - specific exceptions
try:
risky_operation()
except ValueError as e:
log.warning(f"Invalid value: {e}")
except ConnectionError as e:
log.error(f"Connection failed: {e}")
raise
BAD - User input in shell:
# VULNERABLE
os.system(f"grep {user_input} /var/log/app.log")
import subprocess
subprocess.run(f"ls {directory}", shell=True)
GOOD - Avoid shell, use lists:
# SAFE - no shell
subprocess.run(["grep", user_input, "/var/log/app.log"])
# SAFE - validated input
if not re.match(r'^[a-zA-Z0-9_-]+$', directory):
raise ValueError("Invalid directory name")
subprocess.run(["ls", directory])
BAD - User input in paths:
# VULNERABLE
path = f"/uploads/{user_filename}"
with open(path) as f:
return f.read()
GOOD - Validate and sanitize:
# SAFE
from pathlib import Path
upload_dir = Path("/uploads").resolve()
requested = (upload_dir / user_filename).resolve()
if not requested.is_relative_to(upload_dir):
raise ValueError("Path traversal attempt")
with open(requested) as f:
return f.read()
BAD - Secrets in code:
# VULNERABLE
API_KEY = "sk-1234567890abcdef"
DB_PASSWORD = "super_secret_password"
GOOD - Environment variables:
# SAFE
import os
API_KEY = os.environ["API_KEY"]
DB_PASSWORD = os.environ["DB_PASSWORD"]
# Or with defaults for development
API_KEY = os.getenv("API_KEY", "dev-key-only")
BAD - Unsanitized output:
<!-- VULNERABLE -->
<div>{{ user_input }}</div>
GOOD - Proper escaping:
<!-- SAFE - auto-escaped in most frameworks -->
<div>{{ user_input | e }}</div>
<!-- Or use textContent in JS -->
element.textContent = userInput; // Safe
| Severity | Impact | Examples |
|---|---|---|
| CRITICAL | Data breach, RCE | SQL injection, shell injection |
| HIGH | Data exposure, privilege escalation | Path traversal, hardcoded secrets |
| MEDIUM | Information disclosure | Verbose errors, bare excepts |
| LOW | Best practice violation | Missing input validation |
VULNERABLE_PATTERNS = {
"sql_injection": [
r'execute\([\'"].*%s.*[\'"].*%', # % formatting in SQL
r'execute\(f[\'"]', # f-string in SQL
r'execute\([\'"].*\+', # String concat in SQL
],
"shell_injection": [
r'os\.system\(', # os.system
r'subprocess\..*shell=True', # shell=True
r'eval\(', # eval
r'exec\(', # exec
],
"bare_except": [
r'except\s*:', # bare except
],
"hardcoded_secrets": [
r'password\s*=\s*[\'"]', # password = "..."
r'api_key\s*=\s*[\'"]', # api_key = "..."
r'secret\s*=\s*[\'"]', # secret = "..."
],
}
const VULNERABLE_PATTERNS = {
sqlInjection: [
/`SELECT.*\$\{/, // Template literal in SQL
/"SELECT.*" \+ /, // String concat in SQL
],
xss: [
/innerHTML\s*=/, // innerHTML assignment
/dangerouslySetInnerHTML/, // React dangerous prop
],
shellInjection: [
/exec\([`'"]/, // child_process.exec
/spawn\(.*shell:\s*true/, // shell: true
],
};
Check these high-risk areas first:
- Authentication/authorization code
- Database queries
- File operations
- External API calls
- User input handling
- Serialization/deserialization
For each source file:
Match against vulnerability patterns
Record file, line, pattern matched
Assess severity
# Security Audit Report
## Summary
- CRITICAL: 2
- HIGH: 5
- MEDIUM: 12
## Critical Issues
### 1. SQL Injection in user_service.py:45
Pattern: f-string in execute()
```python
cursor.execute(f"SELECT * FROM users WHERE id = {user_id}")
Fix: Use parameterized query
cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
## Integration
### With /ai-dev-kit:execute-lane
Run security audit in code-related lanes:
```markdown
Lane: SL-API
Post-implementation checks:
1. ✓ Tests pass
2. ✓ Lint clean
3. ⚠️ Security audit: 2 MEDIUM issues
Review security findings before merge.
- name: Security Audit
run: |
# Check for vulnerable patterns
grep -rn "execute(f" --include="*.py" && exit 1 || true
grep -rn "shell=True" --include="*.py" && exit 1 || true
grep -rn "except:" --include="*.py" && echo "Warning: bare except found"