From: Andreas Weigel Date: Tue, 14 Nov 2023 15:17:09 +0000 (+0000) Subject: FTP: Ignore credentials with a NUL-prefixed username (#1557) X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=7bac3e467e91fa84c39c11b590394e83b27c9919;p=thirdparty%2Fsquid.git FTP: Ignore credentials with a NUL-prefixed username (#1557) 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". --- diff --git a/src/clients/FtpGateway.cc b/src/clients/FtpGateway.cc index 783006a715..c072a3c1b4 100644 --- a/src/clients/FtpGateway.cc +++ b/src/clients/FtpGateway.cc @@ -404,6 +404,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. thats fatal. */ - if (!user[0]) - fatal("FTP login parsing destroyed username info"); + // XXX: We we keep default "anonymous" instead of properly supporting empty usernames. + Must(user[0]); /* name + password == success */ if (password[0])