]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix validation of Digest auth header parameters (#1906)
authorFrancesco Chemolli <5175948+kinkie@users.noreply.github.com>
Mon, 7 Oct 2024 08:13:17 +0000 (08:13 +0000)
committerFrancesco Chemolli <5175948+kinkie@users.noreply.github.com>
Wed, 9 Oct 2024 10:26:18 +0000 (11:26 +0100)
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

index f39d43cba758f128a4cb3f5cb95a4868b441324b..0fd32330cff434d8116dc1e5f001bbe701f83481 100644 (file)
@@ -966,13 +966,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 **/