Changeset 1773 in subversion
- Timestamp:
- Sep 12, 2008 11:14:34 AM (5 years ago)
- Location:
- trunk/roundcubemail/program
- Files:
-
- 2 edited
-
include/main.inc (modified) (2 diffs)
-
steps/mail/func.inc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/roundcubemail/program/include/main.inc
r1763 r1773 598 598 599 599 // ignore the whole block if evil styles are detected 600 if (stristr($source, 'expression') || stristr($source, 'behavior')) 600 $stripped = preg_replace('/[^a-z\(:]/', '', rcmail_xss_entitiy_decode($source)); 601 if (preg_match('/expression|behavior|url\(|import/', $stripped)) 601 602 return ''; 602 603 … … 631 632 return $styles; 632 633 } 634 635 636 /** 637 * Decode escaped entities used by known XSS exploits. 638 * See http://downloads.securityfocus.com/vulnerabilities/exploits/26800.eml for examples 639 * 640 * @param string CSS content to decode 641 * @return string Decoded string 642 */ 643 function rcmail_xss_entitiy_decode($content) 644 { 645 $out = html_entity_decode(html_entity_decode($content)); 646 $out = preg_replace('/\\\00([a-z0-9]{2})/ie', "chr(hexdec('\\1'))", $out); 647 $out = preg_replace('#/\*.+\*/#Um', '', $out); 648 return $out; 649 } 633 650 634 651 -
trunk/roundcubemail/program/steps/mail/func.inc
r1766 r1773 603 603 } 604 604 605 / * CSS styles need to be sanitized!605 // allow CSS styles, will be sanitized by rcmail_washtml_callback() 606 606 if ($p['safe']) { 607 607 $wash_opts['html_elements'][] = 'style'; 608 $wash_opts['html_attribs'] = array('type'); 609 } 610 */ 608 } 611 609 612 610 $washer = new washtml($wash_opts); 613 611 $washer->add_callback('form', 'rcmail_washtml_callback'); 612 $washer->add_callback('style', 'rcmail_washtml_callback'); 614 613 $body = $washer->wash($html); 615 614 $REMOTE_OBJECTS = $washer->extlinks; … … 699 698 break; 700 699 700 case 'style': 701 // decode all escaped entities and reduce to ascii strings 702 $stripped = preg_replace('/[^a-zA-Z\(:]/', '', rcmail_xss_entitiy_decode($source)); 703 704 // now check for evli strings like expression, behavior or url() 705 if (!preg_match('/expression|behavior|url\(|import/', $css)) { 706 $out = html::tag('style', array('type' => 'text/css'), $content); 707 break; 708 } 709 701 710 default: 702 711 $out = '';
Note: See TracChangeset
for help on using the changeset viewer.
