← PHP / Laravel · Contents

PHP-082 / Beginner

Secrets left as default values (env('APP_KEY', 'secret'))

A05:2021 Security Misconfiguration · CWE-1188 Insecure Default Initialization

Why is this a problem?

If an environment variable is missing, a predictable default key is used.

How to fix it

php
'jwt_secret' => env('JWT_SECRET') ?? throw new \RuntimeException('JWT_SECRET missing'),

Further reading