phpBMS

Changeset 728 for trunk

Show
Ignore:
Timestamp:
01/07/10 12:45:17 (2 years ago)
Author:
brieb
Message:
  • Fixed possible security loopholes in search screen (SQL Manipulation)
Location:
trunk/phpbms
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/phpbms/common/javascript/queryfunctions.js

    r707 r728  
    7777                } else 
    7878                    ctrlkeydown = theevent.metaKey; 
    79                      
     79 
    8080                shiftkeydown=theevent.shiftKey; 
    8181        } 
     
    610610} 
    611611 
    612 function LSRunSearch(){ 
    613         var sqlbox=getObjectFromID("LSSQL"); 
    614         var advancedsearch=getObjectFromID("advancedsearch"); 
    615         advancedsearch.value=sqlbox.value 
    616         advancedsearch.form.submit(); 
    617 } 
    618612function LSDeleteSearch(base){ 
    619613        var theselect=getObjectFromID("LSList"); 
  • trunk/phpbms/include/relationships.php

    r703 r728  
    102102        */ 
    103103        foreach($theids as $theid) 
    104             $_SESSION["passedjoinwhere"] .= " OR ".$therecord["fromtable"].".id = ".$theid; 
     104            $_SESSION["passedjoinwhere"] .= " OR ".$therecord["fromtable"].".id = ".((int) $theid); 
    105105 
    106106        $_SESSION["passedjoinwhere"] = substr($_SESSION["passedjoinwhere"], 3); 
  • trunk/phpbms/include/search_class.php

    r720 r728  
    8181                                        searchroleid, 
    8282                                        advsearchroleid, 
    83                                         viewsqlroleid 
     83                                        viewsqlroleid, 
     84                                        editroleid, 
     85                                        addroleid 
    8486                                FROM 
    85                                         tabledefs inner join modules on tabledefs.moduleid = modules.uuid 
     87                                        tabledefs INNER JOIN modules on tabledefs.moduleid = modules.uuid 
    8688                                WHERE 
    8789                                        tabledefs.uuid= '".$id."'"; 
  • trunk/phpbms/loadsearch.php

    r726 r728  
    249249                                    </p> 
    250250                                    <p> 
    251                                             <textarea id="LSSQL" rows="8" cols="10" <?php if(!hasRights($tableinfo["advsearchroleid"])) echo " readonly=\"readonly\""?>></textarea> 
     251                                            <textarea id="LSSQL" name="LSSQL" rows="8" cols="10" <?php if(!hasRights($tableinfo["advsearchroleid"])) echo ' readonly="readonly"'?>></textarea> 
    252252                                    </p> 
    253253                            </td> 
    254254                            <td valign="top"> 
    255                                     <p><br/><input id="LSLoad" type="button" onclick="LSRunSearch()" class="Buttons" disabled="disabled" value="run search"/></p> 
     255                                    <p><br/><input id="LSLoad" type="submit" name="command" class="Buttons" disabled="disabled" value="run search"/></p> 
    256256                                    <p><input id="LSDelete" type="button" onclick="LSDeleteSearch('<?php echo APP_PATH ?>')" class="Buttons" disabled="disabled" value="delete"/></p> 
    257257                                    <div id="LSResults">&nbsp;</div> 
     
    270270if(isset($_GET["cmd"])){ 
    271271 
     272    require_once("include/session.php"); 
     273 
    272274    $thesearch = new savedSearch($db); 
    273275 
  • trunk/phpbms/search.php

    r720 r728  
    4141 
    4242        if(!isset($_GET["id"])) 
    43                 $error = new appError(100,"Passed Parameter not present."); 
    44  
    45         $_GET["id"]= mysql_real_escape_string($_GET["id"]); 
     43            $error = new appError(100,"Passed Parameter not present."); 
     44 
     45        $_GET["id"] = mysql_real_escape_string($_GET["id"]); 
    4646 
    4747        $displayTable= new displaySearchTable($db); 
     
    109109                                $querystatement = " 
    110110                                        SELECT 
    111                                                 name 
     111                                                name, 
     112                                                roleid 
    112113                                        FROM 
    113114                                                tableoptions 
     
    169170                        // omit selected from current query 
    170171                        //===================================================================================================== 
    171                         $displayTable->recordoffset=0; 
    172                         $tempwhere=""; 
    173                         $theids=explode(",",$_POST["theids"]); 
    174                         foreach($theids as $theid){ 
    175                                 $tempwhere.=" or ".$displayTable->thetabledef["maintable"].".id=".$theid; 
    176                         } 
    177                         $tempwhere=substr($tempwhere,3); 
    178                         $displayTable->querywhereclause="(".$displayTable->querywhereclause.") and not (".$tempwhere.")"; 
     172                        $displayTable->recordoffset = 0; 
     173                        $tempwhere = ""; 
     174                        $theids = explode(",",$_POST["theids"]); 
     175 
     176                        foreach($theids as $theid) 
     177                            $tempwhere.=" OR ".$displayTable->thetabledef["maintable"].".id=".((int) $theid); 
     178 
     179                        $tempwhere = substr($tempwhere,3); 
     180 
     181                        $displayTable->querywhereclause="(".$displayTable->querywhereclause.") AND NOT (".$tempwhere.")"; 
    179182                        break; 
    180183 
     
    182185                        // keep only those ids 
    183186                        //===================================================================================================== 
    184                         $displayTable->recordoffset=0; 
    185                         $tempwhere=""; 
    186                         $theids=explode(",",$_POST["theids"]); 
    187                         foreach($theids as $theid){ 
    188                                 $tempwhere.=" or ".$displayTable->thetabledef["maintable"].".id=".$theid; 
    189                         } 
     187                        $displayTable->recordoffset = 0; 
     188                        $tempwhere = ""; 
     189                        $theids = explode(",",$_POST["theids"]); 
     190 
     191                        foreach($theids as $theid) 
     192                            $tempwhere.=" or ".$displayTable->thetabledef["maintable"].".id=".((int) $theid); 
     193 
    190194                        $tempwhere=substr($tempwhere,3); 
    191                         $displayTable->querywhereclause=$tempwhere; 
     195 
     196                        $displayTable->querywhereclause = $tempwhere; 
     197 
    192198                        break; 
    193199 
    194200                case "advanced search": 
     201 
     202                        if(!hasRights($displayTable->thetabledef["advsearchroleid"])) 
     203                            goURL(APP_PATH."noaccess.php"); 
     204 
    195205                        $displayTable->recordoffset=0; 
    196206                        $displayTable->querywhereclause=stripslashes($_POST["advancedsearch"]); 
    197207                        $displayTable->querytype="advanced search"; 
    198208                        break; 
     209 
     210                case "run search": 
     211                    /** 
     212                     * Run a loaded search 
     213                     */ 
     214 
     215                        if(!hasRights($displayTable->thetabledef["advsearchroleid"])){ 
     216                            /** 
     217                             * Need to load search from id, because the 
     218                             * person does not have rights to override loaded 
     219                             * searches 
     220                             */ 
     221 
     222                            $querystatement=" 
     223                                SELECT 
     224                                        sqlclause 
     225                                FROM 
     226                                        usersearches 
     227                                WHERE id=".((int) $_POST["LSList"]); 
     228 
     229                            $queryresult = $db->query($querystatement); 
     230 
     231                            $therecord = $db->fetchArray($queryresult); 
     232 
     233                            $_POST["LSSQL"] = $therecord["sqlclause"]; 
     234 
     235                        }//endif 
     236 
     237                        $displayTable->recordoffset=0; 
     238                        $displayTable->querywhereclause=stripslashes($_POST["LSSQL"]); 
     239                        $displayTable->querytype="advanced search"; 
     240                        break; 
     241                    break; 
    199242 
    200243                case "advanced sort": 
    201244                        $displayTable->showGroupings = 0; 
    202245                        $displayTable->recordoffset = 0; 
    203                         $displayTable->querysortorder=$_POST["advancedsort"]; 
     246                        $displayTable->querysortorder = $_POST["advancedsort"]; 
    204247                        break; 
    205248 
phpBMS vulnerability assesment provided by Orvant Inc. Copyright © 2010 Kreotek, LLC. All Rights reserved.