1 Nov 2013

A Note on Security of PHP

php , javascript , html5 , css3 , web design development
PHP is a powerful and versatile tool. This power and adaptability comes from PHP being a really thin framework sitting on prime of dozens of distinct 3rd-party libraries. every of those libraries have their own distinctive input data characteristics. data that will be safe to pass to at least one library might not be safe to pass to a different.

A recent internet Worm referred to as NeverEverSanity exposed a slip within the input validation within the standard phpBB message board application. Their highlighting code did not account for double-urlencoded input properly. while not correct input validation of untrusted user data combined with any of the PHP calls that may execute code or write to the filesystem you produce a potential security drawback. Despite some confusion relating to the temporal order of some unrelated PHP security fixes and also the NeverEverSanity worm, the worm did not even have something to try to to with a security drawback in PHP.

When we name security in a very internet application we actually have 2 classes. Remote and local. each remote exploit are often avoided with terribly careful input validation. If you're writing an application that asks for a user's name and age, check and ensure you're solely obtaining characters you'd expect. conjointly ensure you're not obtaining an excessive amount of data that may overflow your backend data storage or no matter manipulation functions you'll be passing this data to. A variation of the remote exploit is that the XSS or cross-site scripting drawback wherever one user enters some javascript that consequent user then views.

For local exploits we principally hear concerning open_basedir or safemode issues on shared virtual hosts. These 2 options are there as a convenience to system administrators and may in no means be thought of as an entire security framework. With all the 3rd-party libraries you'll hook into PHP and every one the inventive ways that you'll trick these libraries into accessing files, it's not possible to ensure security with these directives. The Oracle and Curl extensions each have ways that to travel through the library and browse a local file, as an example. wanting modifying these 3rd-party libraries, which might be tough for the closed-source Oracle library, there extremely is not a lot of PHP will do regarding this.

When you have PHP by itself with solely alittle set of extensions safemode and open_basedir are usually enough to frustrate the typical soul, except for crucial security things you must be using OS-level security by running multiple internet servers every as their own user id and ideally in separate jailed/chroot'ed filesystems. Better yet, use utterly separate physical servers. If you share a server with somebody you do not trust you wish to understand that you simply can ne'er reach airtight security.

No comments:

Post a Comment