]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
FTP: Ignore credentials with a NUL-prefixed username (#1557)
authorAndreas Weigel <andreas.weigel@securepoint.de>
Tue, 14 Nov 2023 15:17:09 +0000 (15:17 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Tue, 28 Nov 2023 01:03:38 +0000 (14:03 +1300)
    FATAL: FTP login parsing destroyed username info

This bug was discovered and detailed by Joshua Rogers at
https://megamansec.github.io/Squid-Security-Audit/ftp-fatal.html
where it was filed as "FTP Authentication Crash".

src/clients/FtpGateway.cc

index 0f0d0ddcc3d4b3c7022aed45bfaa549a6be1ab7e..1a51aa6307ce6bac8fe321495383e9ede5109dcf 100644 (file)
@@ -402,6 +402,12 @@ Ftp::Gateway::loginParser(const SBuf &login, bool escaped)
     if (login.isEmpty())
         return;
 
+    if (!login[0]) {
+        debugs(9, 2, "WARNING: Ignoring FTP credentials that start with a NUL character");
+        // TODO: Either support credentials with NUL characters (in any position) or ban all of them.
+        return;
+    }
+
     const SBuf::size_type colonPos = login.find(':');
 
     /* If there was a username part with at least one character use it.
@@ -1042,9 +1048,8 @@ Ftp::Gateway::checkAuth(const HttpHeader * req_hdr)
     /* Test URL login syntax. Overrides any headers received. */
     loginParser(request->url.userInfo(), true);
 
-    /* name is missing. that's fatal. */
-    if (!user[0])
-        fatal("FTP login parsing destroyed username info");
+    // XXX: We we keep default "anonymous" instead of properly supporting empty usernames.
+    Assure(user[0]);
 
     /* name + password == success */
     if (password[0])