Re: A Study In Scarlet - Exploiting Common Vulnerabilities in PHP Applications

From: Julian Hall (julesat_private)
Date: Fri Jul 27 2001 - 10:05:25 PDT

  • Next message: Juergen P. Meier: "Re: UDP packet handling weird behaviour of various operating systems"

    Sorry for the delay in responding here, but I've not had a chance to catch up
    with the list for a while, but:
    
    Shaun Clowes wrote:
    
    > As an alternate attack assisted by file upload consider the following
    > example PHP code:
    >
    >  <?php
    >   if (file_exists($theme)) // Checks the file exists on the local system (no
    > remote files)
    >    include("$theme");
    >  ?>
    
    Is anyone really that naive?  I, and I'm sure most other PHP uses, would
    automatically write:
    
    <?php
        $themefile = "themes/$theme.inc";
        include ($themefile);
    ?>
    
    If I was even remotely thinking about security I would check for the presence
    of directory seperator characters in $theme (as it stands obviously the code
    would allow the inclusion of any file with the '.inc' suffix).  You never
    include code from a filename specified directly by the user.  That's a primary
    rule, and applies to server applications written in any language, not just PHP
    and other similar systems.
    



    This archive was generated by hypermail 2b30 : Fri Jul 27 2001 - 10:20:08 PDT