PHP security guru Stefan Esser recently posted on some of the changes and important security issues that are likely to have significant effects for the everyday PHP coder (and user) with the release of the upcoming PHP 5.3.
Probably the simplest and most effective change that will come with PHP 5.3 is a modification to the way that $_REQUEST superglobal variables are handled. After several years of known vulnerability, it seems that the PHP developers are finally addressing one of the most risky elements of the scripting language.
For those who are unaware, the $_REQUEST superglobal variable in PHP is able to be called from anywhere in any PHP script, can not be overwritten/replaced by a user variable of the same name (though the contents can be changed) and is an associative array with the values passed via GET, POST and via cookie to the particular script ($_GET, $_POST, $_COOKIE PHP superglobals).
It took several years for the idea of disabling register_globals in the php.ini to be a default practice, and it is due to be removed from PHP 6.0 (if register_globals was enabled, any local variable could be overwritten by an equivalently named element of a superglobal array - $_GET['foo'] would overwrite $foo), but it still persists in odd corners of the Internet.
The difficulties associated with stamping out the register_globals directive are sure to be have been in the minds of the language developers when deciding to change the handling of $_REQUEST. As described by Esser, the primary change to $_REQUEST is a means to control what superglobals are looked at to form $_REQUEST, and in which order, without actually destroying or modifying the original superglobals. This means that $_REQUEST could be used to only monitor $_GET and $_POST submitted variables and ignore $_COOKIE values, or any other combination of the three.
Why not just get rid of $_REQUEST all-together, since $_GET, $_POST, and $_COOKIE already exist? Too many applications built in PHP are likely to use $_REQUEST in some form to enable a complete cutout of the superglobal. $_REQUEST does make the developer's life a little easier as they can accept user input from $_GET or $_POST without discrimination (though it is poor form to do so), but there are significant risks with allowing the user to arbitrarily overwrite values in either $_GET or $_POST.
Developing with a secure mindset means that all user-supplied data is considered potentially malicious, so it shouldn't really be a problem at the end of the day but using the relevant $_GET or $_POST superglobal vice $_REQUEST does make for better and more readable code.
Should developers continue to have access to risky functions, even when there are safer alternatives present in the core language? Some would argue that by not having the temptation in the first place, that the resultant software developed will be more secure by default, and that if developers really need access to a similar capability, they can code it themselves. Alternatively it could be argued that developers should be aware of their language of choice's limitations before attempting to code in it. Site after poorly coded site, project after poorly developed project, and sites such as the Daily WTF show that this is an extremely optimistic view to take, and one that is not borne out by reality.
In the future it is possible that $_REQUEST will go away completely, and developers should begin looking through their code to see what they can start doing now to make their code ready for future PHP versions, with the side benefit of making it more secure.
Latest on PHP
- PHP development comes to Google Android
- WordPress 3.0 blogging software released
- Horde open source groupware preps version 4 release
- Amberdms gives open source accounting green light
- Botnet authors crash WordPress sites with buggy code
- Wordpress puts RSS in the cloud for real time updates
- Drupal gains ground down under
- Microsoft offers open source link for PHP, .Net
- Zend tool beta backs PHP language upgrade
- Open source webERP takes on the big guns
Development Essentials
- Security experts name top 25 programming screw-ups
- Top 10 wicked cool algorithms
- Facebook app verification fee draws criticism
- Microsoft's openness stressed
- Yahoo's developer platform to launch this week
- Microsoft starts new developer portal
- Google API allows creating apps that can track laptops
- PHP, JavaScript, Ruby, Perl, Python, and Tcl Today: The State of the Scripting Universe
- Analyst: In-house app development fraught with waste
- Is unit testing doomed?
- WebSphere Solution Design (S20) - CBD, contract role3/09/2010
Other
I.T. & T
WebSphere Solution Design (S20) - CBD, contract role - Solution Architect - Web Application Architecture Project!3/09/2010
Other
I.T. & T
Solution Architect to provide strategic and operational consulting for the end-to-end Web Application System project! Experienced with J2EE or .NET?! - Principal Consultant - ITIL2/09/2010
Other
I.T. & T
Excellent opportunity for an experienced ITIL Principal Consultant to join an innovative leading IT Service management consultancy. Attractive packag - Mainframe Developer - COBOL - 12 Month Contract2/09/2010
Other
I.T. & T
Mainframe Developer - COBOL - 12 Month Contract - Business Systems Analyst2/09/2010
Other
I.T. & T
Perm CBD based role for an experienced Business Systems Analyst - Senior SAP Project Manager2/09/2010
Other
I.T. & T
Senior SAP Project Manager - SAP FICO Consultant - 6 week contract - West Sydney2/09/2010
Other
I.T. & T
SAP FICO Consultant - 6 week contract - West Sydney
Whitepapers
TechWorld Blogs
Recent blog posts
- Windows Phone 7: how big can it get?
- NBN gets a turn at political football
- Internet filter gets caught up in politics
- TechWorld Forums goes live
- Selective sourcing the hybrid of cloud services
- Social networks catch more business attention
- RIP Kin
- Telstra’s copper and NBN’s fibre: will the two ends meet?
- RIP Windows 2000, XP lives on
- Does the world need another iPhone? Why not
Recent comments
- java development
12 hours 40 min ago - When mine called they
13 hours 24 min ago - 3D TV cannot fall - no way! Why?
16 hours 37 min ago - Thanks for taking the time to
1 day 4 hours ago - Windows scam
1 day 12 hours ago - My only anti fraud method is
2 days 7 hours ago - Private Cloud Taxonomies
2 days 7 hours ago - ...however...
2 days 16 hours ago - This Guy
2 days 16 hours ago - Glasses Free technology
2 days 17 hours ago - FOSS community
3 days 15 min ago - i have dv6000 with nvidia
3 days 1 hour ago - i have dv6000 and suddenly
3 days 1 hour ago - This is an awesome comment.
3 days 5 hours ago - Real Estate
3 days 7 hours ago - Scam - eventvwr scammers
3 days 11 hours ago - Well I never...
5 days 2 hours ago - Too bad Microsoft was mentioned
5 days 4 hours ago - Phone card is a better option to make calls at a lower rate
5 days 8 hours ago - In other words: "Developers,
5 days 14 hours ago










Comments
Post new comment