WordPress 3.3 Cross-Site Scripting (XSS) -
3 January, 2012 by ethicalhack3r

Yesterday two Indian security researchers, Aditya Modha & Samir Shah, released an advisory outlining a Cross-Site Scripting (XSS) vulnerability within the latest version (at the time of writing) of WordPress 3.3. Many people started re-tweeting the news (including myself) and blogging about it. The problem came when I tried to reproduce the vulnerability, I couldn’t.

I started to think that the vulnerability was a miss-understanding or publicity stunt and was getting annoyed at the many people who were spreading miss-information. I contacted the researchers over Twitter and told them that I was unable to reproduce the vulnerability in any browser or on any WordPress installation including vanilla installs.

The researchers got back in touch with a link to a WordPress installation on which the vulnerability worked. The URL they gave me was an IP address. Within their environment the XSS worked.

At this point I think even the researchers were puzzled. They sent me this code that they believed was the function causing the XSS within wp-includes/functions.php http://pastebin.com/iBnpN8Zm.

function wp_guess_url() {
	if ( defined('WP_SITEURL') && '' != WP_SITEURL ) {
		$url = WP_SITEURL;
	} else {
		$schema = is_ssl() ? 'https://' : 'http://';
		$url = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']);
	}
	return rtrim($url, '/');
}

The XSS occurs because $_SERVER['REQUEST_URI'] (the URI which was given in order to access the page) was used within output before first being sanitized. Or better yet, it shouldn’t have been used at all.

The reason I couldn’t reproduce it or why the researchers couldn’t reproduce outside of their environment? The reason is the ‘else’ never gets triggered when WordPress was installed via a domain.

If you installed WordPress by accessing http://192.168.100.110/, for example, you are vulnerable. If however, like most people, but not all, installed WordPress via the domain name, http://www.ethicalhack3r.co.uk you are not vulnerable.

Quick and easy fix until WordPress release a patch? Put $_SERVER['REQUEST_URI'] through esc_html() first, esc_html($_SERVER['REQUEST_URI']).

Example (tested):

wp-includes/functions.php:3756

$url = preg_replace('|/wp-admin/.*|i', '', $schema . $_SERVER['HTTP_HOST'] . esc_html($_SERVER['REQUEST_URI']));

UPDATE –

WordPress 3.3.1 has been released that seems to fix the issue.

20 Responses



  1. If the WordPress site is running HTTPS, there is a good chance that it can still be accessed by IP address, and vulnerable to this bug.


    Comment posted on January 3, 2012 at 19:55:10 BST


  2. [...] Başka bir sitede yer alan bilgiye göre wordpress domain adresi üzerine (siteadi.com) kurulu ise açık kullanılamıyor. Fakat IP adresi(x.x.x.x) üzerinden kurulum yapılmışsa web sitesi saldırıya açık demektir.[kaynak] [...]


    Comment posted on January 3, 2012 at 23:32:55 BST


  3. [...] researcher who goes by the name of ethicalhack3r decided to try to replicate their findings using the proof of concept (PoC) code that was posted to [...]


    Comment posted on January 3, 2012 at 23:36:31 BST


  4. [...] 15 issues with WordPress 3.3. Once the vulnerability was made public other researchers tried to test the vulnerability but without success. It transpires that if WordPress is installed using [...]


    Comment posted on January 4, 2012 at 09:49:43 BST


  5. [...] researcher who goes by the name of ethicalhack3r decided to try to replicate their findings using the proof of concept (PoC) code that was posted to [...]


    Comment posted on January 4, 2012 at 10:42:04 BST


  6. [...] be reproduced/tested using an IP address (not a domain name) via Internet Explorer according to ethicalhack3r.The XSS vulnerability that affected WordPress version 3.3 has been patched in version [...]


    Comment posted on January 4, 2012 at 18:33:01 BST


  7. [...] instances installed using an IP address; instances of WordPress installed using a domain name are reportedly not [...]


    Comment posted on January 5, 2012 at 01:39:08 BST


  8. [...] instances installed using an IP address; instances of WordPress installed using a domain name are reportedly not [...]


    Comment posted on January 5, 2012 at 09:42:49 BST


  9. [...] WordPress 3.3 ist ein Update herausgegeben worden. Es behebt 15 Fehler unter denen sich eine experimentelle Cross-Site Scripting-Lücke befindet. Das Durchführen eines Updates kann also eigentlich nicht [...]


    Comment posted on January 5, 2012 at 10:41:52 BST


  10. HI!
    THANKS FOR THIS POST.
    I BEG TO SAY THAT MY 1 WORDPRESS SITE WAS HACK.

    WHEN I VISIT MY SITE IT SHOWN “HACKED BY DR.FOSAL”

    PLZ. SAY ME HOW CAN I REMOVE IT.
    THANK U SO MUCH.
    WAITING FOR RPLY.


    Comment posted on January 11, 2012 at 19:51:38 BST


  11. best solution is to remove the wordpress wp-admin and all unwanted files


    Comment posted on January 24, 2012 at 13:38:18 BST


  12. I have the same problem.Waiting for adv.


    Comment posted on January 25, 2012 at 09:47:33 BST


  13. You specifically mention installed using an IP, what of the site can be access by both IP and domain?


    Comment posted on March 20, 2012 at 13:37:12 BST

  14. ethicalhack3r

    @Phillips321

    It should depend on which you were using when you installed WordPress, the IP address of the domain name.


    Comment posted on March 21, 2012 at 23:19:50 BST

  15. ethicalhack3r

    Slight typo: ‘of’ should be ‘or’.


    Comment posted on March 21, 2012 at 23:20:49 BST


  16. I have justdPress installation address shouldn’t be the same as the site address.

    and suggest this:
    Moving WP core files to any non-standard folder will make your site less vulnerable to automated attacks. Most scripts that script kiddies use rely on default file paths. If your blog is setup on http://www.site.com you can put WP files in ie: /var/www/vhosts/site.com/www/wp-core/ instead of the obvious /var/www/vhosts/site.com/www/.

    Site and WP address can easily be changed in Options – General. Before doing so please watch this detailed video tutorial which describes what other steps are necessary to move your WP core files to another location.

    do you think it’s really an issue?


    Comment posted on March 31, 2012 at 01:46:31 BST


  17. [...] Potential cross-site scripting vulnerability on WordPress sites configured directly by IP address (tested here). [...]


    Comment posted on April 21, 2012 at 11:55:27 BST


  18. [...] Potential cross-site scripting vulnerability on WordPress sites configured directly by IP address (tested here). [...]


    Comment posted on April 21, 2012 at 11:56:41 BST

  19. kock

    Click Here for Detail


    Comment posted on August 5, 2012 at 15:51:59 BST


  20. Ocean Pv Cell Diagram president Chris Sauer says it’s a” mature technology,” compared with newer alternative energy such as solar and wind accounted for just 8. The Project’spioneering roleis in making
    these technologies available to some of the final new crop corn that will be sent to digesters capable turning the
    waste into methane, CO2 and fertiliser. While a
    weak RES will do little to push America’s market for clean-energy, this particular bill.


    Comment posted on May 25, 2013 at 05:19:06 BST

Leave a Reply