Changeset 1990

Show
Ignore:
Timestamp:
09/06/2007 09:41:29 PM (12 months ago)
Author:
jan
Message:

merged [1875] from 1.4.x

  • fixed mem-leak in mod_auth (reported by Stefan Esser)
  • fixed crash with md5-sess and cnonce not set in mod_auth (reported
  • by Stefan Esser)
  • fixed missing check for base64 encoded string in mod_auth and Basic
  • auth (reported by Stefan Esser)
  • fixed possible crash in Auth-Digest header parser on trailing WS in mod_auth (reported by Stefan Esser)
Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/NEWS

    r1986 r1990  
    2323  * fixed prctl() usage (#1310, #1333) 
    2424  * fixed FastCGI header overrun in mod_fastcgi (reported by mattias@secweb.se) 
     25  * fixed mem-leak in mod_auth (reported by Stefan Esser) 
     26  * fixed crash with md5-sess and cnonce not set in mod_auth (reported by Stefan Esser) 
     27  * fixed missing check for base64 encoded string in mod_auth and Basic auth 
     28    (reported by Stefan Esser) 
     29  * fixed possible crash in Auth-Digest header parser on trailing WS in  
     30    mod_auth (reported by Stefan Esser)  
    2531 
    2632- 1.4.14 - ??? 
  • trunk/src/http_auth.c

    r1952 r1990  
    833833        password = buffer_init(); 
    834834 
    835         base64_decode(username, realm_str); 
     835        if (!base64_decode(username, realm_str)) { 
     836                log_error_write(srv, __FILE__, __LINE__, "sb", "decodeing base64-string failed", username); 
     837 
     838                buffer_free(username); 
     839                return 0; 
     840        } 
    836841 
    837842        /* r2 == user:password */ 
    838843        if (NULL == (pw = strchr(username->ptr, ':'))) { 
     844                log_error_write(srv, __FILE__, __LINE__, "sb", ": is missing in", username); 
     845 
    839846                buffer_free(username); 
    840  
    841                 log_error_write(srv, __FILE__, __LINE__, "sb", ": is missing in", username); 
    842  
    843847                return 0; 
    844848        } 
     
    969973                /* skip whitespaces */ 
    970974                while (*c == ' ' || *c == '\t') c++; 
    971                 if (!c) break; 
     975                if (!*c) break; 
    972976 
    973977                for (i = 0; dkv[i].key; i++) { 
     
    10181022                log_error_write(srv, __FILE__, __LINE__, "s", 
    10191023                                "digest: missing field"); 
     1024 
     1025                buffer_free(b); 
     1026                return -1; 
     1027        } 
     1028 
     1029        /** 
     1030         * protect the md5-sess against missing cnonce and nonce 
     1031         */ 
     1032        if (algorithm && 
     1033            0 == strcasecmp(algorithm, "md5-sess") && 
     1034            (!nonce || !cnonce)) { 
     1035                log_error_write(srv, __FILE__, __LINE__, "s", 
     1036                                "digest: (md5-sess: missing field"); 
     1037 
     1038                buffer_free(b); 
    10201039                return -1; 
    10211040        } 
  • trunk/tests/mod-auth.t

    r1349 r1990  
    99use strict; 
    1010use IO::Socket; 
    11 use Test::More tests => 10; 
     11use Test::More tests => 13; 
    1212use LightyTest; 
    1313 
     
    9494ok($tf->handle_http($t) == 0, 'Digest-Auth: missing nc (noncecount instead), no crash'); 
    9595 
     96$t->{REQUEST}  = ( <<EOF 
     97GET /server-status HTTP/1.0 
     98Authorization: Basic = 
     99EOF 
     100 ); 
     101$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 401 } ]; 
     102ok($tf->handle_http($t) == 0, 'Basic-Auth: Invalid Base64'); 
     103 
     104 
     105$t->{REQUEST}  = ( <<EOF 
     106GET /server-status HTTP/1.0 
     107User-Agent: Wget/1.9.1 
     108Authorization: Digest username="jan", realm="jan", 
     109        nonce="b1d12348b4620437c43dd61c50ae4639", algorithm="md5-sess", 
     110        uri="/MJ-BONG.xm.mpc", qop=auth, noncecount=00000001", 
     111        cnonce="036FCA5B86F7E7C4965C7F9B8FE714B7", 
     112        nc="asd", 
     113        response="29B32C2953C763C6D033C8A49983B87E" 
     114EOF 
     115 ); 
     116$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 401 } ]; 
     117ok($tf->handle_http($t) == 0, 'Digest-Auth: md5-sess + missing cnonce'); 
     118 
     119$t->{REQUEST}  = ( <<EOF 
     120GET /server-status HTTP/1.0 
     121User-Agent: Wget/1.9.1 
     122Authorization: Digest username="jan", realm="jan", 
     123        nonce="b1d12348b4620437c43dd61c50ae4639", algorithm="md5-sess", 
     124        uri="/MJ-BONG.xm.mpc", qop=auth, noncecount=00000001", 
     125        cnonce="036FCA5B86F7E7C4965C7F9B8FE714B7", 
     126        nc="asd", 
     127        response="29B32C2953C763C6D033C8A49983B87E"      
     128EOF 
     129 ); 
     130$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 401 } ]; 
     131ok($tf->handle_http($t) == 0, 'Digest-Auth: trailing WS'); 
     132 
    96133 
    97134