Aller au contenu

Missing Security Headers (ARCH7141)

Ce contenu n’est pas encore disponible dans votre langue.

Key php.security.missing-security-headers · Severity info · Category security · CWE CWE-693

Two shapes, both file-scoped: a kernel (Kernel extends HttpKernel) whose global $middleware stack names no headers middleware, and a script that sends Content-Type: text/html but never X-Content-Type-Options, Content-Security-Policy or Strict-Transport-Security. Reported as info: a reverse proxy may add them.

class Kernel extends HttpKernel
{
protected $middleware = [
\App\Http\Middleware\TrustProxies::class,
\Illuminate\Http\Middleware\HandleCors::class,
];
}
class Kernel extends HttpKernel
{
protected $middleware = [
\App\Http\Middleware\TrustProxies::class,
\Illuminate\Http\Middleware\HandleCors::class,
\App\Http\Middleware\SecurityHeaders::class,
];
}

Register a middleware that sets Strict-Transport-Security, Content-Security-Policy and X-Content-Type-Options: nosniff on every response; in plain PHP send them with header() before the body.