Changeset 2245 in subversion


Ignore:
Timestamp:
Jan 20, 2009 11:28:33 AM (4 years ago)
Author:
thomasb
Message:

Treat 'background' attributes the same way as 'src' (another XSS vulnerability)

Location:
trunk/roundcubemail
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/CHANGELOG

    r2242 r2245  
    11CHANGELOG RoundCube Webmail 
    22--------------------------- 
     3 
     42009/01/20 (thomasb) 
     5---------- 
     6- Fix XSS vulnerability through background attributes as reported by Julien Cayssol 
    37 
    482009/01/18 (alec) 
  • trunk/roundcubemail/program/lib/washtml.php

    r1811 r2245  
    8181   
    8282  /* Allowed HTML attributes */ 
    83   static $html_attribs = array('name', 'class', 'title', 'alt', 'width', 'height', 'align', 'nowrap', 'col', 'row', 'id', 'rowspan', 'colspan', 'cellspacing', 'cellpadding', 'valign', 'bgcolor', 'color', 'border', 'bordercolorlight', 'bordercolordark', 'face', 'marginwidth', 'marginheight', 'axis', 'border', 'abbr', 'char', 'charoff', 'clear', 'compact', 'coords', 'vspace', 'hspace', 'cellborder', 'size', 'lang', 'dir', 'background');   
     83  static $html_attribs = array('name', 'class', 'title', 'alt', 'width', 'height', 'align', 'nowrap', 'col', 'row', 'id', 'rowspan', 'colspan', 'cellspacing', 'cellpadding', 'valign', 'bgcolor', 'color', 'border', 'bordercolorlight', 'bordercolordark', 'face', 'marginwidth', 'marginheight', 'axis', 'border', 'abbr', 'char', 'charoff', 'clear', 'compact', 'coords', 'vspace', 'hspace', 'cellborder', 'size', 'lang', 'dir');   
    8484   
    8585  /* State for linked objects in HTML */ 
     
    161161      $value = $node->getAttribute($key); 
    162162      if(isset($this->_html_attribs[$key]) || 
    163          ($key == 'href' && preg_match('/^(http|https|ftp|mailto):.*/i', $value))) 
     163         ($key == 'href' && preg_match('/^(http|https|ftp|mailto):.+/i', $value))) 
    164164        $t .= ' ' . $key . '="' . htmlspecialchars($value, ENT_QUOTES) . '"'; 
    165165      else if($key == 'style' && ($style = $this->wash_style($value))) 
    166166        $t .= ' style="' . $style . '"'; 
    167       else if($key == 'src' && strtolower($node->tagName) == 'img') { //check tagName anyway 
     167      else if($key == 'background' || ($key == 'src' && strtolower($node->tagName) == 'img')) { //check tagName anyway 
    168168        if($src = $this->config['cid_map'][$value]) { 
    169169          $t .= ' ' . $key . '="' . htmlspecialchars($src, ENT_QUOTES) . '"'; 
    170170        } 
    171         else if(preg_match('/^(http|https|ftp):.*/i', $value)) { 
     171        else if(preg_match('/^(http|https|ftp):.+/i', $value)) { 
    172172          if($this->config['allow_remote']) 
    173173            $t .= ' ' . $key . '="' . htmlspecialchars($value, ENT_QUOTES) . '"'; 
     
    175175            $this->extlinks = true; 
    176176            if ($this->config['blocked_src']) 
    177               $t .= ' src="' . htmlspecialchars($this->config['blocked_src'], ENT_QUOTES) . '"'; 
     177              $t .= ' ' . $key . '="' . htmlspecialchars($this->config['blocked_src'], ENT_QUOTES) . '"'; 
    178178          } 
    179179        } 
Note: See TracChangeset for help on using the changeset viewer.