APP_KEY and the .env file
The .env file holds APP_KEY, database credentials and third-party keys. If the web root is misconfigured so /.env is served, everything is exposed. APP_KEY matters beyond confidentiality: it encrypts cookies, and Laravel's encrypted cookie payloads were historically unserialised, so a known APP_KEY was a route to remote code execution (CVE-2018-15133 in older versions). Any leaked APP_KEY should be rotated.
Debug mode and Ignition
- APP_DEBUG=true shows detailed error pages with environment values and stack frames.
- CVE-2021-3129: Ignition before 2.5.2, used with Laravel debug mode, allowed unauthenticated remote code execution through its solutions feature. It is in CISA's Known Exploited Vulnerabilities catalogue.
- Telescope (/telescope) and Horizon (/horizon) expose requests, queries, jobs and sometimes tokens if their gates are left open outside the local environment.
- Debugbar in production leaks queries and session data in every response.
Eloquent, policies and queries
- $guarded = [] or a broad $fillable combined with Model::create($request->all()) lets clients set is_admin or team_id.
- Policies and Gates only apply where controllers call authorize() or use can middleware; route model binding fetches any ID.
- DB::raw, whereRaw and orderByRaw with request input are injectable.
- Signed URLs and password reset links built from the Host header can be poisoned if trusted hosts are not set.
A practical Laravel test order
Check unauthenticated exposure first: /.env, /storage and log files, /telescope, /horizon and debug error pages. Then authenticate as a normal user and replay requests against other users' route-model-bound IDs. Finally, add unexpected attributes to create and update requests to test $fillable, and check password reset links for Host header poisoning.
Testing a Laravel app with Pentest-Swarm
Pentest-Swarm works on the deployed Laravel app from outside. It looks for the same exposed files and debug surfaces an attacker would.
- Content discovery tools in the arsenal (ffuf, feroxbuster, gobuster) look for exposed files and paths such as dotfiles and dashboards; nuclei covers broad CVE templates including known Laravel issues.
- Run owasp-top10 against staging with a test user's session cookie via
--cookieto reach authenticated controllers. - Use api-security for Sanctum or Passport-protected JSON APIs, passing the token with
--auth. - Run with
--safe-modeon environments shared with other teams.
Where it falls short
Black-box testing confirms what is reachable, not what is configured. It cannot read your .env or verify that APP_KEY was rotated after an exposure. Add Larastan or another static analyser, and check deployment configuration directly. The free edition of Pentest-Swarm also limits its most aggressive exploitation, so treat a clean run as evidence, not proof.
Questions
What happens if my Laravel APP_KEY leaks?
Attackers can decrypt and forge encrypted cookies and signed values, and on older versions it has led to code execution. Rotate it and invalidate sessions.
Is APP_DEBUG=true dangerous even without Ignition?
Yes. Debug error pages disclose environment details, file paths and query data that help with every other attack.
How do I protect Telescope in production?
Restrict it with the viewTelescope gate to specific users, or do not install it in production at all.