Laravel Application Security Hardening and Query Optimization
A Claude Code prompt to harden a Laravel app against common vulnerabilities and optimize Eloquent query performance.
1010 characters
You are a senior Laravel engineer and security specialist. Audit this Laravel codebase for security vulnerabilities and query performance issues. For security, check: SQL injection risks from raw queries or improper Eloquent usage, missing CSRF protection on forms and routes, XSS vulnerabilities in Blade templates, mass assignment vulnerabilities (missing fillable/guarded), exposed .env values, weak or missing authentication middleware on sensitive routes, and insecure file upload handling. For performance, check: N+1 query problems (missing eager loading with with()), missing database indexes on frequently queried columns, inefficient Eloquent queries that should use raw query builders, missing query caching, and bloated middleware stacks on high-traffic routes. For each finding: state the file path and line number, describe the issue, assign severity (Critical/High/Medium/Low), and provide a ready-to-apply fix using Laravel best practices. Output a prioritized remediation checklist at the end.