Req #66851 [Wfx]: $_SERVER holds unrelated client stuff

From: Date: Sun, 09 Mar 2014 17:07:53 +0000
Subject: Req #66851 [Wfx]: $_SERVER holds unrelated client stuff
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184646@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66851&edit=1

 ID:                 66851
 Updated by:         rasmus@php.net
 Reported by:        eldmannen+php at gmail dot com
 Summary:            $_SERVER holds unrelated client stuff
 Status:             Wont fix
 Type:               Feature/Change Request
 Package:            Variables related
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

It is the web server that communicates with the client, not PHP. It sets a number of variables about
the current executing request. It is not PHP's job to try to figure out if a piece of
information set by the server originated from the server or the client. In fact we have no way to
determine this. We can make some guesses, but then when another server comes along and sets
something we haven't seen before we won't know where that came from. We simply put
everything the server sets into the $_SERVER array. This is simple, consistent, future-proof and
easy for everyone to understand. What you are suggesting would lead to chaos and bugs if we were to
try to guess as to the origin of every piece of data provided to us by the server.


Previous Comments:
------------------------------------------------------------------------
[2014-03-09 17:02:55] eldmannen+php at gmail dot com

So GATEWAY_INTERFACE, SERVER_ADDR, SERVER_SOFTWARE, and SERVER_ADMIN aren't server-originated
data?

While things like HTTP_USER_AGENT and HTTP_REFERER are from the client.

I see a distinction between these. Server and client.
Some of these can be trusted, others can not.

------------------------------------------------------------------------
[2014-03-09 16:48:47] phpmpan at mpan dot pl

$_SERVER doesn't hold server-originated data. It holds served-possesed data about
the execution environment. This is, among other things, information about the request currently
being processed.

------------------------------------------------------------------------
[2014-03-07 23:25:09] eldmannen+php at gmail dot com

Description:
------------
http://websec.io/2012/08/11/Can%27t-Trust-the-$_SERVER.html

The superglobal $_SERVER contains unrelated stuff such as HTTP_USER_AGENT and HTTP_REFERER which are
from the client and set by the client, not the server.

These ought to be stripped out and moved into a new superglobal called $_CLIENT.



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=66851&edit=1


Thread (5 messages)

« previous php.bugs (#184646) next »