Tuesday, April 1, 2008

Wordpress v.2.3.3 Directory Traversal

Author: Gerendi Sandor Attila
Date: April 01, 2008
Package: Wordpress
Product Homepage: http://wordpress.org/
Versions Affected: v.2.3.3 (Other versions may also be affected)
Severity: High

The parameter “cat” in “index.php” is vulnerable to directory traversal attacks and possibly to arbitrary code inclusion/execution.

In “template-loader.php” line 35- 37 we have:
else if ( is_category() && $template = get_category_template()) {
include($template);
return;
the $template variable is supplied by the:
function get_category_template() {
$template = '';
if ( file_exists(TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php') )
$template = TEMPLATEPATH . "/category-" . get_query_var('cat') . '.php';
elseif ( file_exists(TEMPLATEPATH . "/category.php") )
$template = TEMPLATEPATH . "/category.php";
return apply_filters('category_template', $template);
}
Here we see, we can inject values after “TEMPLATEPATH/category- ...”.
One interesting 'feature' in Windows XP (possibly in some other OS too) is that we can use an existing file as base for directory traversal. For example path like “c:\boot.ini\..\boot.ini” is valid and will point to “c:\boot.ini”.

So if the Wordpress is running on a box which behave like Windows XP and there is a category template on the server named “category-xx.php” we can include arbitrary php files from the server trough the “cat” parameter.

Example:

If we have template for category 1 (category-1.php)
“http://somehost/worpress/?cat=1.php/../searchform” will include the “searchform.php” from the curent template directory.

Status:
1. Contacted the author on April 01, 2008.
2. Author promptly responded with:
http://trac.wordpress.org/changeset/7586
This will be in our upcoming 2.5.1 release.

No comments:

Post a Comment