PC-022HIGHWeb Server & Framework

Laravel APP_DEBUG=true Enabled in Environment Config

Catches APP_DEBUG=true in environment/deployment files and hardcoded debug => true defaults in Laravel config/app.php that expose full Ignition stack traces and environment variables.

Rule Slug
laravel-app-debug-enabled
Affected Files
.env*, config/app.php, *.env, docker-compose*.yml, docker-compose*.yaml
Detection Method
Deterministic Regex
Live Rule Tester100% Browser-Local
HIGH: Detected 1 violation
Line 3:APP_DEBUG=true

Vulnerable Pattern vs. Hardened Fix

Vulnerable Pattern
# .env.production or docker-compose.yml
APP_ENV=production
APP_DEBUG=true # HIGH RISK: Dumps $_ENV secrets on any exception!

// config/app.php
'debug' => (bool) env('APP_DEBUG', true),
Recommended Fix
# .env.production
APP_ENV=production
APP_DEBUG=false

// config/app.php (fails closed to false if env var is omitted)
'debug' => (bool) env('APP_DEBUG', false),

Why This Fails in Production

In Laravel applications, enabling APP_DEBUG=true activates detailed exception pages (Whoops / Spatie Ignition) whenever an unhandled error or malformed HTTP request occurs. While useful during local development, shipping APP_DEBUG=true (or hardcoding 'debug' => env('APP_DEBUG', true) in config/app.php) to a public staging or production server is one of the fastest ways to leak application secrets.

When an attacker sends a deliberately malformed POST body, invalid HTTP verb, or non-existent parameter to a Laravel route with APP_DEBUG=true, Laravel renders a complete interactive error trace straight to the attacker’s browser. That debug page dumps full PHP stack traces, absolute server file paths, SQL queries with bound values, and most critically, the entire $_ENV and $_SERVER superglobals containing APP_KEY, DB_PASSWORD, AWS_SECRET_ACCESS_KEY, STRIPE_SECRET, and MAIL_PASSWORD in plaintext.

Once an attacker reads APP_KEY from a single Laravel debug page, the compromise escalates immediately from information disclosure to Remote Code Execution (RCE) via signed cookie deserialization or session forgery, even if the database itself is firewalled inside a private subnet. Automated botnets actively probe Laravel endpoints daily with malformed requests specifically hunting for APP_DEBUG=true responses.

Always default 'debug' => (bool) env('APP_DEBUG', false) inside config/app.php so production fails safe if the variable is missing, set APP_DEBUG=false in all deployment manifests, and rely on centralized error trackers (Sentry, Bugsnag, or structured server logs) to diagnose production exceptions.

Remediation Steps

  1. 1Set APP_DEBUG=false and APP_ENV=production in your production environment variables and deployment configs.
  2. 2Update config/app.php so the fallback default is strictly false: 'debug' => (bool) env('APP_DEBUG', false).
  3. 3Run php artisan config:cache during deployment so Laravel reads compiled production settings reliably.
  4. 4If APP_DEBUG=true was ever exposed on a public server, rotate APP_KEY (php artisan key:generate) along with all database and third-party API secrets.
BackendRecipes: Laravel Production Deployment Checklist

Fix debug leaks, caching, and permissions with the Laravel production guide on BackendRecipes.

Open BackendRecipes ↗

Frequently Asked Questions

Is APP_DEBUG=true safe inside my local .env file if it is in .gitignore?
Locally on localhost, APP_DEBUG=true is normal for development. PushCheck’s .gitignore check verifies your local .env stays untracked, while flagging APP_DEBUG=true in committed configs, docker-compose files, or config/app.php defaults.
Why is leaking APP_KEY from a Laravel debug page so dangerous?
Laravel uses APP_KEY to encrypt and sign session cookies and serialized payloads. Attackers with APP_KEY can forge admin sessions and, depending on session driver and Laravel version, achieve remote code execution.
How should I inspect production errors with APP_DEBUG=false?
Errors are still logged with full stack traces to storage/logs/laravel.log or forwarded to Sentry/CloudWatch while visitors only see a clean 500 error page.

Related Web Server & Framework Rules

Scan local project folder →