Cybersecurity · PHP & Laravel

The practical Laravel security checklist

By · Last updated: · free to read, no paywall

Most Laravel apps don't get hacked by clever zero-days. They get hacked by exposed .env files, debug mode left on, unpatched PHP and weak SSH. This checklist covers the boring, high-impact work first — server, application, dependencies, secrets and response — with a way to automate each step.

In this guide
  1. What actually gets Laravel apps hacked
  2. Server hardening checklist
  3. Application hardening checklist
  4. Dependencies & supply chain
  5. Secrets & data protection
  6. Detection, monitoring & response
  7. FAQ

What actually gets Laravel apps hacked

Ranked by how often they show up in real incidents, not by how interesting they are:

  1. Exposed debug output. APP_DEBUG=true in production leaks environment variables, database credentials and file paths to anyone who triggers an error.
  2. Readable .env or .git/. Misconfigured document roots that serve dotfiles hand over your APP_KEY and credentials.
  3. Unpatched PHP, framework or packages with known CVEs.
  4. Weak SSH: password auth, root login enabled, no brute-force protection.
  5. Unsafe file uploads that allow executable content into web-served paths.
  6. Injection in the escape hatches: raw SQL without bindings, unescaped {!! !!} Blade output.
  7. Admin panels without MFA and without rate limiting.

Boring beats clever: if you close these seven doors, you're ahead of the vast majority of production PHP deployments.

Server hardening checklist

Application hardening checklist

Dependencies & supply chain

Your app is mostly other people's code, so treat dependency hygiene as a first-class security control:

Secrets & data protection

Detection, monitoring & response

Put this into practice with Cipi

Cipi is the free, open-source deploy CLI referenced throughout this guide: one command turns a fresh Ubuntu VPS into a hardened production server for Laravel — Nginx, PHP-FPM or Octane, MariaDB or PostgreSQL, queues, scheduler, SSL and zero-downtime Git deploys included.

wget -O - https://cipi.sh/setup.sh | bash

Frequently asked questions

Is Laravel secure by default?

The framework ships strong defaults: CSRF protection, hashed passwords, SQL injection protection through the query builder, and escaped Blade output. Most real-world incidents come from deployment mistakes — debug mode on, exposed .env files, unpatched PHP, weak SSH — which is why server hardening matters as much as application code.

What is the single most important Laravel security setting?

APP_DEBUG=false in production. An exposed debug page leaks environment variables, credentials and paths, and it is still the most common self-inflicted Laravel breach. Verify it now, then automate the check in your deploy pipeline.

How often should I update PHP and my dependencies?

Apply security patches as soon as practical — automate detection with composer audit in CI and Renovate or Dependabot for update PRs. For PHP itself, use a managed mechanism rather than memory: Cipi, for example, checks weekly and applies PHP security patches via cipi php upgrade.

Do I need a WAF for a Laravel app?

A WAF is a useful extra layer, not a substitute for the basics. Close the fundamentals first: TLS, patched software, hardened SSH, validated input, rate limiting. After that, a CDN-level WAF adds defense in depth against automated attacks.

What should I do first if I suspect a compromised server?

Isolate the machine from traffic, rotate every secret it held (database passwords, API tokens, APP_KEY), restore the application onto a clean server from a known-good backup, and only then investigate the entry point. Patching the live compromised host and hoping is how attackers keep their foothold.

Keep reading