xiaohongshu
xiaohongshu
audit-security
Run a single-session security audit on the codebase
Full skill instructions
| Condition | Mode | Time |
|---|---|---|
| Task tool available + no context pressure | Parallel | ~15 min |
| Task tool unavailable | Sequential | ~60 min |
| Context running low (<20% remaining) | Sequential | ~60 min |
| User requests sequential | Sequential | ~60 min |
When to use: Task tool available, sufficient context budget, no S0/S1 in scope
Focus Areas:
Files:
app/api/**/*.ts (API routes)middleware.tslib/auth*.tsFocus Areas:
Files:
package.json, package-lock.jsonfunctions/package.jsonFocus Areas:
Files:
firestore.rules, storage.rulesfirebase.jsonfunctions/src/**/*.tsnext.config.mjsFocus Areas:
Files:
.claude/ configscrypto, random, hash patternsInvoke all 4 agents in a SINGLE Task message:
Task 1: vulnerability-scanner agent - audit auth, input validation, OWASP Task
2: supply-chain-auditor agent - audit dependencies, npm packages Task 3:
framework-security-auditor agent - audit Firebase, Next.js, headers Task 4:
ai-code-security-auditor agent - audit AI patterns, crypto, files
When to use: Task tool unavailable, context limits, or user preference
Execution Order (priority-first):
Total: ~60 min (vs ~15 min parallel)
Checkpointing: After each category, write intermediate findings to file before continuing. This protects against context loss.
{
"started_at": "ISO timestamp",
"categories_completed": ["Auth", "Input"],
"current_category": "DataProtection",
"findings_count": 24,
"last_file_written": "stage-2-findings.jsonl"
}
${AUDIT_DIR}/checkpoint.json.jsonl file (not overwrite)Step 0: Episodic Memory Search (Session #128)
Before running security audit, search for context from past security sessions:
// Search for past security audit findings
mcp__plugin_episodic -
memory_episodic -
memory__search({
query: ["security audit", "S0", "vulnerability"],
limit: 5,
});
// Search for specific vulnerability patterns addressed before
mcp__plugin_episodic -
memory_episodic -
memory__search({
query: ["OWASP", "injection", "auth bypass"],
limit: 5,
});
Why this matters:
Step 1: Check Thresholds
Run npm run review:check and report results. Check for security-sensitive file
changes.
Step 2: Gather Current Baselines
Collect these metrics by running commands:
# Dependency vulnerabilities (extract summary without truncating JSON)
npm audit --json 2>/dev/null | node -e '
try {
const d = JSON.parse(require("fs").readFileSync(0,"utf8"));
console.log(JSON.stringify(d.metadata?.vulnerabilities ?? d.vulnerabilities ?? {}, null, 2));
} catch (e) {
console.log("{\"error\": \"Invalid JSON from npm audit\"}");
}
'
# Security lint warnings
npm run lint 2>&1 | grep -i "security" | head -10
# Pattern compliance (security patterns)
npm run patterns:check 2>&1
# Check for .env files (existence only - no permission/owner metadata needed)
ls .env* 2>/dev/null || echo "No .env files found"
Step 2b: Query SonarCloud Security (if MCP available)
If mcp__sonarcloud__get_security_hotspots is available:
status: "TO_REVIEW" to get unresolved security hotspotsIf mcp__sonarcloud__get_issues is available:
types: "VULNERABILITY" to get security-specific issuesThis provides real-time security issue data from static analysis.
Step 3: Load False Positives Database
Read docs/audits/FALSE_POSITIVES.jsonl and filter findings matching:
securityexpires date passed)Note patterns to exclude from final findings.
Step 4: Check Template Currency
Read docs/templates/MULTI_AI_SECURITY_AUDIT_PLAN_TEMPLATE.md and verify:
If outdated, note discrepancies but proceed with current values.
Focus Areas (12 Categories):
Authentication & Authorization (auth checks, role validation, IDOR, privilege escalation)
Input Validation & Injection Prevention:
Data Protection (encryption, PII handling, secrets, overly verbose errors)
Firebase/Firestore Security (rules, Cloud Functions, rate limiting, replay protection)
Dependency Security & Supply Chain:
OWASP Top 10 Coverage
Hosting & Headers Security:
Next.js/Framework-Specific:
File Handling Security:
Crypto & Randomness:
Product/UX Security Risks:
AI-Generated Code & Agent Security:
AI Security Patterns (AI-Codebase Specific):
.claude/ configs, agent prompts, LLM
integrations with user input (S0)any types, * CORS, overly
permissive rules (S1)For each category:
Security-Sensitive Files to Check:
firestore.rules, storage.rulesfunctions/src/**/*.tslib/firebase*.ts, lib/auth*.tsmiddleware.ts, next.config.mjsfirebase.json (hosting headers, rewrites).env* files (environment variables)package.json, package-lock.json (supply chain).claude/ configs (agent security)Additional Checks for Vibe-Coded Apps:
eval(, new Function(, Function( - dynamic code executiondangerouslySetInnerHTML - XSS vectorsNEXT_PUBLIC_ env vars - ensure no secrets leakedprocess.env in client components - boundary leakspostinstall, preinstall in package.json - supply chain.claude/ that could be prompt injectionScope:
app/, components/, lib/, functions/, firestore.rules,
firebase.json, .claude/node_modules/, .next/, docs/, tests/All findings MUST include:
lib/auth.ts:45)Confidence Levels:
S0/S1 findings require:
Before finalizing findings, cross-reference with:
docs/audits/single-session/security/ for duplicate
findingsFindings without tool validation should note: "cross_ref": "MANUAL_ONLY"
For all S0 (Critical) and S1 (High) findings:
Document dual-pass result in finding: "verified": "DUAL_PASS_CONFIRMED" or
"verified": "DOWNGRADED_TO_S2"
1. Markdown Summary (display to user):
## Security Audit - [DATE]
### Baselines
- npm audit: X vulnerabilities (Y critical, Z high)
- Security patterns: X violations
- Security-sensitive files: X changed since last audit
### Findings Summary
| Severity | Count | OWASP Category | Confidence |
| -------- | ----- | -------------- | ----------- |
| S0 | X | ... | HIGH/MEDIUM |
| S1 | X | ... | HIGH/MEDIUM |
| S2 | X | ... | ... |
| S3 | X | ... | ... |
### Critical/High Findings (Immediate Action)
1. [file:line] - Description (S0/OWASP-A01) - DUAL_PASS_CONFIRMED
2. ...
### False Positives Filtered
- X findings excluded (matched FALSE_POSITIVES.jsonl patterns)
### Dependency Vulnerabilities
- ...
### Recommendations
- ...
2. JSONL Findings (save to file):
Create file: docs/audits/single-session/security/audit-[YYYY-MM-DD].jsonl
CRITICAL - Use JSONL_SCHEMA_STANDARD.md format:
{
"category": "security",
"title": "Short specific title",
"fingerprint": "security::path/to/file.ts::identifier",
"severity": "S0|S1|S2|S3",
"effort": "E0|E1|E2|E3",
"confidence": 90,
"files": ["path/to/file.ts:123"],
"why_it_matters": "1-3 sentences explaining security impact",
"suggested_fix": "Concrete remediation direction",
"acceptance_tests": ["Array of verification steps"],
"evidence": ["code snippet", "grep output", "tool output"],
"owasp_category": "A01|A02|...|A10|N/A",
"cvss_estimate": "LOW|MEDIUM|HIGH|CRITICAL"
}
For S0/S1 findings, ALSO include verification_steps:
{
"verification_steps": {
"first_pass": {
"method": "grep|tool_output|file_read|code_search",
"evidence_collected": ["initial evidence"]
},
"second_pass": {
"method": "contextual_review|exploitation_test|manual_verification",
"confirmed": true,
"notes": "Confirmation notes"
},
"tool_confirmation": {
"tool": "npm_audit|eslint|sonarcloud|patterns_check|NONE",
"reference": "Tool output or NONE justification"
}
}
}
⚠️ REQUIRED FIELDS (per JSONL_SCHEMA_STANDARD.md):
category - MUST be security (normalized)fingerprint - Format: <category>::<primary_file>::<identifier>files - Array with file paths (include line as file.ts:123)confidence - Number 0-100 (not string)acceptance_tests - Non-empty array of verification steps3. Markdown Report (save to file):
Create file: docs/audits/single-session/security/audit-[YYYY-MM-DD].md
Full markdown report with all findings, baselines, and remediation plan.
Before finalizing the audit:
Run Validation Script:
node scripts/validate-audit.js docs/audits/single-session/security/audit-[YYYY-MM-DD].jsonl
Validation Checks:
If validation fails:
docs/audits/single-session/security/node scripts/validate-audit.js on the JSONL filenpm run validate:canon
Ensure all CANON files pass validation before committing.node scripts/debt/intake-audit.js docs/audits/single-session/security/audit-[YYYY-MM-DD].jsonl --source "audit-security-[DATE]"
This assigns DEBT-XXXX IDs and adds to
docs/technical-debt/MASTER_DEBT.jsonl. See
docs/technical-debt/PROCEDURE.md for the full TDMS workflow.This audit resets the security category threshold in docs/AUDIT_TRACKER.md
(single-session audits reset their own category; multi-AI audits reset all
thresholds). Reset means the commit counter for this category starts counting
from zero after this audit.
Security audit triggers (check AUDIT_TRACKER.md):
After 3 single-session security audits, a full multi-AI Security Audit is recommended. Track this in AUDIT_TRACKER.md "Single audits completed" counter.
If you encounter a pattern that should be excluded from future audits:
node scripts/add-false-positive.js \
--pattern "regex-pattern" \
--category "security" \
--reason "Explanation of why this is not a security issue" \
--source "AI_REVIEW_LEARNINGS_LOG.md#review-XXX"
Before running this audit, review:
node scripts/debt/intake-audit.js <output.jsonl> --source "audit-security-<date>"xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience