Thursday, July 19, 2012

This is a security advisory for popular PHP framework - CodeIgniter. I've found several bypasses in xss sanitization functions in the framework. These were responsibly disclosed to the vendor and are now fixed in version 2.1.2. (CVE-2012-1915).

Affected products

CVE

CVE-2012-1915

Introduction

CodeIgniter ( http://codeigniter.com) is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications. CodeIgniter comes with a Cross Site Scripting Hack prevention filter which can either run automatically to filter all POST and COOKIE data that is encountered, or you can run it on a per item basis. Several vectors bypassing claimed XSS filter protections have been found in 2.1.0 version of the framework. In cooperation with vendor, these have been fixed in version 2.1.2.

Description

XSS filter of CodeIgniter framework is implemented in xss_clean() function defined in system/core/Security.php file. It uses multiple, mostly blacklist-oriented methods to detect and remove XSS payloads from the passed input. As per documentation of the filter ( http://codeigniter.com/user_guide/libraries/security.html ) the filter is supposed to be run on input passed to the application e.g. before saving data in the database i.e. it's not an output-escaping, but input sanitizing filter.

There are multiple ways to bypass the current version of the filters, exemplary vectors are given below:

Mitigation

Upgrade to CodeIgniter >= 2.1.2. Avoid using xss-clean() function. It's based on multiple blacklists and will therefore unavoidably be bypassable in the future. For input filtering, use HTMLPurifier ( http://htmlpurifier.org/ ) instead.

When it comes to value modularity CodeIgniter is one of the most severe artists in the market. CodeIgniter is not designed using any flip style design so all alternatives are after-thoughts that were designed by associates of the group.

CodeIgniter Development is really a widely used framework offered y PHP and I found it quite compatible and secure and this is the most important benefit why everyone is preferring to hire CodeIgniter developers for designing their applications.