Hey!
I am writing code which is served by a freeBSD/Apache machine. The code will not be moved to another server, so I am not concerned with ever running it in another environment or another machine.
A couple of the pages require data to be passed via the query string as opposed to through a form, so one of my concerns is protecting the integrity of that data. I have some security measures in place, but was wondering if anyone sees any harm in using the $_SERVER['HTTP_REFERER'] variable as a secondary security check.
For example, whenever someone clicks on a link, the referer value is my server that the code is running on, which is what I want. However, if the user messes with the query string in any way (inserts variables, changes values, etc), the referer value is no longer reported as my server. So, if the referer variable I get back is not my server, I can tell that the query string was modified and I don't accept that data.
I have tested this with IE, Netscape, and Mozilla and it works fine. PHP.net however, says: "HTTP_REFERER--The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted." Again, as a person that wants to code securely, I've added this as a secondary measure--not the only thing I am relying on.
So, can anyone tell me if, for some reason, this is a bad idea? I've tested and tested it and it seems to work fine, but someone out there may know of some reasons not to use this. The PHP.net quote keeps haunting me! Sounds like a browser issue (user agent), but the three main browsers I tested on worked fine...
Thanks in advance!