UmaWorld's avatar

$_SERVER['HTTP_REFERER'] is a browser-sent value that usually tells you which page the user came from.

ChatGPT saying like ,

No, not really:

HTTP_REFERER can be missing or faked, depending on browser settings.

It should not be relied on for security, but it’s okay for flow control or basic UX.

is that true?

0 likes
4 replies
Glukinho's avatar

Yes it's true. Anybody can send anything in HTTP_REFERER header, you shouldn't trust it.

UmaWorld's avatar

difficult to understand this type security concern

Glukinho's avatar

@UmaWorld Just don't rely on this value for security consideration.

For example, deciding to allow access to your application based on this header is wrong. But deciding to show a customized greeting to user may be acceptable.

1 like
martinbean's avatar
Level 80

@umaworld Yes, it’s true. The HTTP_REFERER heading can be spoofed or just not sent at all. For example, after clicking a link with an rel="noreferrer" attribute.

From https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/rel/noreferrer:

The noreferrer keyword for the rel attribute of the <a>, <area>, and <form> elements instructs the browser, when navigating to the target resource, to omit the Referer header and otherwise leak no referrer information — and additionally to behave as if the noopener keyword were also specified.

So you shouldn’t be relying on this header being present, let alone being trustworthy.

1 like

Please or to participate in this conversation.