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 1rhtr6-00Dwmd-62 for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Mar 2024 16:10:56 +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 1rhtr4-00BdfL-KQ for pgsql-hackers@arkaria.postgresql.org; Wed, 06 Mar 2024 16:10:55 +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 1rhtr4-00BdfA-Av for pgsql-hackers@lists.postgresql.org; Wed, 06 Mar 2024 16:10:54 +0000 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rhtr1-0036or-CD for pgsql-hackers@lists.postgresql.org; Wed, 06 Mar 2024 16:10:53 +0000 Received: by mail-io1-xd29.google.com with SMTP id ca18e2360f4ac-7c874fb2b1fso42062539f.0 for ; Wed, 06 Mar 2024 08:10:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709741449; x=1710346249; darn=lists.postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=SW4KnyaG/Ff8hXjJYwu6TZgJ8gNSOGC38RWqsVskPUM=; b=RyYXdDFe6puPEbJTbFeX+goW2P3pWjqxKODRjk/ucjtqtEROpIdxcp+sa+t7JXDozg o5il02O3VsB8cU9QLOnK2JVNIVN6h6KzAa1qzqQUPvbn5h3arv9Ii36qEgqLQb9Pl2l0 ml3MN3XRfluccGoS90DKnShAMWQ8/YwkdbXf6VyvILY4rh6qJ3ElQp9qBNSo8fL+Gokk 4+vXUJ0YPFte3AkIM3OO3J3GAzCLu1EYyehdfpwm+hweduKCDPLp+J8yksXeOWncItXr 5p2L8s2cCKezC8QDyRn+vZyV8QYAnSDEVC0PhEHDnw8qZkQ3qFCo9XIZDY2q8P3GcrAw wcRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709741449; x=1710346249; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SW4KnyaG/Ff8hXjJYwu6TZgJ8gNSOGC38RWqsVskPUM=; b=JSm7iF1vAbxgY5cenV4bXrpIYoy1BJXzJn1Ys1rydqkTj9wYK0GOiF44JEG+3awq+O cRvxtweJicVWgQF1VSKuVkeuBtlmatYteki6yz/7WUdnu37/gD4/OKnlRCCkdiKeAx/7 24Gh6NjXh6g0lynbemRvRQoqqQCHcoqW8TErYJVzxpWltId6mlpKSayFwtOAyrkaawh7 m686EyJMSDY8KuOsA8glH3RSTH+h6v4JKfvIj3g9sZvEQOlUJXsWfL/EGsH2s7Q6gdS/ n5k1DkE66SHbmDesRwaeubJ3H6QYXKBrG1/a9GMvbC6XmCTWKV84PLLZJ8YoaOmLn1ge 4CjA== X-Forwarded-Encrypted: i=1; AJvYcCU0wX5v4GrOGEEf4VaPzEGF6IlP6Yo+05jbOuuh4piZwg1otntQhfKqOH6pjMTHRjdyw3kJIKDQhkpbtB7PgJT7mwi4pldXXg73Uutj0KZLvW/b X-Gm-Message-State: AOJu0YwJfoNuqx/+nbqlmVZT26+wLdfvrMvkpdPdPNlFrZOpHq+D3Y5N 6/KCyEDxXY8gKrQOwdR564BJ35AWL5Hkq1JZBevmR3ccMCVfdYzN X-Google-Smtp-Source: AGHT+IECga9D9S52U9x8EA5n28i7Vi99J1EnD5f6w9Qku/tGrCt/C9Ixe/WYx1AWfrtzLpDr+MMOmA== X-Received: by 2002:a05:6602:2986:b0:7c8:7476:1bf5 with SMTP id o6-20020a056602298600b007c874761bf5mr2851409ior.9.1709741449353; Wed, 06 Mar 2024 08:10:49 -0800 (PST) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id q19-20020a02c8d3000000b0047679fe3a05sm453555jao.88.2024.03.06.08.10.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 08:10:49 -0800 (PST) Date: Wed, 6 Mar 2024 10:10:45 -0600 From: Nathan Bossart To: Jacob Champion Cc: Michael Banck , Tomas Vondra , Abhijit Menon-Sen , pgsql-hackers@lists.postgresql.org, =?utf-8?B?5oiQ5LmL54SV?= Subject: Re: [PATCH] Exponential backoff for auth_delay Message-ID: <20240306161045.GA3542434@nathanxps13> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Mar 05, 2024 at 05:14:46PM -0800, Jacob Champion wrote: > On Tue, Mar 5, 2024 at 1:51 PM Nathan Bossart wrote: >> I don't have a strong opinion about making this configurable, but I do >> think we should consider making this a hash table so that we can set >> MAX_CONN_RECORDS much higher. > > I'm curious why? It seems like the higher you make MAX_CONN_RECORDS, > the easier it is to put off the brute-force protection. (My assumption > is that anyone mounting a serious attack is not going to be doing this > from their own computer; they'll be doing it from many devices they > don't own -- a botnet, or a series of proxies, or something.) 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. I also think the linear search approach artifically constrains the value of MAX_CONN_RECORDS, so even if a user wanted to bump it up substantially for their own build, they'd potentially begin noticing the effects of the O(n) behavior. AFAICT this is really the only reason this value is set so low at the moment, as I don't think the memory usage or code complexity of a hash table with thousands of slots would be too bad. In fact, it might even be simpler to use hash_search() instead of hard-coding linear searches in multiple places. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com