security-audit-codebase
정보
이 스킬은 코드베이스에서 자동화된 보안 감사를 수행하여 노출된 비밀, 취약한 종속성, 주입 결함 및 OWASP Top 10 문제를 탐지합니다. 배포 전, 주기적 검토 중 또는 규정 준수 감사를 준비할 때 사용하도록 설계되었습니다. 이 도구는 읽기, 쓰기, 편집 및 bash 기능을 활용하여 프로젝트 파일을 체계적으로 스캔합니다.
빠른 설치
Claude Code
추천npx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/security-audit-codebaseClaude Code에서 이 명령을 복사하여 붙여넣어 스킬을 설치하세요
문서
Security Audit Codebase
Perform a systematic security review of a codebase to identify vulnerabilities and exposed secrets.
When to Use
- Before publishing or deploying a project
- Periodic security review of existing projects
- After adding authentication, API integration, or user input handling
- Before open-sourcing a private repository
- Preparing for a security compliance audit
Inputs
- Required: Codebase to audit
- Optional: Specific focus area (secrets, dependencies, injection, auth)
- Optional: Compliance framework (OWASP, ISO 27001, SOC 2)
- Optional: Previous audit findings for comparison
Procedure
Step 1: Scan for Exposed Secrets
Search for patterns that indicate hardcoded secrets:
# API keys and tokens
grep -rn "sk-\|ghp_\|gho_\|github_pat_\|hf_\|AKIA" --include="*.{md,js,ts,py,R,json,yml,yaml}" .
# Generic secret patterns
grep -rn "password\s*=\s*['\"]" --include="*.{js,ts,py,R,json}" .
grep -rn "api[_-]key\s*[=:]\s*['\"]" --include="*.{js,ts,py,R,json}" .
grep -rn "secret\s*[=:]\s*['\"]" --include="*.{js,ts,py,R,json}" .
# Connection strings
grep -rn "postgresql://\|mysql://\|mongodb://" .
# Private keys
grep -rn "BEGIN.*PRIVATE KEY" .
Got: No real secrets found — only placeholders like YOUR_TOKEN_HERE or [email protected].
If fail: If real secrets are found, remove them immediately, rotate the exposed credential, and clean git history with git filter-branch or git-filter-repo. Treat any exposed secret as compromised.
Step 2: Check .gitignore Coverage
Verify sensitive files are excluded:
# Check that these are git-ignored
git check-ignore .env .Renviron credentials.json node_modules/
# Look for tracked sensitive files
git ls-files | grep -i "\.env\|\.renviron\|credentials\|secret"
Got: All sensitive files (.env, .Renviron, credentials.json) are listed in .gitignore, and git ls-files returns no tracked sensitive files.
If fail: If sensitive files are tracked, run git rm --cached <file> to untrack them, add to .gitignore, and commit. The file remains on disk but is no longer version-controlled.
Step 3: Audit Dependencies
Node.js:
npm audit
npx audit-ci --moderate
Python:
pip-audit
safety check
R:
# Check for known vulnerabilities in packages
# No built-in tool, but verify package sources
renv::status()
Got: No high or critical vulnerabilities in dependencies. Moderate and low vulnerabilities documented for review.
If fail: If critical vulnerabilities are found, update the affected packages immediately with npm audit fix or pip install --upgrade. If updates introduce breaking changes, document the vulnerability and create a remediation plan.
Step 4: Check for Injection Vulnerabilities
SQL Injection:
# Look for string concatenation in queries
grep -rn "paste.*SELECT\|paste.*INSERT\|paste.*UPDATE\|paste.*DELETE" --include="*.R" .
grep -rn "query.*\+.*\|query.*\$\{" --include="*.{js,ts}" .
All database queries should use parameterized queries, not string concatenation.
Command Injection:
# Look for shell execution with user input
grep -rn "system\(.*paste\|exec(\|spawn(" --include="*.{R,js,ts,py}" .
XSS (Cross-Site Scripting):
# Look for unescaped user content in HTML
grep -rn "innerHTML\|dangerouslySetInnerHTML\|v-html" --include="*.{js,ts,jsx,tsx,vue}" .
Got: No SQL, command, or XSS injection vectors found. All database queries use parameterized statements, shell commands avoid user-controlled input, and HTML output is properly escaped.
If fail: If injection vulnerabilities are found, replace string concatenation in queries with parameterized queries, sanitize or escape user input before shell execution, and use framework-safe rendering methods instead of innerHTML or dangerouslySetInnerHTML.
Step 5: Review Authentication and Authorization
Checklist:
- Passwords hashed with bcrypt/argon2 (not MD5/SHA1)
- Session tokens are random and sufficiently long
- Authentication tokens have expiration
- API endpoints check authorization
- CORS configured restrictively
- CSRF protection enabled for state-changing operations
Got: All checklist items pass: passwords use strong hashing, tokens are random with expiration, endpoints enforce authorization, CORS is restrictive, and CSRF protection is active.
If fail: Prioritize fixes by severity: weak password hashing and missing authorization are critical, while CORS and CSRF issues are high. Document all findings with their severity level.
Step 6: Check Configuration Security
# Debug mode in production configs
grep -rn "debug\s*[=:]\s*[Tt]rue\|DEBUG\s*=\s*1" --include="*.{json,yml,yaml,toml,cfg}" .
# Permissive CORS
grep -rn "Access-Control-Allow-Origin.*\*\|cors.*origin.*\*" --include="*.{js,ts}" .
# HTTP instead of HTTPS
grep -rn "http://" --include="*.{js,ts,py,R}" . | grep -v "localhost\|127.0.0.1\|http://"
Got: Debug mode is disabled in production configurations, CORS does not use wildcard origins in production, and all external URLs use HTTPS.
If fail: If debug mode is enabled in production configs, disable it immediately. Replace wildcard CORS origins with explicit allowed domains. Update http:// URLs to https:// where the endpoint supports it.
Step 7: Document Findings
Create an audit report:
# Security Audit Report
**Date**: YYYY-MM-DD
**Auditor**: [Name]
**Scope**: [Repository/Project]
**Status**: [PASS/FAIL/CONDITIONAL]
## Findings Summary
| Category | Status | Details |
|----------|--------|---------|
| Exposed secrets | PASS | No secrets found |
| .gitignore | PASS | Sensitive files excluded |
| Dependencies | WARN | 2 moderate vulnerabilities |
| Injection | PASS | Parameterized queries used |
| Auth/AuthZ | N/A | No authentication in scope |
| Configuration | PASS | Debug mode disabled |
## Detailed Findings
### Finding 1: [Title]
- **Severity**: Low / Medium / High / Critical
- **Location**: `path/to/file:line`
- **Description**: What was found
- **Recommendation**: How to fix
- **Status**: Open / Resolved
## Recommendations
1. Update dependencies to fix moderate vulnerabilities
2. [Additional recommendations]
Got: A complete SECURITY_AUDIT_REPORT.md saved in the project root with findings categorized by severity, each with a specific location, description, and recommendation.
If fail: With too many findings to document individually, group by category and prioritize critical/high findings. Generate the report regardless of outcome to establish a baseline.
Validation
- No hardcoded secrets in source code
- .gitignore covers all sensitive files
- No high/critical dependency vulnerabilities
- No injection vulnerabilities
- Authentication is properly implemented (if applicable)
- Audit report is complete and findings addressed
Pitfalls
- Only checking current files: Secrets in git history are still exposed. Check with
git log -p --all -S 'secret_pattern'. - Ignoring dev dependencies: Development dependencies can still introduce supply chain risks.
- False sense of security from
.gitignore:.gitignoreonly prevents future tracking. Already-committed files needgit rm --cached. - Overlooking configuration files:
docker-compose.yml, CI configs, and deployment scripts often contain secrets. - Not rotating compromised credentials: Finding and removing a secret is not enough. The credential must be revoked and regenerated.
Related Skills
configure-git-repository- proper .gitignore setupwrite-claude-md- documenting security requirementssetup-gxp-r-project- security in regulated environments
GitHub 저장소
연관 스킬
qmd
개발qmd는 BM25, 벡터 임베딩, 재순위화를 결합한 하이브리드 검색을 통해 로컬 파일을 색인화하고 검색할 수 있는 로컬 검색 및 색인화 CLI 도구입니다. 명령줄 사용과 Claude 통합을 위한 MCP(Model Context Protocol) 모드를 모두 지원합니다. 이 도구는 임베딩에 Ollama를 사용하고 색인을 로컬에 저장하여 터미널에서 직접 문서나 코드베이스를 검색하는 데 이상적입니다.
subagent-driven-development
개발이 스킬은 각 독립적인 작업마다 새로운 하위 에이전트를 배치하고 작업 사이에 코드 리뷰를 진행하여 구현 계획을 실행합니다. 이 리뷰 프로세스를 통해 품질 게이트를 유지하면서 빠른 반복 작업을 가능하게 합니다. 동일한 세션 내에서 대부분 독립적인 작업을 진행할 때 내장된 품질 검증과 함께 지속적인 진행을 보장하기 위해 사용하세요.
mcporter
개발mcporter 스킬은 개발자가 Claude에서 직접 Model Context Protocol(MCP) 서버를 관리하고 호출할 수 있도록 합니다. 이 스킬은 사용 가능한 서버를 나열하고, 인수를 사용해 해당 서버의 도구를 호출하며, 인증 및 데몬 생명주기를 처리하는 명령어를 제공합니다. 개발 워크플로우에서 MCP 서버 기능을 통합하고 테스트할 때 이 스킬을 사용하세요.
adk-deployment-specialist
개발이 스킬은 A2A 프로토콜을 사용하여 Vertex AI ADK 에이전트를 배포하고 오케스트레이션하며, AgentCard 검색, 작업 제출, 코드 실행 샌드박스 및 메모리 뱅크와 같은 지원 도구를 관리합니다. Python, Java 또는 Go 언어로 순차, 병렬 또는 루프 오케스트레이션 패턴을 갖춘 다중 에이전트 시스템 구축을 가능하게 합니다. Google Cloud에서 ADK 에이전트 배포 또는 에이전트 워크플로우 오케스트레이션을 요청받았을 때 사용하세요.
