Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rhxyP-00EL4g-Du for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Mar 2024 20:34:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rhxyN-00E5Yo-Rb for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Mar 2024 20:34:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rhxyN-00E5Yf-I8 for pgsql-hackers@lists.postgresql.org; Wed, 06 Mar 2024 20:34:44 +0000 Received: from mail-lj1-x234.google.com ([2a00:1450:4864:20::234]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rhxyK-0038yj-Gs for pgsql-hackers@lists.postgresql.org; Wed, 06 Mar 2024 20:34:42 +0000 Received: by mail-lj1-x234.google.com with SMTP id 38308e7fff4ca-2d28387db09so1214141fa.0 for ; Wed, 06 Mar 2024 12:34:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1709757279; x=1710362079; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=F1HBVt84W4aZald2Ff2a2quNT773Q8UTLWykxwpfgy0=; b=ZQYkB9CGFyjKEhb4PTdS7BNcjmgVgBDatSKziigPdkXisoZlBri+EdAXdHs+fz27pP tHl8wEICx9NFJLEDk7HYw2GyDKCsNJVaL/RqLLOnI/i4g/4Trqjm9dCId/IbnKhQ5kri /PX1dSK3p7PO3NRAvphXOmTmyes4PgyzoLt/HhTbifry7qkCB5khy6EB9mRDr6rw2J3h 7xmGYVwXKHhUjLAmIjK9vUEtYqVPvVD5W8h63L/xDptrgbcixgv91frmSzuejzXksCLt 9yyPs3ZqcKS75+bfrX3E2h+Qikdd0uBIObJ8fRMBDBwv9CnUgXkDNHsjsT+DMEF0Y0WQ rpkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709757279; x=1710362079; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=F1HBVt84W4aZald2Ff2a2quNT773Q8UTLWykxwpfgy0=; b=RK8d/sIZAEY/pY/n8uU70h52Wp75nI84ouEh3H9GwY8i4TF9w2AXDiWB6OzOgD3EYX LOftpRx9ZbwRE2rsEIvJPE8zdSU2xP0DsSs41r1nHjpzlRcdpvMcTbMlRa8kWwJAwvQa WMdubaJ5Lp+N9fojts1VZq0WcWEdu8MCl749ISO7sODMiBbWXdkO0Pwb96MB4mJOXIYC XsvUZMMMrCfiYS8P72NaWTWveIbF14Gj30z3cgQym1tfDel1+9x4inw/FOKbBxXzv/gy KQ1rmBrNrldQVWqc0BVewJvTWZ57T9u8lAyWcAZ1UbV1rLHc35vJ/paEpD5OzbzNW7j/ i6Hg== X-Forwarded-Encrypted: i=1; AJvYcCWKcTPfOo2Yfw9cMLuCJkptgsewx64A59aEikeLCM8aYgp/w/zY1bMZrdHo01V7W/05eOn1GEfTwS5cG943YLd+DP8yh3A3OVig+Uxa18AQ7vbO X-Gm-Message-State: AOJu0Yxozx2GFADfK9ZCJ58gEegL2u0Zob37xhetmfr73rMvt+tvP796 sHVPbEfzqF6B5Rs7jq+FE8wgJkGGqZVrjKa8grFIKrno1f4KxYsw+N2HvZ7I5g== X-Google-Smtp-Source: AGHT+IGS19lVJMiMaO/VwZYBc+TW3kLO5Sc0SXGOWJFcJ5ZxgIIVexVcwk1pOX5+oVJYheXawNIC9Q== X-Received: by 2002:a05:6512:281a:b0:513:24b8:a7b1 with SMTP id cf26-20020a056512281a00b0051324b8a7b1mr152761lfb.47.1709757278960; Wed, 06 Mar 2024 12:34:38 -0800 (PST) Received: from [10.137.0.18] (ip-86-49-225-124.bb.vodafone.cz. [86.49.225.124]) by smtp.gmail.com with ESMTPSA id u2-20020a1709060b0200b00a45200fe2b5sm4333434ejg.224.2024.03.06.12.34.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Mar 2024 12:34:38 -0800 (PST) Message-ID: Date: Wed, 6 Mar 2024 21:34:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Exponential backoff for auth_delay To: Jacob Champion , Nathan Bossart Cc: Michael Banck , Abhijit Menon-Sen , pgsql-hackers@lists.postgresql.org, =?UTF-8?B?5oiQ5LmL54SV?= References: <658c4eab.050a0220.731ff.011e@mx.google.com> <65965e9d.050a0220.919a6.f9e1@mx.google.com> <65aa8265.170a0220.1ecef.91df@mx.google.com> <65aa8439.050a0220.31e77.0071@mx.google.com> <65e62440.170a0220.f6a7c.6f7f@mx.google.com> <20240305215044.GA3538518@nathanxps13> <20240306161045.GA3542434@nathanxps13> Content-Language: en-US From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/6/24 19:24, Jacob Champion wrote: > On Wed, Mar 6, 2024 at 8:10 AM Nathan Bossart wrote: >> Assuming you are referring to the case where we run out of free slots in >> acr_array, I'm not sure I see that as desirable behavior. Once you run out >> of slots, all failed authentication attempts are now subject to the maximum >> delay, which is arguably a denial-of-service scenario, albeit not a >> particularly worrisome one. > > Maybe I've misunderstood the attack vector, but I thought the point of > the feature was to deny service when the server is under attack. If we > don't deny service, what does the feature do? > > And I may have introduced a red herring in talking about the number of > hosts, because an attacker operating from a single host is under no > obligation to actually wait for the authentication delay. Once we hit > some short timeout, we can safely assume the password is wrong, > abandon the request, and open up a new connection. It seems like the > thing limiting our attack is the number of connection slots, not > MAX_CONN_RECORDS. Am I missing something crucial? > Doesn't this mean this approach (as implemented) doesn't actually work as a protection against this sort of DoS? If I'm an attacker, and I can just keep opening new connections for each auth request, am I even subject to any auth delay? ISTM the problem lies in the fact that we apply the delay only *after* the failed auth attempt. Which makes sense, because until now we didn't have any state with information for new connections. But with the new acr_array, we could check that first, and do the delay before trying to athenticate, no? regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company