Development

Changeset 8922

You must first sign up to be able to contribute.

Changeset 8922

Show
Ignore:
Timestamp:
05/13/08 10:20:09 (1 year ago)
Author:
fabien
Message:

fixed yml validator file can be overriden by a remote attacker (closes #1617 - based on a patch from Carl.Vondrick)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0/lib/filter/sfExecutionFilter.class.php

    r7791 r8922  
    7272        $validated = true; 
    7373 
     74        // the case of the first letter of the action is insignificant 
    7475        // get the current action validation configuration 
    75         $validationConfig = $moduleName.'/'.sfConfig::get('sf_app_module_validate_dir_name').'/'.$actionName.'.yml'; 
     76        $validationConfigWithFirstLetterLower = $moduleName.'/'.sfConfig::get('sf_app_module_validate_dir_name').'/'.strtolower(substr($actionName, 0, 1)).substr($actionName, 1).'.yml'; 
     77        $validationConfigWithFirstLetterUpper = $moduleName.'/'.sfConfig::get('sf_app_module_validate_dir_name').'/'.ucfirst($actionName).'.yml'; 
     78 
     79        // determine $validateFile by testing both the uppercase and lowercase 
     80        // types of validation configurations. 
     81        $validateFile = null; 
     82        if (!is_null($testValidateFile = sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$validationConfigWithFirstLetterLower, true))) 
     83        { 
     84          $validateFile = $testValidateFile; 
     85        } 
     86        else if (!is_null($testValidateFile = sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$validationConfigWithFirstLetterUpper, true))) 
     87        { 
     88          $validateFile = $testValidateFile; 
     89        } 
    7690 
    7791        // load validation configuration 
    7892        // do NOT use require_once 
    79         if (null !== $validateFile = sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name').'/'.$validationConfig, true)) 
     93        if (!is_null($validateFile)) 
    8094        { 
    8195          // create validator manager 
  • branches/1.0/test/functional/fixtures/project/apps/frontend/modules/validation/actions/actions.class.php

    r3168 r8922  
    1313  public function executeIndex() 
    1414  { 
     15    if (sfWebRequest::POST == $this->getRequest()->getMethod()) 
     16    { 
     17      $this->getResponse()->setHttpHeader('X-Validated', 'ok'); 
     18    } 
    1519  } 
    1620 
    1721  public function handleErrorIndex() 
    1822  { 
     23    $this->getResponse()->setHttpHeader('X-Validated', 'ko'); 
     24 
     25    return sfView::SUCCESS; 
     26  } 
     27 
     28  public function executeIndex2() 
     29  { 
     30    if (sfWebRequest::POST == $this->getRequest()->getMethod()) 
     31    { 
     32      $this->getResponse()->setHttpHeader('X-Validated', 'ok'); 
     33    } 
     34  } 
     35 
     36  public function handleErrorIndex2() 
     37  { 
     38    $this->getResponse()->setHttpHeader('X-Validated', 'ko'); 
     39 
    1940    return sfView::SUCCESS; 
    2041  } 
  • branches/1.0/test/functional/validationTest.php

    r3168 r8922  
    138138  checkResponseElement('body ul[class="errors"] li[class="input4"]', 'Required') 
    139139; 
     140 
     141// check that /validation/index and /validation/Index both uses the index.yml validation file (see #1617) 
     142// those tests are only relevant on machines where filesystems are case sensitive. 
     143$b-> 
     144  post('/validation/index')-> 
     145  isStatusCode(200)-> 
     146  isRequestParameter('module', 'validation')-> 
     147  isRequestParameter('action', 'index')-> 
     148  isResponseHeader('X-Validated', 'ko') 
     149; 
     150 
     151$b-> 
     152  post('/validation/Index')-> 
     153  isStatusCode(200)-> 
     154  isRequestParameter('module', 'validation')-> 
     155  isRequestParameter('action', 'Index')-> 
     156  isResponseHeader('X-Validated', 'ko') 
     157; 
     158 
     159$b-> 
     160  post('/validation/INdex')-> 
     161  isStatusCode(404) 
     162; 
     163 
     164$b-> 
     165  post('/validation/index2')-> 
     166  isStatusCode(200)-> 
     167  isRequestParameter('module', 'validation')-> 
     168  isRequestParameter('action', 'index2')-> 
     169  isResponseHeader('X-Validated', 'ko') 
     170; 
     171 
     172$b-> 
     173  post('/validation/Index2')-> 
     174  isStatusCode(200)-> 
     175  isRequestParameter('module', 'validation')-> 
     176  isRequestParameter('action', 'Index2')-> 
     177  isResponseHeader('X-Validated', 'ko') 
     178; 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.