aboutsummaryrefslogtreecommitdiff
path: root/.claude/commands/security-check.md
blob: 0880e994dc2856ece497135356e6a31d3f780e60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
description: Audit staged changes (or a specific file/directory) for security issues in three categories. Hardcoded secrets — AWS keys, `sk-`/`sk_live_`/`sk_test_` patterns, password/secret assignments, private-key blocks, `.env` contents, API tokens, JWTs, bearer tokens. OWASP top-10 — SQL injection via string concatenation, XSS via unsanitized rendering, missing permission checks, unsafe deserialization (`eval`/`exec` on untrusted data), debug-mode misconfigs, PII or tokens in logs. Dependency risks — runs `pip-audit` for Python diffs, `npm audit` for JS/TS diffs, flags new unpinned deps. Scope defaults to `git diff --cached`; falls back to the last commit if nothing's staged; an explicit path overrides. Reports findings in a severity-ranked table (CRITICAL/HIGH/MEDIUM/LOW/INFO) with file:line + recommendation per row, or a "no issues detected" verdict listing what was checked. Use before committing changes touching security-sensitive paths. Do NOT use for full-codebase audits (diff-scoped — see Claude Code's `/security-review` for branch-wide review), runtime/fuzzing analysis, or as a substitute for full-lockfile dependency scanning.
disable-model-invocation: true
---

# /security-check — Audit Changes for Security Issues

Scan staged or recent changes for secrets, OWASP vulnerabilities, and dependency risks.

## Usage

```
/security-check [FILE_OR_DIRECTORY]
```

If no argument is given, audit all staged changes (`git diff --cached`). If there are no staged changes, audit the diff from the last commit.

## Instructions

1. **Gather the changes** to audit:
   - Staged changes: `git diff --cached`
   - Or last commit: `git diff HEAD~1`
   - Or specific path if provided

2. **Check for hardcoded secrets** — scan for patterns:
   - AWS access keys (`AKIA...`)
   - Generic secret patterns (`sk-`, `sk_live_`, `sk_test_`)
   - Password assignments (`password=`, `passwd=`, `secret=`)
   - Private keys (`-----BEGIN.*PRIVATE KEY-----`)
   - `.env` file contents committed by mistake
   - API tokens, JWTs, or bearer tokens in source code

3. **OWASP Top 10 review**:
   - SQL injection: string concatenation in queries
   - XSS: unsanitized user input rendered in HTML/JSX
   - Broken authentication: missing permission checks on endpoints
   - Insecure deserialization: unsafe deserialization of untrusted data (e.g., eval, exec)
   - Security misconfiguration: debug mode enabled in production settings
   - Sensitive data exposure: PII or tokens in log statements

4. **Dependency audit**:
   - Run `pip-audit` if Python files changed
   - Run `npm audit` if JavaScript/TypeScript files changed
   - Flag any new dependencies added without version pinning

5. **Report findings** in a table:

   | Severity | File:Line | Finding | Recommendation |
   |----------|-----------|---------|----------------|

   Severity levels: CRITICAL, HIGH, MEDIUM, LOW, INFO

6. If no issues found, report "No security issues detected" with a summary of what was checked.