Overview
The Security Guidance plugin monitors file edits for common security patterns and provides warnings before Claude writes potentially vulnerable code. It acts as a safety net, catching security issues early.Installation
This plugin is bundled with Claude Code. To enable it:How It Works
The plugin uses a PreToolUse hook that:- Monitors all file edit operations
- Checks file paths and content for security patterns
- Shows warnings when risky patterns are detected
- Provides specific guidance for each vulnerability type
The hook runs before Claude writes the file, giving you a chance to reconsider the approach.
Security Patterns Detected
The plugin monitors for 9 common security issues:1. GitHub Actions Command Injection
Files:.github/workflows/*.yml, .github/workflows/*.yaml
What it catches:
- Untrusted input used directly in
run:commands - Issue titles, PR descriptions, commit messages in shell commands
2. SQL Injection
Files:*.py, *.js, *.ts, *.php, *.rb
What it catches:
- String concatenation in SQL queries
- Unparameterized queries with user input
3. Command Injection
Files:*.py, *.js, *.ts, *.sh, *.bash
What it catches:
- Using
os.system(),eval(),exec()with user input - Shell commands with unvalidated strings
4. Cross-Site Scripting (XSS)
Files:*.jsx, *.tsx, *.vue, *.html
What it catches:
dangerouslySetInnerHTMLusageinnerHTMLassignments- Unescaped user content in templates
5. Path Traversal
Files: All file types with file path operations What it catches:- User-controlled file paths
- Missing validation on path strings
- Direct use of
../patterns
6. Insecure Deserialization
Files:*.py, *.js, *.java
What it catches:
- Using
pickle.load()on untrusted data - Unsafe
JSON.parse()patterns - Java deserialization of external data
7. Hardcoded Secrets
Files: All code files What it catches:- API keys in source code
- Passwords in configuration
- Tokens and credentials hardcoded
8. Insecure Randomness
Files:*.py, *.js, *.java, *.go
What it catches:
- Using
Math.random()for security tokens - Non-cryptographic random for secrets
9. Unsafe HTML Rendering
Files:*.jsx, *.tsx, *.vue, *.svelte
What it catches:
- Direct HTML string rendering
- Unsafe component props
Example Warnings
When Claude attempts to edit a GitHub Actions workflow:Configuration
No configuration required. The plugin activates automatically when enabled.Session-Based Warnings
Warnings are shown once per session per file. This prevents:- Repetitive warnings on the same file
- Disruption to workflow
- Warning fatigue
When to Disable
Consider disabling if:- Working on non-security-sensitive code
- Warnings become disruptive
- You have other security tooling (e.g., CodeQL)
Technical Details
Hook Implementation
The plugin uses Python for pattern matching:State Management
Warnings are tracked per session:- State file:
/tmp/security-warnings-{session-id}.json - Cleared when session ends
- Survives session resume
Limitations
The plugin:- Cannot detect all vulnerabilities
- Uses simple pattern matching
- May have false negatives
- Should supplement, not replace, security reviews
Details
Plugin Information
Plugin Information
Name: security-guidanceType: PreToolUse Hook (Python)Author: David Dworken ([email protected])Version: 1.0.0Hook File:
hooks/security_reminder_hook.pyPatterns Monitored: 9 security vulnerability typesRelated
Hook Development
Build your own PreToolUse hooks
Project Config
CLAUDE.md security guidelines