From 6c2008cb349e58b94bd39bd9a63c485b179fac01 Mon Sep 17 00:00:00 2001 From: Francesco Chemolli <5175948+kinkie@users.noreply.github.com> Date: Mon, 7 Oct 2024 08:13:17 +0000 Subject: [PATCH] Fix validation of Digest auth header parameters (#1906) Insufficient validation of Digest authentication parameters resulted in a DigestCalcHA1() call that dereferenced a nil pointer. This bug was discovered and detailed by Joshua Rogers at https://megamansec.github.io/Squid-Security-Audit/ where it was filed as "strlen(NULL) Crash Using Digest Authentication". --- src/auth/digest/Config.cc | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/auth/digest/Config.cc b/src/auth/digest/Config.cc index e00e15099b8..a4125210861 100644 --- a/src/auth/digest/Config.cc +++ b/src/auth/digest/Config.cc @@ -967,13 +967,19 @@ Auth::Digest::Config::decode(char const *proxy_auth, const HttpRequest *request, return rv; } } else { - /* cnonce and nc both require qop */ - if (digest_request->cnonce || digest_request->nc[0] != '\0') { - debugs(29, 2, "missing qop!"); - rv = authDigestLogUsername(username, digest_request, aRequestRealm); - safe_free(username); - return rv; - } + /* RFC7616 section 3.3, qop: + * "MUST be used by all implementations" + * + * RFC7616 section 3.4, qop: + * "value MUST be one of the alternatives the server + * indicated it supports in the WWW-Authenticate header field" + * + * Squid sends qop=auth, reject buggy or outdated clients. + */ + debugs(29, 2, "missing qop!"); + rv = authDigestLogUsername(username, digest_request, aRequestRealm); + safe_free(username); + return rv; } /** below nonce state dependent **/