Security Rules
Rules that protect against dangerous operations and secrets.
security/branch-protection
Severity: block | Event: PreToolUse | Tools: Edit, Write
Blocks writes to protected branches (main, master by default).
rules: {
'security/branch-protection': {
protectedBranches: ['main', 'master', 'staging'],
},
}
security/destructive-commands
Severity: block | Event: PreToolUse | Tools: Bash
Blocks: rm -rf /, rm -rf ~, git push --force, git push -f, git reset --hard, git clean -fd, curl | sh, chmod 777, dd of=/dev/.
security/secret-detection
Severity: block | Event: PreToolUse | Tools: Write
Detects: AWS keys, GitHub tokens, Stripe keys, private keys, npm tokens, generic API keys/passwords.
rules: {
'security/secret-detection': {
allowPatterns: ['NEXT_PUBLIC_SUPABASE_ANON_KEY'],
},
}
security/prompt-injection
Severity: warn | Event: PostToolUse | Tools: Read, Fetch
Detects prompt injection patterns in content read or fetched by the AI agent: instruction overrides, role reassignment, chat template injection.
security/dependency-audit
Severity: warn | Event: PostToolUse | Tools: Bash
Flags suspicious package installation patterns: installing from URLs instead of registry, pip over HTTP, curl piped to pip.
security/env-exposure
Severity: block | Event: PreToolUse | Tools: Write, Edit
Prevents leaking environment variables in client-side code. Detects direct .env imports, console.log(process.env), and spreading ...process.env.
security/rls-required
Severity: warn | Event: PreToolUse | Tools: Write
Checks SQL migration files for CREATE TABLE statements and warns if ENABLE ROW LEVEL SECURITY is missing.
security/unsafe-eval
Severity: block | Event: PreToolUse | Tools: Write
Blocks eval(), new Function(), and string-argument setTimeout/setInterval which create code injection vectors.
rules: {
'security/unsafe-eval': {
allowInTestFiles: true,
},
}
security/no-hardcoded-urls
Severity: warn | Event: PreToolUse | Tools: Write
Warns about hardcoded localhost, 127.0.0.1, and raw URLs in fetch/axios calls. URLs should come from environment variables.
rules: {
'security/no-hardcoded-urls': {
allowDomains: ['cdn.jsdelivr.net'],
},
}
security/xss-prevention
Severity: warn | Event: PreToolUse | Tools: Write
Warns about patterns that bypass framework XSS protections: dangerouslySetInnerHTML (React), innerHTML, document.write(), v-html (Vue), {!! !!} (Blade), |safe (Jinja/Django).
security/sql-injection
Severity: block | Event: PreToolUse | Tools: Write
Blocks SQL queries built with string concatenation or template literal interpolation. Requires parameterized queries with ? or $1 placeholders.