← PHP / Laravel · Contents

PHP-067 / Intermediate

Trusting the Host header (password-reset link poisoning)

A05:2021 Security Misconfiguration · CWE-644 Improper Neutralization of HTTP Headers for Scripting Syntax

Why is this a problem?

An attacker alters the Host header so the victim receives a link to a malicious domain.

How to fix it

php
// Fix APP_URL in .env and allow only approved domains through TrustHosts middleware
protected function hosts() { return ['^app\.example\.com$']; }   // TrustHosts

Further reading