Mailing List Archive

svn commit: r1885659 - in /httpd/httpd/trunk: changes-entries/auth_digest_nonce.txt modules/aaa/mod_auth_digest.c
Author: ylavic
Date: Mon Jan 18 17:01:53 2021
New Revision: 1885659

URL: http://svn.apache.org/viewvc?rev=1885659&view=rev
Log:
mod_auth_digest: Fast validation of the nonce's base64 to fail early if
the format can't match anyway.


Added:
httpd/httpd/trunk/changes-entries/auth_digest_nonce.txt
Modified:
httpd/httpd/trunk/modules/aaa/mod_auth_digest.c

Added: httpd/httpd/trunk/changes-entries/auth_digest_nonce.txt
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/changes-entries/auth_digest_nonce.txt?rev=1885659&view=auto
==============================================================================
--- httpd/httpd/trunk/changes-entries/auth_digest_nonce.txt (added)
+++ httpd/httpd/trunk/changes-entries/auth_digest_nonce.txt Mon Jan 18 17:01:53 2021
@@ -0,0 +1,3 @@
+ *) mod_auth_digest: Fast validation of the nonce's base64 to fail early if
+ the format can't match anyway. [Yann Ylavic]
+

Modified: httpd/httpd/trunk/modules/aaa/mod_auth_digest.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/aaa/mod_auth_digest.c?rev=1885659&r1=1885658&r2=1885659&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/aaa/mod_auth_digest.c (original)
+++ httpd/httpd/trunk/modules/aaa/mod_auth_digest.c Mon Jan 18 17:01:53 2021
@@ -1427,9 +1427,14 @@ static int check_nonce(request_rec *r, d
time_rec nonce_time;
char tmp, hash[NONCE_HASH_LEN+1];

- if (strlen(resp->nonce) != NONCE_LEN) {
+ /* Since the time part of the nonce is a base64 encoding of an
+ * apr_time_t (8 bytes), it should end with a '=', fail early otherwise.
+ */
+ if (strlen(resp->nonce) != NONCE_LEN
+ || resp->nonce[NONCE_TIME_LEN - 1] != '=') {
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(01775)
- "invalid nonce %s received - length is not %d",
+ "invalid nonce '%s' received - length is not %d "
+ "or time encoding is incorrect",
resp->nonce, NONCE_LEN);
note_digest_auth_failure(r, conf, resp, 1);
return HTTP_UNAUTHORIZED;