Laravel Security Checklist for Production Apps

A production Laravel security checklist: debug mode, APP_KEY, mass assignment, authorisation policies, CSRF, file uploads and headers.

Yrzo AI28 November 2026 2 min read

Laravel is secure by default — until it is not

Laravel ships with CSRF protection, escaped Blade output, hashed passwords and parameterised queries. Most Laravel security incidents come from switching those protections off, misconfiguring production, or skipping authorisation. Work through this list before and after every launch.

1. Turn debug mode off

APP_DEBUG=true in production exposes stack traces, environment variables and database details on any error. Set APP_DEBUG=false and APP_ENV=production.

2. Protect .env and APP_KEY

Your .env file holds database passwords, API keys and APP_KEY, which signs cookies and encrypts data. Make sure the web server's document root is public/, not the project root, so .env cannot be downloaded. See exposed .env files. If APP_KEY ever leaks, rotate it.

3. Guard against mass assignment

Use $fillable (or carefully reviewed $guarded) on every model. Never pass $request->all() straight into create() or update(). See mass assignment vulnerabilities.

4. Authorise every action

Authentication says who someone is; authorisation says what they can touch. Use policies or gates and call $this->authorize() in controllers. Check ownership on every model loaded from a route parameter — otherwise you have IDOR.

5. Keep CSRF protection on

Do not add routes to the CSRF exception list unless they are genuine webhooks with their own signature verification. See CSRF attacks.

Is your site exposed to this?

Run a free, non-intrusive check of what attackers can see from outside. No account needed.

6. Be careful with raw queries and unescaped output

DB::raw(), whereRaw() and {!! !!} bypass Laravel's protections. Use bindings and sanitise any HTML you output raw. See SQL injection and XSS.

7. Validate file uploads

Validate MIME type and size, store uploads outside public/ or on object storage, and never trust the original filename. See file upload vulnerabilities.

8. Rate limit authentication

Use Laravel's rate limiter on login, registration and password reset routes. See password reset vulnerabilities.

9. Secure sessions and cookies

Set SESSION_SECURE_COOKIE=true, keep http_only on, and use same_site=lax or stricter. See cookie security flags.

10. Hide tooling in production

Telescope, Horizon and debug bars should be disabled or locked behind authentication in production.

Test it like an attacker would

Yrzo AI's Professional tier tests custom apps for access control, injection, exposed config and session issues. See plans or run a free scan.

Related reading: Exposed .env Files: Why They Are Dangerous and How to Check Yours · Password Reset Vulnerabilities: How Reset Flows Get Abused · Next.js Security Best Practices: A Practical Checklist

Laravel security checklistLaravel security best practicessecure Laravel applicationLaravel production security
Share

Check your own website in 60 seconds

Free check, no account needed. Want the full picture? Full reports start at £149, with up to 110 checks with a 14-day money-back guarantee.

Keep reading