Ashrafiucse laravel security

From jiayaoqijia/cryptoskill · View interactive version

Ashrafiucse laravel security is an AI agent skill from the GitHub repository jiayaoqijia/cryptoskill. Audits Laravel (PHP) applications for framework-specific vulnerabilities — mass assignment via missing fillable/guarded, SQL injection through DB::raw/whereRaw/orderByRaw concatenation, Blade raw output XSS, CSRF middleware exclusions, committed APP_KEY enabling cookie-forgery RCE chains, APP_DEBUG

How to use this skill

Skill file

Laravel Security

Step 0 — Detect

rg -n "laravel/framework" -g 'composer.json' ; ls artisan app routes config 2>/dev/null

Record Laravel version (composer.json/lock), PHP version, and whether Sanctum/Passport/Fortify are in use.

Step 1 — Config & env (the Laravel RCE chain)

git ls-files | rg -i '(^|/)\.env($|\.)'
rg -n "APP_DEBUG\s*=\s*true|APP_ENV\s*=\s*production" -g '.env*'
rg -n "APP_KEY" -g '.env*' -g 'config/app.php' | head -3

Step 2 — Mass assignment (privilege escalation)

rg -n "fillable|guarded" app/Models/ | head
rg -n "::create\(|::update\(|forceFill|unguard" app/ routes/ | head -20
rg -n "Model::unguard\(true\)|ShouldAutoSize" app/Providers/ 2>/dev/null

For each model feeding ::create/update with request data:

Step 3 — SQL injection

rg -n "DB::raw|whereRaw|orderByRaw|selectRaw|havingRaw|DB::select\(|DB::statement\(" app/ routes/

Step 4 — Blade XSS

rg -n '\{!!' -g '*.blade.php' .
rg -n '\{!!' -g '*.blade.php' . | wc -l   # census FIRST: know the full inventory size

Census, don't sample. Glob to *.blade.php — the bare pattern also matches React/TSX aria-invalid={!!…} noise that crowds out real hits. Run wc -l before reading: every raw echo in the inventory gets an explicit disposition (verified-safe / finding / not-assessed). head-truncating this list is how review-moderation XSS ships to production. For repos >50 hits, triage by author privilege first (below), but never leave the tail unexamined.

Every {!! !!} with a variable that traces to user input is a finding — then triage by privilege direction, which sets the severity:

| Author of the raw content | Viewer of the page | Severity |

|---|---|---|

| Unprivileged (student/customer/guest form: reviews, tickets, messages, submission text, uploaded filenames) | Privileged (admin/moderator/staff) | Critical — fires in the staff origin → session-riding requests → account takeover. Moderation queues guarantee a privileged viewer opens it. |

| Privileged (admin/instructor-authored: descriptions, embeds, templates) | Unprivileged/everyone | High (public) / Medium (authenticated) |

| Same privilege | same | Medium |

Blade's {{ }} escapes; {!! !!} exists only to bypass. nl2br() is NOT an escape — {!! nl2br($x) !!} is a raw echo. Check {{ $x }} + |raw? (Blade has no |raw; Twig confusion = false positive).

Step 5 — CSRF

rg -n "except" app/Http/Middleware/VerifyCsrfToken.php bootstrap/app.php 2>/dev/null
rg -n "withoutMiddleware|WithoutMiddleware" app/ routes/

Step 6 — Authorization

rg -n "middleware\(" routes/ | head -20
rg -n "Gate::before|Gate::define|policy|authorize\(" app/ | head -20

Step 7 — Files, uploads, misc

rg -n "response\(\)->download|Storage::(download|get|put)|\->store\(" app/
rg -n "debugbar|telescope|ignition" composer.json composer.lock 2>/dev/null
rg -n "eval\(|unserialize\(|assert\(" app/

Step 8 — Feature flags & outbound-email amplification

Plan-constrained tenants are authenticated ADMINS whose capability should be plan-gated — menu-level hiding is cosmetic. (Incident class, 2026-09-23 user report: one trial tenant blasted 1200+ emails in ~2 minutes via an ungated compose route + global-default import flag.) The attacker persona is an admin the PLAN should stop, not one auth should stop.

# flag census: every define + its default, then every use site
rg -n "Feature::(define|active|for)" app/ modules/ config/
# which routes actually carry the feature middleware
rg -n "feature:" routes/ modules/ routes/ app/ 2>/dev/null
# email-triggering endpoints and their throttles
rg -n "Route::(get|post)" routes/ modules/ routes/ | rg -i "send-|verif|subscribe|reset"
rg -n "throttle:" routes/ modules/ routes/
# blast fan-out: jobs that load unbounded sets and send per row
rg -n "::query\(\)->get\(\)|::all\(\)" app/ modules/
rg -n "Mail::to\(|Mail::send\(" app/ modules/
# pennant store + whether deploys purge stored values
rg -n "'store'" config/pennant.php
rg -n "pennant:purge" deploy/ scripts/

Reporting

Severity table above. Fixes are usually short — give exact code (protected $fillable = ['name','email'];, whereRaw('name = ?', [$name])). Cross-reference dependency CVEs via ../dependency-vulns/SKILL.md (composer.lock).

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.