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
- 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
- Zend PHP framework accesses Amazon cloud
- Zend Technologies readies a new PHP application server
- Open source identity: Spine CMS creator Hendrik Van Belleghem
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?
- Instructional Designer (Training Developer) (s15)10/02/2010
Other
I.T. & T
Instructional Designer (Training Developer) (s15) - BUSINESS DEVELOPMENT MANAGER - CONTENT MANAGEMENT SYSTEMS, INTRANETS,10/02/2010
Other
I.T. & T
BUSINESS DEVELOPMENT MANAGER - CONTENT MANAGEMENT SYSTEMS, INTRANETS, - Informatica PowerCenter Consultants10/02/2010
Other
I.T. & T
Informatica PowerCenter Consultants - WEB CONTENT MANAGEMENT SYSTEMS - BUSINESS DEVELOPMENT MANAGER10/02/2010
Other
I.T. & T
WEB CONTENT MANAGEMENT SYSTEMS - BUSINESS DEVELOPMENT MANAGER - Senior Tester9/02/2010
Other
I.T. & T
Senior Tester
Whitepapers
-
CIO Executive Guide | Unlocking the Potential of Automated Accounts Payable -
Beyond PCI Checklists: Securing Cardholder Data with enhanced File Integrity Monitoring -
Gartner's Magic Quadrant for PC Configuration Life Cycle Management Tools -
Keeping your SQL Server Going 24x7 -
Business Continuity: A Guide to Choosing the Right Technology Solution
TechWorld Blogs
Recent blog posts
- Talk about mobile computing
- iPad arrives: can Apple crack the tablet?
- Linux.conf.au 2010 kicks off in New Zealand
- VMware jumps further into SaaS with Zimbra
- Amarok 2.2.2 released – rock on!
- Happy Nexus Year
- So long 2009, and thanks for another decade in tech
- KDE 4.4 enters beta, bring on mainstream computing
- Chromium OS source released: another way of thinking
- Dell goes Android for mobile market entrance
Recent comments
- RE: Report: Google to make Gmail more social
18 min 2 sec ago - Buy 2 get 1 free: Apple iphone 3gs 32gb,Nokia N97,BB Bold,HTC HD
5 hours 53 min ago - My Take:
6 hours 10 min ago - PDA Smart phone users
15 hours 22 min ago - Touch Phone Accessories
15 hours 30 min ago - joo joo
16 hours 21 min ago - Thanks!
1 day 11 hours ago - Transcription mistake
2 days 12 hours ago - Freeway is hardly Australian
2 days 14 hours ago - Great Business Initiative
3 days 9 hours ago - www.mintfly.com
3 days 14 hours ago - also creating unemployment
4 days 6 hours ago - How to save in one page???
5 days 8 hours ago - Well it's 2010 now...
5 days 17 hours ago - Man, catch up. You're being
6 days 18 hours ago - Rhapsody in Australia
6 days 19 hours ago - ipad reaction
1 week 10 hours ago - Capacity Bollenecks
1 week 1 day ago - not only for "young folks"
1 week 1 day ago - Take action now
1 week 2 days ago







Comments
Post new comment