/laraclaude:lc:security-audit [analyze | fix | fix --dry-run | file-path | fix file-path]from laraclaude
Scans Laravel projects for security vulnerabilities including SQL injection, XSS, mass assignment, and exposed secrets using static analysis.
Ships in laraclaude. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Detect common security vulnerabilities in a Laravel application through static analysis. Checks for SQL injection risks, XSS vectors, mass assignment issues, exposed secrets, missing CSRF, and debug mode misconfiguration.
| Subcommand | Description |
|---|---|
| (no argument) | Scan the entire project and report all security issues. Read-only. |
fix | Scan and auto-fix all fixable issues. Asks for confirmation before each change. |
fix --dry-run | Show what fixes would be applied without changing anything. |
[file-path] | Audit a specific file only. Read-only. |
fix [file-path] | Fix security issues in a specific file, with confirmation. |
What to detect:
DB::raw() calls containing variable interpolation or concatenation with user inputwhereRaw(), selectRaw(), orderByRaw(), havingRaw() with unparameterized variablesDB::statement() or DB::unprepared() with string concatenationHow to scan:
Grep to find all DB::raw(, whereRaw(, selectRaw(, orderByRaw(, havingRaw(, DB::statement(, DB::unprepared( calls.Read to examine each match and check if the SQL string contains $ variables without being passed as bindings.Safe patterns (do not flag):
DB::raw('COUNT(*)') // No variables
whereRaw('price > ?', [$minPrice]) // Parameterized
DB::select('SELECT * FROM t WHERE id = ?', [$id]) // Parameterized
Unsafe patterns (flag):
DB::raw("price > $minPrice") // Variable interpolation
whereRaw("name LIKE '%{$search}%'") // Variable in string
DB::statement("ALTER TABLE $table ...") // Variable table name
Severity: Critical
Fix: Replace with parameterized queries using ? placeholders and binding arrays.
What to detect:
{!! $variable !!} in Blade templates where $variable could contain user input{!! !!} is safe when rendering trusted HTML (e.g., rich text from admin, markdown output)How to scan:
Grep to find all {!! patterns in resources/views/**/*.blade.php.Read to check the context of each match.Safe patterns (do not flag):
{!! $markdownHtml !!} <!-- Admin-generated content -->
{!! $svgIcon !!} <!-- Static SVG -->
{!! $component->render() !!} <!-- Component output -->
Unsafe patterns (flag):
{!! $user->bio !!} <!-- User-editable content -->
{!! $comment->body !!} <!-- User-submitted content -->
{!! request('content') !!} <!-- Direct request input -->
Severity: High
Fix: Replace {!! !!} with {{ }} for auto-escaping, or apply e() / htmlspecialchars() / Str::of()->sanitizeHtml().
What to detect:
$fillable nor $guarded$guarded = [] (completely unguarded)How to scan:
Glob to find all app/Models/*.php.Read to check each model for $fillable or $guarded properties.$guarded.Severity: High
Fix: Add appropriate $fillable array based on the migration columns (exclude id, timestamps, auto-generated fields).
What to detect:
env())'password' => 'actual_value', $apiKey = 'sk-...', $secret = '...'env()How to scan:
Grep to search for common secret patterns:
password.*=.*['"] (excluding env( on the same line)secret.*=.*['"] (excluding env()api_key.*=.*['"] (excluding env()token.*=.*['"] (excluding env()sk-, pk-, whsec_, Bearer that are not in .envRead to verify each match is a real hardcoded secret and not a variable name, comment, or config key.Severity: Critical
Fix: Move the value to .env and replace with env('KEY_NAME') or config('key').
What to detect:
.env.example containing values that look like real credentials instead of placeholder valuesHow to scan:
Read to load .env.example.password, secret, '', or similar placeholdersk_live_..., pk_live_...)Severity: High
Fix: Replace real values with placeholder text (e.g., your-api-key-here, empty string, or secret).
What to detect:
@csrf directiveVerifyCsrfToken middlewareHow to scan:
Grep to find POST/PUT/PATCH/DELETE route definitions in routes/*.php.web middleware group (which includes CSRF) or explicit csrf middleware.Grep to find <form tags in Blade files and check for @csrf.app/Http/Middleware/VerifyCsrfToken.php for $except exclusions.Severity: Medium (API routes are exempt, web routes need it)
Fix: Add @csrf to forms, ensure POST routes use web middleware group.
What to detect:
APP_DEBUG=true in production-related config'debug' => true hardcoded in config/app.php (not using env())How to scan:
Read to check config/app.php for the debug key.env('APP_DEBUG', false) (safe) or a hardcoded value (unsafe)..env and .env.example for APP_DEBUG value.Severity: Medium
Fix: Ensure config/app.php uses env('APP_DEBUG', false).
SECURITY AUDIT REPORT
======================
CRITICAL (2 issues)
--------------------
1. SQL Injection Risk
File: app/Services/SearchService.php:45
Code: DB::raw("MATCH(title) AGAINST('$query')")
Fix: Use parameterized query: DB::raw("MATCH(title) AGAINST(?)", [$query])
2. Hardcoded API Key
File: config/services.php:28
Code: 'secret' => 'sk_live_abc123...'
Fix: Replace with env('STRIPE_SECRET')
HIGH (3 issues)
----------------
1. Mass Assignment Unprotected
File: app/Models/Payment.php
Issue: No $fillable or $guarded defined
Fix: Add $fillable with appropriate columns
...
SUMMARY
========
Files scanned: 245
Critical issues: 2
High issues: 3
Medium issues: 5
Low issues: 1
For each fixable issue, apply the fix with confirmation:
$fillable array based on migration columns.{!! !!} with {{ }} where appropriate.env() calls and add placeholder to .env.example.@csrf to forms.env('APP_DEBUG', false).SQL injection fixes require manual review and are flagged but not auto-fixed (risk of breaking queries).
{!! !!} usage is intentional (admin HTML content, SVGs). Use judgment.routes/api.php) legitimately skip CSRF -- do not flag them.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub edulazaro/laraclaude --plugin laraclaude32 skills in this plugin
/lc:analyze-errorPaste a Laravel stacktrace and get root cause analysis with suggested fix./lc:analyze-modelDeep analysis of a Laravel Eloquent model - relationships, scopes, casts, fillable, observers, keepers, actions./lc:api-docsGenerate API documentation from routes, controllers, and form requests./lc:blade-auditDetect hardcoded text without @text(), duplicate CSS classes, unused Blade components, and accessibility issues./lc:boost-inspectRuntime-verified Laravel inspection using the Laravel Boost MCP server (Tinker, Database Query/Schema, Last Error) instead of static grep. Falls back to Docker/Tinker if Boost is not installed./lc:cache-opportunitiesDetect repeated queries and computations that should be cached.Other plugins' skills for the same job