kristapsdz / kcgi

minimal CGI and FastCGI library for C/C++
https://kristaps.bsd.lv/kcgi
ISC License
275 stars 40 forks source link

Fix HTTP Digest authentication with qpop=auth-int #26

Closed cac04 closed 6 years ago

cac04 commented 6 years ago

There are a couple of problems with kcgi's auth-int implementation:

First, it does not hash the body before including it in A2.

RFC 2617 defines A2 like this:

If the "qop" value is "auth-int", then A2 is:

  A2       = Method ":" digest-uri-value ":" H(entity-body)

But child.c included entity-body directly in the calculation of H(A2) without hashing it first.

Second, child.c used SCRIPT_NAME + PATH_INFO as digest-uri-value.

That's wrong: it has to be the value of the uri auth param to ensure that it is the same string that the client used. See section 3.2.2.5 of RFC 2617.

This commit also contains a regression test for qpop=auth-int