Changeset 4488 in subversion


Ignore:
Timestamp:
Feb 3, 2011 4:12:35 PM (2 years ago)
Author:
thomasb
Message:

Prevent from relaying arbitrary requests through modcss.inc (security issue)

Location:
trunk/roundcubemail/program/steps
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/roundcubemail/program/steps/mail/func.inc

    r4484 r4488  
    11951195function rcmail_alter_html_link($matches) 
    11961196{ 
    1197   global $EMAIL_ADDRESS_PATTERN; 
     1197  global $RCMAIL, $EMAIL_ADDRESS_PATTERN; 
    11981198 
    11991199  $tag = $matches[1]; 
     
    12021202 
    12031203  if ($tag == 'link' && preg_match('/^https?:\/\//i', $attrib['href'])) { 
    1204     $attrib['href'] = "?_task=utils&_action=modcss&u=" . urlencode($attrib['href']) 
    1205         . "&c=" . urlencode($GLOBALS['rcmail_html_container_id']); 
     1204    $tempurl = 'tmp-' . md5($attrib['href']) . '.css'; 
     1205    $_SESSION['modcssurls'][$tempurl] = $attrib['href']; 
     1206    $attrib['href'] = $RCMAIL->url(array('task' => 'utils', 'action' => 'modcss', 'u' => $tempurl, 'c' => $GLOBALS['rcmail_html_container_id'])); 
    12061207    $end = ' />'; 
    12071208  } 
  • trunk/roundcubemail/program/steps/utils/modcss.inc

    r4410 r4488  
    66 |                                                                       | 
    77 | This file is part of the Roundcube Webmail client                     | 
    8  | Copyright (C) 2007-2010, The Roundcube Dev Team                       | 
     8 | Copyright (C) 2007-2011, The Roundcube Dev Team                       | 
    99 | Licensed under the GNU GPL                                            | 
    1010 |                                                                       | 
     
    2222$source = ''; 
    2323 
    24 $url = preg_replace('![^a-z0-9:./\-_?$&=%]!i', '', $_GET['u']); 
    25 if ($url === null) { 
     24$url = preg_replace('![^a-z0-9.-]!i', '', $_GET['_u']); 
     25if ($url === null || !($realurl = $_SESSION['modcssurls'][$url])) { 
    2626    header('HTTP/1.1 403 Forbidden'); 
    27     echo $error; 
     27    echo "Unauthorized request"; 
    2828    exit; 
    2929} 
    3030 
    31 $a_uri = parse_url($url); 
     31$a_uri = parse_url($realurl); 
    3232$port  = $a_uri['port'] ? $a_uri['port'] : 80; 
    3333$host  = $a_uri['host']; 
     
    8686if (!empty($source) && in_array($mimetype, array('text/css','text/plain'))) { 
    8787    header('Content-Type: text/css'); 
    88     echo rcmail_mod_css_styles($source, preg_replace('/[^a-z0-9]/i', '', $_GET['c'])); 
     88    echo rcmail_mod_css_styles($source, preg_replace('/[^a-z0-9]/i', '', $_GET['_c'])); 
    8989    exit; 
    9090} 
Note: See TracChangeset for help on using the changeset viewer.