lc-security-audit
Detect common Laravel security vulnerabilities - SQL injection, XSS, mass assignment, exposed secrets.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Detect common Laravel security vulnerabilities - SQL injection, XSS, mass assignment, exposed secrets.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Create a Larascraper scraper (v2 or v3) for a target website, chaining browser actions (click, type, wait, scroll), conditional flow (when/repeatUntil), captcha solving, and file/PDF downloads. Detects the installed major and generates the matching style.
Add or edit a Laracrate file collection in config/laracrate.php with the correct anatomy (disk, access, types, variants, previews, extract/embed, flags, per-model scoping).
Runtime-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.
Scaffold spatie/laravel-permission setup - add the HasRoles trait to a model and generate a roles & permissions seeder.
Audit spatie/laravel-permission usage - permissions used in code but undefined, defined but unused, unprotected routes, guard mismatches, and cache pitfalls.
Extract business logic from a controller or Livewire component method into a Laractions Action class.
| name | lc:security-audit |
| description | Detect common Laravel security vulnerabilities - SQL injection, XSS, mass assignment, exposed secrets. |
| argument-hint | [analyze | fix | fix --dry-run | file-path | fix file-path] |
| user-invocable | true |
| allowed-tools | Read Grep Bash Edit Write Glob |
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.