+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11
Like Tree1Likes

Thread: Wordpress 3.2.1 Core (post-template.php) Improper Sanitizing(Persistent XSS) Share/Save - My123World.Com!

  1. #1
    Garage Member silentph33r will become famous soon enough
    Join Date
    Jul 2010
    Posts
    52
    Thanks
    34
    Thanked 18 Times in 7 Posts

    Wordpress 3.2.1 Core (post-template.php) Improper Sanitizing(Persistent XSS)



    ================================================== =====
    Improper sanitized code in Wordpress Core Module(post-template.php)
    Causing Cross site Scripting.

    Author can simply Update his Post title to </a><script>alert('1');</script><a>
    and its will give out alert on index page and post page.


    Below are the temporary patches for fixing.
    Vendor notified about this vulnerability.


    /*This will patch XSS in Index Page*/
    Vulnerable Code Part 1
    PHP Code:
    function the_title($before ''$after ''$echo true) {
        
    $title get_the_title();

        if ( 
    strlen($title) == )
            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
    PHP Code:
    function the_title_attribute$args '' ) {
        
    $title get_the_title();

        if ( 
    strlen($title) == )
            return;

        
    $defaults = array('before' => '''after' =>  '''echo' => true);
        
    $r wp_parse_args($args$defaults);
        
    extract$rEXTR_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*/
    PHP Code:
    Vulnerable Code Part 3
    function get_the_title$id ) {
        
    $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*/

    Last edited by silentph33r; 02-16-2012 at 06:02 PM.

  2. The Following 7 Users Say Thank You to silentph33r For This Useful Post:

    41.w4r10r (08-22-2011), AnArKI (08-21-2011), cool (08-21-2011), d4rkd4wn (08-22-2011), fb1h2s (08-21-2011), keval_domadia (08-21-2011), prashant_uniyal (08-21-2011)

  3. #2
    Garage Newcomer keval_domadia is on a distinguished road
    Join Date
    Dec 2010
    Posts
    38
    Thanks
    7
    Thanked 19 Times in 7 Posts
    WP's Core module vulnerable to XSS reminded about one of the status updates that Rahul had put once on Facebook about, one of his senior trying basic SQLi on Gmail and vote was whether he was optimistic or stupid.
    I would reply, optimistic! \m/

    Never under-estimate anyone and......... never over-estimate either!
    31337 - 7H15 15 4n 4nn071ng!
    Study English - write Eleet

  4. #3
    Security Researcher fb1h2s has a spectacular aura aboutfb1h2s has a spectacular aura aboutfb1h2s has a spectacular aura about fb1h2s's Avatar
    Join Date
    Jul 2010
    Location
    India
    Posts
    596
    Blog Entries
    23
    Thanks
    279
    Thanked 150 Times in 76 Posts
    Great Work keep it up, , some good action , and few points to note.'

    1) Since it's WP core module, there are many vulnerability vendors which pays for Vbulletin and Wordpress bugs.
    2) Was this a full disclosure ? or did u contact the vendor(either way not an issue , just a doubt).
    3) You kind of missed to put in detail of the attack surface, like is it possible for (guest, user) accounts to exploit this or only admin could trigger the bug . These sort of info would be helpful to N00bs like us .
    Hacking Is a Matter of Time Knowledge and Patience

  5. #4
    Garage Member silentph33r will become famous soon enough
    Join Date
    Jul 2010
    Posts
    52
    Thanks
    34
    Thanked 18 Times in 7 Posts
    this can be said as Full Disclosure (With Patch)

    And i also notified the vendor and this can be triggered with user having author account.

  6. #5
    InfoSec Consultant 41.w4r10r has a spectacular aura about41.w4r10r has a spectacular aura about41.w4r10r has a spectacular aura about 41.w4r10r's Avatar
    Join Date
    Jul 2010
    Location
    Pune
    Posts
    301
    Thanks
    31
    Thanked 82 Times in 37 Posts
    Quote Originally Posted by silentph33r View Post
    this can be said as Full Disclosure (With Patch)

    And i also notified the vendor and this can be triggered with user having author account.
    Nice find also note fb1's suggestion no 1

  7. #6
    InfoSec Consultant 41.w4r10r has a spectacular aura about41.w4r10r has a spectacular aura about41.w4r10r has a spectacular aura about 41.w4r10r's Avatar
    Join Date
    Jul 2010
    Location
    Pune
    Posts
    301
    Thanks
    31
    Thanked 82 Times in 37 Posts
    Quote Originally Posted by silentph33r View Post
    this can be said as Full Disclosure (With Patch)

    And i also notified the vendor and this can be triggered with user having author account.
    Nice find also note fb1's suggestion no 1

  8. #7
    lol
    lol is offline
    Garage Newcomer lol is on a distinguished road
    Join Date
    Sep 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This wasnt found by you, it was found by t0asty from Belegit.

    Why did you rip him off? Im sure hell be pissed...

  9. #8
    Garage Hyper Addict b0nd is a jewel in the roughb0nd is a jewel in the roughb0nd is a jewel in the rough b0nd's Avatar
    Join Date
    Jul 2010
    Location
    irc.freenode.net #g4h
    Posts
    644
    Thanks
    140
    Thanked 270 Times in 109 Posts
    Quote Originally Posted by lol View Post
    This wasnt found by you, it was found by t0asty from Belegit.

    Why did you rip him off? Im sure hell be pissed...
    Banned!
    Should have presented proof instead of just blaming.
    [*] To follow the path: look to the master, follow the master, walk with the master, see through the master,
    ------> become the master!!! <------
    [*] Everyone has a will to WIN but very few have the will to prepare to WIN
    [*] Invest yourself in everything you do, there's fun in being serious

  10. #9
    Garage Newcomer GenesMan is on a distinguished road
    Join Date
    Nov 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I suggest another patch, instead parsing $title variables through htmlentities function, thus showing wrong UTF-8 characters in post titles, we could use the strip_tags and esc_attr functions to sanitize.

    PHP Code:
    function the_title($before ''$after ''$echo true) {
        
    $title get_the_title();

        if ( 
    strlen($title) == )
            return;

        
    $title $before $title $after;
        
    $title esc_attr(strip_tags($title)); // Add this PATCH just after line #49
        
    if ( $echo )
            echo 
    $title;
        else
            return 
    $title;

    PHP Code:
    function the_title_attribute$args '' ) {
        
    $title get_the_title();

        if ( 
    strlen($title) == )
            return;

        
    $defaults = array('before' => '''after' =>  '''echo' => true);
        
    $r wp_parse_args($args$defaults);
        
    extract$rEXTR_SKIP );


        
    $title $before $title $after;
        
    $title esc_attr(strip_tags($title)); // Add this PATCH line after line #83

        
    if ( $echo )
            echo 
    $title;
        else
            return 
    $title;

    PHP Code:
    function get_the_title$id ) {
        
    $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 
    esc_attr(apply_filters'the_title'$title$id )); // Patch to line #119 

    Now the titles on posts are sanitized and wont allow Cross-Site Scripting. Hope this help.
    fb1h2s likes this.

  11. #10
    Garage Newcomer d4rkpyth0n is on a distinguished road d4rkpyth0n's Avatar
    Join Date
    Dec 2011
    Posts
    27
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Cong0 silent for ur first exploit..(peace out if u wrote another before)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts