Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pX9YH-0000yd-8b for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Feb 2023 23:38:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pX9YG-0002u5-3h for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Feb 2023 23:38:32 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pX9YF-0002tv-Kb for pgsql-hackers@lists.postgresql.org; Tue, 28 Feb 2023 23:38:31 +0000 Received: from mail-pl1-x62f.google.com ([2607:f8b0:4864:20::62f]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pX9Y7-00063x-Ow for pgsql-hackers@postgresql.org; Tue, 28 Feb 2023 23:38:30 +0000 Received: by mail-pl1-x62f.google.com with SMTP id z2so12156803plf.12 for ; Tue, 28 Feb 2023 15:38:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=timescale.com; s=google; t=1677627502; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=6OvJsNjHnmz4RlMa9ljhv1eeJWF7XPztNWsT7/4Wb9w=; b=EiATKxPuQ88VbeNd+O1dweol86PaTsjZBogsWqgjURYQVJTGLJBM8WpqFz/OF/3TrU AVetSNQ8HO1JiQcOa+pPDY22NKVf6EvEEQImOOfRFmiUuSZEjPP3mgoEeBdew/K93XYa tiCgiilPPY/XW9qquerWf/jTKZGcZ1IqtUDlzP8MaGtKTNPXtBYH7NYpnDCkJNd3YHdH XLVeg1ViSKHZ5XAb1VE+P4ejCDhPEKQcwZux4ZlOgOqt8lQMB1yZ83ZFTkrVJKdrVMOv J4ldGe+GD2Lc2cjRoWVsHvQeUKqR0px3WkOG7/qH98PySvG5PkPLLsnp7QLoLwtaSdpU fO8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677627502; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6OvJsNjHnmz4RlMa9ljhv1eeJWF7XPztNWsT7/4Wb9w=; b=YQp8y3HEDyD+1OPFQ23/B2baorD9VjE5NuId+/rIEs3HDc83BwrervGxUpur/th0v4 MwzhyXbcbdJEHMVq1oG6l34aa9caZH7k02ejLL6A7m8Bum6YZlLVmfExatvYF0kchZnX NbJLDjS8OsPiIUpzbW04s3mcyP+sWmZ8eavPUzemZamI29D4BeEGmdRdoo5efR7wBEuP BC2usNfUG/lpGG4RXQdgXsFgjs4rAflEKgxQ+g1ncXAX3wTP2KHGlOxK31o5Ih1p8mj6 ekcDF4/jOnlybraHdwQkOXuBgsmWVPZFbV9jSmrz8udEkv1pd9iW9Nvhvjfs3il860LQ +png== X-Gm-Message-State: AO0yUKUIZ7ohYO/beP4PMrOcrK65/xBXhgcgq/twpdabzM3MdzsDVk+m IJQEoBHj8PmcyO16Tbv0c/6kXb17seYPf9E/HyQ= X-Google-Smtp-Source: AK7set+nwfwa5rsdaKazi3YGhU+4iTtlFXvZ3DMLLtemy/BTGEk1X2WoT0Z4LpOChJOSgppsWLSj/w== X-Received: by 2002:a17:90b:1801:b0:233:cea2:dac6 with SMTP id lw1-20020a17090b180100b00233cea2dac6mr4994863pjb.47.1677627501946; Tue, 28 Feb 2023 15:38:21 -0800 (PST) Received: from [192.168.1.21] ([50.53.8.205]) by smtp.gmail.com with ESMTPSA id q2-20020a17090a68c200b00234b785af1dsm6690824pjj.26.2023.02.28.15.38.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Feb 2023 15:38:21 -0800 (PST) Message-ID: Date: Tue, 28 Feb 2023 15:38:21 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PoC] Let libpq reject unexpected authentication requests Content-Language: en-US From: Jacob Champion To: "pgsql-hackers@postgresql.org" Cc: Aleksander Alekseev , Michael Paquier , Peter Eisentraut , "David G. Johnston" References: <949f1c20-771c-aef7-058f-2c10885db955@enterprisedb.com> <8e2e5fb6-8225-de8a-b0f9-178c27402367@enterprisedb.com> <9de74f8d-fbf4-63d9-7bcb-b9c27edf8b73@enterprisedb.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2/16/23 10:57, Jacob Champion wrote: > v14 rebases over the test and solution conflicts from 9244c11afe2. Since we're to the final CF for PG16, here's a rough summary. This patchset provides two related features: 1) the ability for a client to explicitly allow or deny particular methods of in-band authentication (that is, things like password exchange), and 2) the ability to withhold a client certificate from a server that asks for it. Feature 1 was originally proposed to mitigate abuse where a successful MITM attack can then be used to fish for client credentials [1]. It also lets users disable undesirable authentication types (like plaintext) by default, which seems to be a common interest. Both features came up again in the context of proxies such as postgres_fdw, where it's sometimes important that users authenticate using only their credentials and not piggyback on the authority of the proxy host [2]. And another use case for feature 2 just came up independently [3], to fix connections where the default client certificate isn't valid for a particular server. Since this is all client-side, it's compatible with existing servers. Also since it's client-side, it can't prevent connections from being established by an eager server; it can only drop the connection once it sees that its requirement was not met, similar to how we handle target_session_attrs. That means it can't prevent a login trigger from being processed on behalf of a confused proxy. (I think that would require server-side support.) 0001 and 0002 are the core features. 0003 is a more future-looking refactoring of the internals, to make it easier to handle more SASL mechanisms, but it's not required and contains some unexercised code. Thanks, --Jacob [1] https://www.postgresql.org/message-id/fcc3ebeb7f05775b63f3207ed52a54ea5d17fb42.camel%40vmware.com [2] https://www.postgresql.org/message-id/20230123015255.h3jro3yyitlsqykp%40awork3.anarazel.de [3] https://www.postgresql.org/message-id/CAAWbhmh_QqCnRVV8ct3gJULReQjWxLTaTBqs%2BfV7c7FpH0zbew%40mail.gmail.com