Jump to content

Recommended Posts

Do not use register_globals. It is depreciated as of PHP 6 as it should have been from the get go.

 

extract is better, but I would not use it on a SUPER GLOBAL. Just call the array index instead. It is faster than using a variable, and ensure's more security. But yes, extract would be more secure than leaving register_globals on. But extracting still poses the similar threat if your code is not done properly.

Extract should only be used with the second parameter of EXTR_PREFIX_ALL and a unique prefix so that there is no chance of overwriting your existing program variables, like register_globals did.

 

Let us say the first thing your code on a page does is figure out who is logged in and/or who is an administrator on your site and sets a variable $admin = TRUE, then at some point later you extract($_REQUEST) and I am a hacker and visit your site with ?admin=TRUE on the end of the URL. I just became an administrator on your site.

 

You should also not use $_REQUEST because it combines POST/GET/COOKIE. Think of all the code that has not worked properly because someone forgot that they had a COOKIE by a specific name and they added a form a couple months later that tried to get a form to work that had a field with the same name. If you expect data in $_POST, use $_POST, if you expect data in $_GET, use $_GET, and if you expect data in $_COOKIE, use $_COOKIE. Using $_REQUEST also makes it easier for a hacker because he can just set there changing parameters on the end of the URL in order to send your code various COOKIE values.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.