Skip to content

commandSecurity

Security Scan

Scans the codebase for injection, broken auth, unsafe deserialization and similar flaws, then ranks each finding by severity.

npx workspacetemplates add security-scan --tool claude-code

Writes 1 file to .claude/commands/

.claude/commands/security-scan.md14 lines · 1.2 KBFile
---
description: Scans the codebase for injection, broken auth, unsafe deserialization and similar flaws, then ranks each finding by severity.
argument-hint: "[folder or area, default whole repo]"
---

Scan for security vulnerabilities in: $ARGUMENTS (the whole repository if empty).

1. Map the entry points first: HTTP routes, queue consumers, CLI args, file uploads, webhooks.
2. Trace each input toward its sinks. Look for SQL or NoSQL built with string concatenation, shell calls with interpolated values, unescaped HTML output, path joins using user text, unsafe deserialization (pickle, yaml.load, eval), SSRF through fetched URLs, open redirects, weak hashing (md5, sha1 for passwords), and hard-coded keys.
3. Check session and token handling: cookie flags, expiry, JWT algorithm checks, CSRF protection on state-changing routes.
4. Run the project's own linters or scanners if installed (semgrep, bandit, gosec, eslint-plugin-security). Quote their output, do not trust it blindly.
5. Do not edit files and do not run exploits against anything live.

Report a table: severity (critical, high, medium, low), file:line, the flaw, how an attacker would use it, and the smallest fix. Put critical items first. End by asking which finding to fix first.

What it does

A quick review often misses the dull, common flaws: string-built queries, unescaped output, weak crypto and handlers that trust the client. This command walks the code looking for those patterns by name and records exactly where each one sits.

Findings come back ranked from critical to low, each with a file and line, a short exploit story and a concrete fix. It only reads code and never edits anything.

Example

you › /security-scan src/api

agent › critical: src/api/search.ts:41 builds a SQL string from req.query.q. Attacker sends q=' OR 1=1-- and reads every row. Fix: use a parameterized query.
high: src/api/upload.ts:18 joins the filename into a path, allowing ../ traversal.
medium: session cookie lacks the SameSite flag.
Which finding should I fix first?

Questions

Does it exploit the flaws it finds?
No. It reasons from the code and reports; it never sends attack traffic anywhere.
Can it replace a professional audit?
No. It catches common patterns quickly, but design-level and business-logic weaknesses still need a human reviewer.
  • Audit Dependencies

    CommandSecurity

    Free
  • Check Auth

    CommandSecurity

    Free
  • Find Secrets

    CommandSecurity

    Free
  • Harden Input

    CommandSecurity

    Free