10 August
2005

Web Application Security

Chris Shifflet gave a talk on PHP security at OSCON 2005 last week and made his slides available online through his blog. Chris Shifflet is the founder of Brain Bulb, a PHP consultancy firm, and is the author of a number of books on PHP security. While his slides are no replacement for his books and other detailed references online, they do a great job at illustrating the biggest reason why I shy away from PHP in general, and from hosting untrusted PHP applications in particular: PHP relies heavily on a programmer's vigilance for security.

As a security-conscious systems administrator who cannot afford to spend time personally auditing each and every line of PHP code on my servers, programmer vigilance is an often unacceptable assumption. It's terrifying just looking at the steady stream of advisories about remotely-exploitable vulnerabilities of applications written in PHP, on mailing lists like BugTraq, or specialized forums like phpSecure();.


Worse, many of these programs are community-driven projects used and developed by more than one person, with source code that can be freely reviewed and audited. Imagine the increased risk of using PHP as a platform for web-based applications that sit between relatively sensitive corporate data and the Internet, developed and maintained by anywhere from one to a handful of in-house PHP developers who are subjected to rapidly changing requirements and insane deadlines.

There is nothing wrong with PHP per se, but the risks are obvious. As a web development platform, it allows developers a tad too much freedom. Unless ample investments are made to allow for the proper security-oriented training of a PHP development team, and regular, timely security audits of PHP applications, PHP applications offer a relatively easy entry point into sensitive corporate data and critical systems.


ZOPE AS AN ALTERNATIVE

As a consultant with experience in both systems administration and web application development, I highly recommend Zope as an alternative development and hosting platform. Among the many benefits that Zope brings, one that stands out significantly over PHP is the tightly-integrated security system built into Zope from the ground up. The Zope Developer's Guide makes a clear point about this with its summary of the default Zope security policy. To wit:


  • access to an object which does not have any associated security information is always denied.

  • if an object is associated with a permission, access is granted or denied based on the user's roles. If a user has a role which has been granted the permission in question, access is granted. If the user does not possess a role that has been granted the permission in question, access is denied.

  • if the object has a security assertion declaring it public, then access will be granted.

  • if the object has a security assertion declaring it private, then access will be denied.

  • accesses to objects that have names beginning with the underscore character _ are always denied.


Zope's object database layer and the lack of direct involvement between web applications and actual files on the server provides a vital layer of security that makes access to arbitrary files on the server's filesystem a difficult feat. Access to arbitrary objects within theobject database is likewise restricted by Zope's deny-by-default security policy. Couple these with built-in virtual hosting capabilities, the ability of folders to have their own user databases and security policies, and the powerful but restricted web-based management interface, and Zope allows for relatively secure multi-system web application hosting, especially in environments where users may not trust each other or may not be counted on to be extremely vigilant about security.

Zope also handles input filtering and output escaping by default, especially when accessing databases through Z SQL Methods. Z SQL Methods further enable the restriction of access to database login and password information, as well as database schema. By providing the capability to restrict access to the configuration of database and SQL objects, work can be delegated to multiple
"security levels" of web application developers. For example, "HTML form managers" may be designated to work with the data through database and SQL objects, which are in turn handled by more senior developers with direct information about the databases and training about query optimization.

The possibilities with Zope are endless. Despite the fact that PHP developers and F/OSS applications written in PHP are easier to find, Zope provides a viable alternative for organizations needing to develop and maintain secure web application systems that provide selective access to sensitive corporate data.

Posted by Federico Sevilla III at 02:26 | Comments (6)
Comments
Re: Web Application Security

Nice post Jijo.

I too have been moving over to Zope for some of our projects as you may already know. I can't find anything in the PHP world that compares to Zope's built-in security model.

Perhaps what PHP needs is a framework that treats security as an essential component and not as an afterthought. So far, I haven't come across anything.

Posted by: Angelo Abarentos at August 16,2005 09:49
Re: Web Application Security

zope is undoubtedly a very robust framework. how do you address the issues :

- speed (a lot has been said regarding the performance of zope)

- marketability (in terms of plugging it to future clients). most developers code at the mercy of what the clients have in their web application host of choice.

thanks in advance.

Posted by: cyx at August 23,2005 11:14
Re: Web Application Security

For single-server Zope installations, using a caching HTTP accelerator like Squid in front of the Zope instance significantly improves its performance. For installations that need more than one server, Zope Enterprise Objects (ZEO) allows you to have a farm of Zope instances that keep each other up-to-date. Coupled with a load-balancer like Pound, this allows you to scale a server farm as the load increases without having to drastically change your web application structure.

As to web application developers being at the mercy of their clients' choices, that's just how life is. Using PHP doesn't fix things if you have a client who insists on using ASP, does it? Of course PHP is admittedly more widely-supported on hosting providers, although there are also a number of good hosting providers who provide Zope hosting.

Posted by: Federico Sevilla III at August 24,2005 00:48
Re: Web Application Security

Yeah sadly MS has gained a lot of footing on the SME scene, and has somehow convinced a lot of people that .NET is "secure" (but that's for a whole different topic)

I have been doing some research regarding Ruby on Rails against Zope (as they are primarily good frameworks for their respective languages) and it seems RoR doesn't have an extensive support for security that Zope have. Do you have any recommendations regarding the matter? Somewhat a balance between RAD and robust framework capabilities.

In addition, does Zope offer an Object Relational Mapping Layer out of the box in conjunction with the usual DBs? How i wish that OODBMS'es would flourish in the enterprise scene.

Lastly, being a PHP developer namespaces and unicode, i18n support in general are probably my top frustrations. Does Zope offer good support for this? It's all sad when you are at the mercy of wide acceptance, being a PHP developer i can't even make the switch to PHP5.

Posted by: cyx at August 24,2005 07:22
Re: Web Application Security

You may want to check out the React Framework for Zope. It's still a very young project, but I'm sure you'll want to check it out. It aims to bring the MVC organization popularized by RoR to the Zope framework and make web application development on Zope more fun.

I don't know if it qualifies as an "Object Relational Mapping Layer", but accessing data in SQL RDBMSes using Z SQL Methods is painless. Z SQL Methods are actually one of the strongest points of Zope as a web application development platform for enterprises, since the Z SQL Methods, which contain your SQL, can be maintained by a separate team of SQL experts, while the actual web interface can be delegated to a team of Web Interface experts, who will access the data through the Z SQL objects. You'll probably want to give the Z SQL Methods User's Guide a quick spin to see what Z SQL Methods are all about, and if they'll suit your needs.

The i18n issue I don't know squat about, honestly. A quick Google for "zope i18n" turns up quite a bit, but I don't know what your particular i18n requirements are, and whether Zope gracefully supports these out of the box, at the moment.

Posted by: Federico Sevilla III at August 24,2005 12:31
Re: Web Application Security

yeah thanks for the responses. i'll sure take a look at react, and zope. as of now i need to eat so that means i must continue to develop using PHP.

Posted by: cyx at August 24,2005 22:37