WordPress 3.2.1 core module post-template.php XSS vulnerability and repair

Source: Internet
Author: User

Author: Darshit Ashara
Date: 21/08/2011
Vendor: Wordpress
Version: 3.2.1

Incorrect WordPress core module code (post-template.php)
This causes cross-site scripting.
I can simply update
View plaincopy to clipboardprint?
</A> <script> alert ('1'); </script> <a>
</A> <script> alert ('1'); </script> <a>
Will affect the index page and the back page.
The vulnerability has been notified to the official website.
The following www.2cto.com is a temporary repair method:
View plaincopy to clipboardprint?

/* This will page XSS in Index Page */
Vulnerable Code Part 1
Function the_title ($ before = '', $ after ='', $ echo = true ){
$ Title = get_the_title ();
 
If (strlen ($ title) = 0)
Return;
 
$ Title = $ before. $ title. $ after;
 
If ($ echo)
Echo htmlentities ($ title);/* Line No 52 Patch */
Else
Return htmlentities ($ title);/* Line No 54 Patch */
}
 
 
Vulnerable Code Part 2
Function the_title_attribute ($ args = ''){
$ Title = get_the_title ();
 
If (strlen ($ title) = 0)
Return;
 
$ Defaults = array ('before' => '', 'after' =>'', 'echo '=> true );
$ R = wp_parse_args ($ args, $ defaults );
Extract ($ r, EXTR_SKIP );
 
 
$ Title = $ before. $ title. $ after;
$ Title = esc_attr (strip_tags ($ title ));
 
If ($ echo)
Echo htmlentities ($ title);/* Line No 87 Patch here By adding htmlentities */
Else
Return htmlentities ($ title);/* Line No 89 Patch */
}
 
/* This will Patch XSS in Post page */
 
Vulnerable Code Part 3
Function get_the_title ($ id = 0 ){
$ Post = & get_post ($ id );
 
$ Title = isset ($ post-> post_title )? $ Post-> post_title :'';
$ Id = isset ($ post-> ID )? $ Post-> ID: (int) $ id;
 
If (! Is_admin ()){
If (! Emptyempty ($ post-> post_password )){
$ Protected_title_format = apply_filters ('protected _ title_format ', _ ('protected: % s '));
$ Title = sprintf ($ protected_title_format, $ title );
} Else if (isset ($ post-> post_status) & 'private' ==$ post-> post_status ){
$ Private_title_format = apply_filters ('private _ title_format ', _ ('private: % s '));
$ Title = sprintf ($ private_title_format, $ title );
}
}
Return htmlentities (apply_filters ('the _ title', $ title, $ id);/* Line No 119 Patch */
}
 
/* This will page XSS in Index Page */
Vulnerable Code Part 1
Function the_title ($ before = '', $ after ='', $ echo = true ){
$ Title = get_the_title ();

If (strlen ($ title) = 0)
Return;

$ Title = $ before. $ title. $ after;

If ($ echo)
Echo htmlentities ($ title);/* Line No 52 Patch */
Else
Return htmlentities ($ title);/* Line No 54 Patch */
}


Vulnerable Code Part 2
Function the_title_attribute ($ args = ''){
$ Title = get_the_title ();

If (strlen ($ title) = 0)
Return;

$ Defaults = array ('before' => '', 'after' =>'', 'echo '=> true );
$ R = wp_parse_args ($ args, $ defaults );
Extract ($ r, EXTR_SKIP );


$ Title = $ before. $ title. $ after;
$ Title = esc_attr (strip_tags ($ title ));

If ($ echo)
Echo htmlentities ($ title);/* Line No 87 Patch here By adding htmlentities */
Else
Return htmlentities ($ title);/* Line No 89 Patch */
}

/* This will Patch XSS in Post page */

Vulnerable Code Part 3
Function get_the_title ($ id = 0 ){
$ Post = & get_post ($ id );

$ Title = isset ($ post-> post_title )? $ Post-> post_title :'';
$ Id = isset ($ post-> ID )? $ Post-> ID: (int) $ id;

If (! Is_admin ()){
If (! Empty ($ post-> post_password )){
$ Protected_title_format = apply_filters ('protected _ title_format ', _ ('protected: % s '));
$ Title = sprintf ($ protected_title_format, $ title );
} Else if (isset ($ post-> post_status) & 'private' ==$ post-> post_status ){
$ Private_title_format = apply_filters ('private _ title_format ', _ ('private: % s '));
$ Title = sprintf ($ private_title_format, $ title );
}
}
Return htmlentities (apply_filters ('the _ title', $ title, $ id);/* Line No 119 Patch */
}


Source: fallen leaves's Blog

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.