I recently uploaded Phil Stroujon's REST server for CodeIgniter. I looked at the source code, and when I came to Digest authentication, I saw the following code:
if ($this->input->server('PHP_AUTH_DIGEST')) { $digest_string = $this->input->server('PHP_AUTH_DIGEST'); } elseif ($this->input->server('HTTP_AUTHORIZATION')) { $digest_string = $this->input->server('HTTP_AUTHORIZATION'); } else { $digest_string = ""; }
And a little later, after some checks for the absence of $ digest_string and the presence of a username:
// This is the valid response expected $A1 = md5($digest['username'].':'.$this->config->item('rest_realm').':'.$valid_pass); $A2 = md5(strtoupper($this->request->method).':'.$digest['uri']); $valid_response = md5($A1.':'.$digest['nonce'].':'.$digest['nc'].':'.$digest['cnonce'].':'.$digest['qop'].':'.$A2); if ($digest['response'] != $valid_response) { header('HTTP/1.0 401 Unauthorized'); header('HTTP/1.1 401 Unauthorized'); exit; }
On Wikipedia, I see the following text about HTTP Digest Auth:
For subsequent requests, the hexadecimal request counter (nc) must be greater than the last used value, otherwise the attacker can simply โplayโ the old request with the same credentials. It depends on the server to ensure that the counter is incremented for each of the nonce values โโthat it issued, accordingly rejecting any bad requests.
The server must remember the nonce values โโthat it recently created. It can also remember when each nonce value was released, expiring them after a certain time. If an expired value is used, the server should respond with the status code "401" and add stale = TRUE in the authentication header, indicating that the client should resend with the new one provided without use, without asking the user for a different username and password.
However, I see nothing about checking cnonce, nc, or nonce in the source code. Does this mean that someone who registered a request from the client to the server that transmitted the authentication can simply โreplayโ it in the future and get a new resource value?
Is it really vulgar? Or didnโt I understand something?