Menu

OSS-PHP pagination - XSS Vulnerability

randome
2015-03-04
2015-03-16
  • randome

    randome - 2015-03-04

    Hey there,

    I found a XSS Vulnerability within the OSS-PHP Pagination Class ...
    oss_paging.class.php --> public function compute()

    $this->pageBaseURI = preg_replace('/&(?:' . $this->pageParameter . '|' . $this->rowsParameter . ')=[\d]+/', '', $_SERVER['REQUEST_URI'])
    . $this->paramSeparator . $this->rowsParameter . '=' . $this->resultRows . $this->paramSeparator . $this->pageParameter . '=';
    

    As you simply output $_SERVER['REQUEST_URI'] one can inject malicious JS Code ...

    /search.html?p=170"><script>prompt(955422)</script>&query=1&rows=15"><script>prompt(955422)</script>&blubb="><script>prompt(955422)</script>

    One can inject within known Parameters like p or rows - or even with dummy Parameters ...

    $this->pageBaseURI = str_replace("&&", "&", preg_replace('/(?:' . $this->pageParameter . '|' . $this->rowsParameter . ')=.*(?:\&|$)/U', '', $_SERVER['REQUEST_URI'])
    . $this->paramSeparator . $this->rowsParameter . '=' . (int)$this->resultRows . $this->paramSeparator . $this->pageParameter . '=');
    

    modified it a bit to be safe for the known parameters - but not sure how to protect the dummy Parameters ... guess the whole Function needs to be adapted to be safe ... (go though every GET Param and sanitize input)

    Anyone got a better idea?

    Bye from snowy Austria
    Andreas Schnederle-Wagner

     

    Last edit: randome 2015-03-04
  • Alexandre Toyer

    Alexandre Toyer - 2015-03-04

    Hello,

    Thank you for your warning. However I have some trouble understanding how this could result in an XSS vulnerability. Could you please exlain what a full workflow would be?

    Thank you,
    Alexandre

     
 

Log in to post a comment.