Filed Under (Articles, WordPress) by DK on 6 June 2007

heise.de security recently released an advisory regarding a common vulnerability they have found in a number of WordPress themes. BlogSecurity can verify this as it has been working on a similiar project and will release the latest version of wp-scanner later this week which includes some additional theme vulnerability checks as well as some bug fixes.

PHP_SELF is defined as follows:

The filename of the currently executing script, relative to the document root. For instance, $_SERVER[’PHP_SELF’] in a script at the address http://example.com/test.php/foo.bar would be /test.php/foo.bar. The __FILE__ constant contains the full path and filename of the current (i.e. included) file. - php.net

The vulnerability lies in using PHP_SELF without pre-pending htmlspecialchars. Let us look at an example:

Finding the vulnerability

form id="searchform" method="get" action=
"<?php echo $_SERVER['PHP_SELF']" ?>"

We can see PHP_SELF being used here to get the current URL location of the user; unfortunately, no checks are done to ensure that PHP_SELF is clean from HTML elements.

Secure Version:

form id="searchform" method="get" action=
"<?php echo htmlspecialchars($_SERVER['PHP_SELF'])" ?>"

These vulnerabilities often appear in one of these:

  • Search Facility
  • Custom 404 Pages
  • Theme Header.php (i.e. CSS, META Data)

Proof of Concept

You can test your blog by using the following proof of concept code, obviously it requires you to change the www.example.com for your site URL; the new version of wp-scanner includes this check, it will be released later this week:

http://www.example.com/index.php/"><script>alert(1)</script>

If you receive a JavaScript popup your template is vulnerable to this attack.

In summary, look through your template for PHP_SELF and ensure that the appropriate fix is applied. Alternatively submit your site to us for inspection; all correspondence will be treated with strict confidence.

References:

Read and Contribute to BlogSec News!

Comments

zamolx3 on 6 June, 2007 at 11:44 pm #

There is a mistake in your post.
To check if you blog is vulnerable you should use:

http://www.example.com/index.php/“>alert(1)

Your URL is missing a before script tag.


zamolx3 on 6 June, 2007 at 11:48 pm #

Damn, my comment was mutilated by your filters :)
http://www.example.com/index.php/“][script]alert(1)[/script]
Anyway, you got the point.


Alerte de sécurité - thèmes WordPress on 7 June, 2007 at 1:31 am #

[…] BlogSecurity nous annonce ce matin qu’une faille de sécurité dans certains thèmes a été trouvée par Heise.de. […]


David Kierznowski on 7 June, 2007 at 2:23 am #

zamolx3: corrected thanks.


BlogSecurity » New Release: WordPress Scanner on 10 June, 2007 at 4:21 pm #

[…] new release includes an XSS vulnerability check for WordPress templates, as well as a number of bug […]


BlogSecurity » WordPress Scanner on 10 June, 2007 at 4:22 pm #

[…] v1.1 Released - XWordPress Template XSS Check - Bug fixes especially in other XSS […]


[…] nice article explaining the vulnerability in Worpdress themes (in fact anything using php :-) was […]


datenschmutz.net on 1 July, 2007 at 11:27 am #

Blogistan Panoptikum Woche 26 2k7…

WordPress Tools, neue Themes und philosophische Betrachtungen zum Longtail: das zweite Quartal 2007 endet mit hohen Temperaturen und ebensolcher Postingfrequenz.
……


Robert on 25 July, 2007 at 10:56 pm #

There’s a ” too much.
The secure version must be:
form id="searchform" method="get" action=
""
(delete the _)


BlogSecurity » Top 10 Vulnerable WP Themes on 5 August, 2007 at 11:13 pm #

[…] June we wrote an article on common WordPress template flaws and thought we’d follow up on […]


Los themes de Wordpress y el XSS | aNieto2K on 6 August, 2007 at 9:42 am #

[…] la vulnerabilidad más común en nuestros themes suelen estar relacionadas con el buscador, ya que es una de las formas en las […]


[rmfo-blogs.com]: About on 6 August, 2007 at 8:36 pm #

WP 2.2.2 and Theme Vulnerabilities…

As you may have noticed, the fine folks at WordPress have released WP v2.2.2 into the (deuces) wild. I have taken the unusual step of upgrading RMFO-Blogs users first, rather than RMFO-Pro users. Why? Simply put, RMFO-Blogs has been getting hammered…


that girl again on 9 August, 2007 at 7:08 pm #

Are there any other holes theme developers need to be looking for, or is this the only one? I develop all my themes locally so I can’t use the scanner plugin to check them, even if I was happy with the idea of allowing a random third-party script access to my install.


David Kierznowski on 9 August, 2007 at 10:31 pm #

that girl again, yes potentially there are loads of programming errors to watch out for, however, these are some of the more obvious ones. We will definately look at writing more articles to help educate users a little more in this area.


11,5% dos blogs estão vulneráveis a ataques on 21 August, 2007 at 3:06 am #

[…] você utiliza algum destes temas saiba como corrigir este problema. Caso utilize outro tema baixe agora mesmo o wp-scanner e faça o teste em seu blog. Escreva um […]


[…] Common Wordpress theme vulnerabilities: http://blogsecurity.net/wordpress/article-070607/ […]


don’t hold your breath « wordpress™ wank on 11 December, 2007 at 5:28 pm #

[…] them down, but it’s worth a go. If you’re scouting for excuses, there’s a handy security hole which is Kubrick-derived so should be in more themes than […]


WordPress Templates sicherer machen | WordPress-Buch on 6 February, 2008 at 11:46 am #

[…] BlogSecurity: Common WP Theme Vulnerabilities […]


[…] מידע נוסף על הפרצה אפשר לקרוא כאן. […]


[…] theme is not a problem to me as long it’s fair and safe. So I ask you guys, how safe your theme, did you check your theme? Remember, even the wordpress.org have a problem to all sponsored theme submitted to them. Some […]


Comment
Name:
Email:
Website:
Message: