SecureCoding
Proactive security guidance adapted from VibeSec-Skill. Bug bounty hunter perspective —
teaches attack patterns so you build defenses that actually work.
Customization
Before executing, check for user customizations at:
${PAI_USER_DIR}/SKILLCUSTOMIZATIONS/SecureCoding/
Workflow Routing
| Workflow |
Trigger |
File |
| CodeReview |
"security review", "check for vulnerabilities", "secure code review" |
Workflows/CodeReview.md |
| SecureDesign |
"secure design", "threat model feature", "security architecture" |
Workflows/SecureDesign.md |
| SecretAudit |
"secret audit", "scan for secrets", "find leaked keys", "git history secrets", "secret discovery" |
SecretAudit.md |
Quick Reference
Approach: Bug bounty perspective — think like an attacker, not just a defender
Coverage: Access control, client-side, server-side, auth/JWT, API security
Focus: TypeScript/Node.js, Cloudflare Workers (framework-specific)
3-Tier Security Decision Framework
Quick triage for any security-relevant code change:
Always Do (no exceptions):
- Validate all external input at system boundary (Zod/schema validation)
- Parameterize database queries (no string concatenation)
- Encode output to prevent XSS
- Hash passwords with bcrypt/scrypt/argon2
- Set security headers (CSP, HSTS, X-Frame-Options)
- Use httpOnly + secure + sameSite cookies for sessions
- Rate limit authentication endpoints
Ask First (requires approval):
- Authentication/authorization logic changes
- New sensitive data storage
- External service integrations
- CORS modifications
- File upload handling
- Permission model changes
Never Do:
- Commit secrets to version control
- Log sensitive data (passwords, tokens, PII)
- Rely on client-side validation for security
- Disable security headers
- Use
eval() with user data
- Expose stack traces to users in production
Dependency Auditing
Run periodically and before releases:
npm audit # Check for known vulnerabilities
npm audit --production # Production deps only
Triage by reachability: A critical vulnerability in a dev-only dependency is lower priority than a moderate one in a production request handler. Focus on: (1) Is the vulnerable code path reachable? (2) Can an attacker trigger it? (3) What's the blast radius?
Domain Context Files (loaded on demand):
${CLAUDE_SKILL_DIR}/AccessControl.md — IDOR, privilege escalation, mass assignment, multi-tenant
${CLAUDE_SKILL_DIR}/ClientSide.md — XSS, CSRF, open redirects, secret exposure, prototype pollution
${CLAUDE_SKILL_DIR}/ServerSide.md — SSRF, file uploads, SQLi, XXE, path traversal
${CLAUDE_SKILL_DIR}/AuthSessions.md — JWT attacks, password storage, token management
${CLAUDE_SKILL_DIR}/ApiSecurity.md — Mass assignment, GraphQL depth/complexity, introspection
${CLAUDE_SKILL_DIR}/BypassTechniques.md — Consolidated bypass catalogs across all domains
${CLAUDE_SKILL_DIR}/SecretAudit.md — Secret detection in git history, rotation workflow
Examples
Example 1: Security review of code changes
User: "security review the changes in packages/api"
-> Invokes CodeReview workflow
-> Loads relevant domain context based on code content
-> Returns structured findings with severity, location, fix
Example 2: Secure design for new feature
User: "secure design for the webhook endpoint"
-> Invokes SecureDesign workflow
-> Loads all domain context files
-> Returns attack surfaces, recommended controls
Known Gaps
- Template injection (Handlebars, EJS — not in current stack)
- LDAP injection (no LDAP in PAI projects)
- Insecure deserialization (JSON.parse is safe for JS)
- Business logic flaws (requires human review)
- Compliance frameworks (PCI DSS, HIPAA)
- Infrastructure/network security beyond SSRF
Cross-references:
- Supply chain security →
../SupplyChain.md
- Secret auditing →
${CLAUDE_SKILL_DIR}/SecretAudit.md
1---2name: securecoding3description: Proactive secure coding — vulnerability patterns, bypass techniques, defense-in-depth for TypeScript and Cloudflare Workers. USE WHEN secure code, code security, vulnerability prevention, secure coding review, defense in depth, XSS prevention, SQL injection prevention, SSRF prevention, JWT security, access control patterns, API security patterns, secure design, security review code, prototype pollution.4---56# SecureCoding78Proactive security guidance adapted from VibeSec-Skill. Bug bounty hunter perspective —9teaches attack patterns so you build defenses that actually work.1011## Customization1213**Before executing, check for user customizations at:**14`${PAI_USER_DIR}/SKILLCUSTOMIZATIONS/SecureCoding/`1516<!-- ## Voice Notification1718**When executing a workflow, do BOTH:**19201. **Send voice notification**:21 ```bash22 curl -s -X POST http://localhost:8888/notify \23 -H "Content-Type: application/json" \24 -d '{"message": "Running the WORKFLOWNAME workflow in the SecureCoding skill to ACTION", "voice_id": "fTtv3eikoepIosk8dTZ5"}' \25 > /dev/null 2>&1 &26 ```27282. **Output text notification**:29 ```30 Running the **WorkflowName** workflow in the **SecureCoding** skill to ACTION...31 ```3233**Full documentation:** `${PAI_HOME}/THENOTIFICATIONSYSTEM.md`34-->3536## Workflow Routing3738| Workflow | Trigger | File |39|----------|---------|------|40| **CodeReview** | "security review", "check for vulnerabilities", "secure code review" | `Workflows/CodeReview.md` |41| **SecureDesign** | "secure design", "threat model feature", "security architecture" | `Workflows/SecureDesign.md` |42| **SecretAudit** | "secret audit", "scan for secrets", "find leaked keys", "git history secrets", "secret discovery" | `SecretAudit.md` |4344## Quick Reference4546**Approach:** Bug bounty perspective — think like an attacker, not just a defender47**Coverage:** Access control, client-side, server-side, auth/JWT, API security48**Focus:** TypeScript/Node.js, Cloudflare Workers (framework-specific)4950## 3-Tier Security Decision Framework5152Quick triage for any security-relevant code change:5354**Always Do (no exceptions):**55- Validate all external input at system boundary (Zod/schema validation)56- Parameterize database queries (no string concatenation)57- Encode output to prevent XSS58- Hash passwords with bcrypt/scrypt/argon259- Set security headers (CSP, HSTS, X-Frame-Options)60- Use httpOnly + secure + sameSite cookies for sessions61- Rate limit authentication endpoints6263**Ask First (requires approval):**64- Authentication/authorization logic changes65- New sensitive data storage66- External service integrations67- CORS modifications68- File upload handling69- Permission model changes7071**Never Do:**72- Commit secrets to version control73- Log sensitive data (passwords, tokens, PII)74- Rely on client-side validation for security75- Disable security headers76- Use `eval()` with user data77- Expose stack traces to users in production7879## Dependency Auditing8081Run periodically and before releases:8283```bash84npm audit # Check for known vulnerabilities85npm audit --production # Production deps only86```8788**Triage by reachability:** A critical vulnerability in a dev-only dependency is lower priority than a moderate one in a production request handler. Focus on: (1) Is the vulnerable code path reachable? (2) Can an attacker trigger it? (3) What's the blast radius?8990**Domain Context Files (loaded on demand):**91- `${CLAUDE_SKILL_DIR}/AccessControl.md` — IDOR, privilege escalation, mass assignment, multi-tenant92- `${CLAUDE_SKILL_DIR}/ClientSide.md` — XSS, CSRF, open redirects, secret exposure, prototype pollution93- `${CLAUDE_SKILL_DIR}/ServerSide.md` — SSRF, file uploads, SQLi, XXE, path traversal94- `${CLAUDE_SKILL_DIR}/AuthSessions.md` — JWT attacks, password storage, token management95- `${CLAUDE_SKILL_DIR}/ApiSecurity.md` — Mass assignment, GraphQL depth/complexity, introspection96- `${CLAUDE_SKILL_DIR}/BypassTechniques.md` — Consolidated bypass catalogs across all domains97- `${CLAUDE_SKILL_DIR}/SecretAudit.md` — Secret detection in git history, rotation workflow9899## Examples100101**Example 1: Security review of code changes**102```103User: "security review the changes in packages/api"104-> Invokes CodeReview workflow105-> Loads relevant domain context based on code content106-> Returns structured findings with severity, location, fix107```108109**Example 2: Secure design for new feature**110```111User: "secure design for the webhook endpoint"112-> Invokes SecureDesign workflow113-> Loads all domain context files114-> Returns attack surfaces, recommended controls115```116117## Known Gaps118119- Template injection (Handlebars, EJS — not in current stack)120- LDAP injection (no LDAP in PAI projects)121- Insecure deserialization (JSON.parse is safe for JS)122- Business logic flaws (requires human review)123- Compliance frameworks (PCI DSS, HIPAA)124- Infrastructure/network security beyond SSRF125126**Cross-references:**127- Supply chain security → `../SupplyChain.md`128- Secret auditing → `${CLAUDE_SKILL_DIR}/SecretAudit.md`