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 1l0YDz-0007VY-Jz for pgsql-interfaces@arkaria.postgresql.org; Fri, 15 Jan 2021 23:09:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l0YDy-0000qt-HO for pgsql-interfaces@arkaria.postgresql.org; Fri, 15 Jan 2021 23:09:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l0TLP-00030u-4U for pgsql-interfaces@lists.postgresql.org; Fri, 15 Jan 2021 17:57:07 +0000 Received: from us-smtp-delivery-180.mimecast.com ([216.205.24.180]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1l0TLL-0003U3-AS for pgsql-interfaces@lists.postgresql.org; Fri, 15 Jan 2021 17:57:06 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tableau.com; s=mimecast20191219; t=1610733421; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=5JUAkpKP5IkfX+0/yQ5/ljBt9alDjjUEUDAJX9Iu5Ko=; b=Efn3cHK9+uV10DR+EVEeRY8j35z+gOsR4Z5Nn+01wuzlxa6IiL9pQdT4v+2zpGFdR0r/7f pwPbAXiQ9vbLRmIfz7RnqpuTGavz7PlxOrKQHkcUTMyOCT8YHVDwTmVVB7EAS5MLa7AjkY eEwljvjp+iYr7vBdqBr2KNE/ffWvK0e7HU5UitCteiOzLBj0GxUMwbYzAj/w3uJyIaLMPf Fgb5+SzV1+VfzXOsL7N77bfoiGz2l+GL3Ravx1oUz4ugTyml2b2tMwb+9FzYsThXEiynco TbSs1ykztOUzBetWqMB4UVqnrN20heq5uYcE+NawCySIPOvNmPJsqKOnFO3yDA== Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-141-DXtzZTKINd-3_eLDwrSuHA-1; Fri, 15 Jan 2021 12:56:57 -0500 X-MC-Unique: DXtzZTKINd-3_eLDwrSuHA-1 Received: from BY5PR03MB4965.namprd03.prod.outlook.com (2603:10b6:a03:1e8::23) by BYAPR03MB4550.namprd03.prod.outlook.com (2603:10b6:a03:ca::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.11; Fri, 15 Jan 2021 17:56:54 +0000 Received: from BY5PR03MB4965.namprd03.prod.outlook.com ([fe80::a8c5:3928:7acd:3a01]) by BY5PR03MB4965.namprd03.prod.outlook.com ([fe80::a8c5:3928:7acd:3a01%5]) with mapi id 15.20.3763.011; Fri, 15 Jan 2021 17:56:54 +0000 From: Adrian Vogelsgesang To: "pgsql-interfaces@lists.postgresql.org" Subject: Libpq: Fail connection attempt if server didn't request a password Thread-Topic: Libpq: Fail connection attempt if server didn't request a password Thread-Index: AQHW62QrYUUy5tgLvUK8TVXQFX7sVw== Date: Fri, 15 Jan 2021 17:56:54 +0000 Message-ID: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [2001:a61:2bbc:fa01:ac1e:73d2:82c6:cf91] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: c94303f1-dc77-4de4-ffff-08d8b97ef1cd x-ms-traffictypediagnostic: BYAPR03MB4550: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508 x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0 x-microsoft-antispam-message-info: kK1YIDau/vT3HegL2k7SXBSRR760460VLHZz9BQkwmYU788kVVN2Qdo9W00cA+QLo3Q0I0UXEyXuU7DTfRmHq910kVB7lBU860KBcMIi0G1oEku9MqYEkS5+lBlqQBTfLPPu6xmWb+y4YCUX5CF3jsUh1KpY62zo4v3IwiFSI9DWstcQo+7MtII3V5RfcQkpm/ufjppavQFcq1y2p7hAdNVO0BLweeqNqa5BKAhMsEeyMMtgM0EWh5aCmVW6KADdMNF5EftnPM80jBV9vz8C6AMIJ1y/0sbzrN9LuNTfF02Ul+uZCXHFVgYR04hAQ60w9lMn51A3BFrt38gOwTOlTPnAAe8GmxE4Dm4lXxDkG+bqQQ3KrPUFEqDsMRl2JNTMnwSaymPFJ6YIMXfOkWxVtQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR03MB4965.namprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(396003)(366004)(136003)(346002)(376002)(39860400002)(8676002)(8936002)(186003)(66446008)(76116006)(52536014)(2906002)(5660300002)(9686003)(66946007)(66476007)(64756008)(55016002)(86362001)(66556008)(316002)(33656002)(478600001)(6916009)(7696005)(6506007)(83380400001)(71200400001)(91956017);DIR:OUT;SFP:1102 x-ms-exchange-antispam-messagedata: =?Windows-1252?Q?IH1ZxTt7aT9xjH34Kbo4Ge+7mjOLY293xBs5T88mcM21eQ4eZz1Svgx1?= =?Windows-1252?Q?gN1b+c0/nByWQW4rEZtlTtB/oWmXAIZjanjTGCG7C+r08xwFe0zsUQhl?= =?Windows-1252?Q?pbwZNHb/knOysL6DTOasYwZxfSZIzFMNKMy3M6ItxNl7GJQJkUoxpcwL?= =?Windows-1252?Q?5F0E12qmDhyEJ+eu0T6OVuhoS/Z+DmrxT+Ge4DAsGx97OsBBkwebxuFY?= =?Windows-1252?Q?b8cg/LV7WXqf9af+qivm5RgxQ6xQFKdOyxvZ4wmv1Td4/LKAdB53hmU5?= =?Windows-1252?Q?eoVkCZJe4I0LTqfYqqDngbsFb02g39Mh8zAxdy51ZV6f3h+D5F8hWuc3?= =?Windows-1252?Q?tKOLKDVYERZzvfNwcZ6tR1til6EyL6F8PvnJgAyuux5Yn/ktEwfQHwXO?= =?Windows-1252?Q?DoMAJt7GA8ZiWJ7/FhTYdehn/Z9JMqOPGSf6/ek1wBmj1HuzGRJ+PR14?= =?Windows-1252?Q?RXS9Sg4P/ES5q9KPNUxEmx7EJH3zDCeqr3MQHOuLhtfe7Jjvoddk8AKg?= =?Windows-1252?Q?OaApYRqRYEITv7qAkL2ADFDuuwKJ29AZJrrfn66un6655BKQbXyRiMnZ?= =?Windows-1252?Q?Wmt2VdT/WnWLO/LvrZFUFOIAml8ttV8g/86rFWY5eSd9126xNQORz2Zz?= =?Windows-1252?Q?USvSIzgfRA6QQ/6A8qSh5qNS1XtMLs0F9/c6BI2//Wu/FCOsn34SLWt8?= =?Windows-1252?Q?yHw4vd14ACQ8FTTpOhA43jSp6n5OWhJDDeWIfk8o0wg/S/zp6u4cp8Pk?= =?Windows-1252?Q?YhFEfZ9ACBp/KZnXZsdM74vYNeTTy7JWFBpx+j0JAbJayNy3cMS7ePdC?= =?Windows-1252?Q?8KWxdAsh+9Ih4YrTyOJl8BDzhbDbA2cCbcWTnKIbyD7BI5tmoBdVMceN?= =?Windows-1252?Q?egJsc5k69COxlX08VxKjhGCTuOjCvbkxOtlaaN6mQJZ2x7+NlGMSViGf?= =?Windows-1252?Q?/maRbegidQnTh0aUP2tG8dd8/YSy7bJtVoCNloYeZAiwnS98mUouY2BH?= =?Windows-1252?Q?VM7zl9K60ZMEEWDW91U3Cy+dTAaeajNvT5kNr/CuH8CaPVzTE8d7WH4E?= =?Windows-1252?Q?hXIz6GwM2+KKbKBrJp4RDY1IWG5bhr3ioBQZNAVXwA238GEUs73l4EzC?= =?Windows-1252?Q?We9kj93uRrXGWZ9N2kHbshSF9RrMj9z6OPBAYAZd3vfETw=3D=3D?= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: tableau.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BY5PR03MB4965.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c94303f1-dc77-4de4-ffff-08d8b97ef1cd X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2021 17:56:54.5657 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 5067385a-c584-42cc-8679-3fa2879f99be X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 05aWunjjqr7CtruaVP80OLa26p6qEa+KQdStWn70I67vTGJypdO5OdM/b59K7rRk5ObhsV+UvadLmHxGCRALjByC3ZPk4C20jLAaJeINXXo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR03MB4550 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA80A147 smtp.mailfrom=avogelsgesang@tableau.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: tableau.com Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_BY5PR03MB4965271A9AE58B7367D1DB52A3A70BY5PR03MB4965namp_" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --_000_BY5PR03MB4965271A9AE58B7367D1DB52A3A70BY5PR03MB4965namp_ Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Dear Postgres community, Today, I learned that in the Postgres protocol, the Postgres server first h= as to request a password from the client before libpq will send it. In particular, this also means: if the server doesn=92t request a password = but simply accepts the connection, libpq will just establish the connection= . Is there some way to let libpq fail the connection attempt in such a case, = i.e. if a password was provided but not requested from the server? Can I, as the client, force the authentication used during creating a conne= ction to be scram-sha-256? Or can I at least disable MD5 and plain-text authentication on the client-s= ide (which I both consider unsecure)? You might ask: Why do I care to enforce the authentication mode on the clie= nt side? Two reasons: 1. To identify misconfigured server. In our use case, all servers should re= quire a password. By failing hard and early, we can more easily find miscon= figured servers 2. To establish some trust on the client-side that I am actually connected = to the correct server. In scram-sha-256, the server also has to authenticat= e to the client. This would be a nice additional level of security. However= , this is worthless if the client doesn=92t enforce a scram-sha-256 authent= ication: A malicious server could simply accept the connection without aski= ng for a password or use the MD5 method instead Cheers, Adrian --_000_BY5PR03MB4965271A9AE58B7367D1DB52A3A70BY5PR03MB4965namp_ Content-Type: text/html; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable

Dear Postgres community,

Today, I learned that in the Postgres protocol, the Postgres server first h= as to request a password from the client before libpq will send it.
In particular, this also means: if the server doesn=92t request a password = but simply accepts the connection, libpq will just establish the connection= .


Is there some way to let libpq fail the connection attempt in such a case, = i.e. if a password was provided but not requested from the server?
Can I, as the client, force the authentication used during creating a conne= ction to be scram-sha-256?
Or can I at least disable MD5 and plain-text authentication on the client-s= ide (which I both consider unsecure)?

You might ask: Why do I care to enforce the authentication mode on the clie= nt side? Two reasons:
1. To identify misconfigured server. In our use case, all servers should re= quire a password. By failing hard and early, we can more easily find miscon= figured servers
2. To establish some trust on the client-side that I am actually connected = to the correct server. In scram-sha-256, the server also has to authenticat= e to the client. This would be a nice additional level of security. However= , this is worthless if the client doesn=92t enforce a scram-sha-256 authentication: A malicious server could= simply accept the connection without asking for a password or use the MD5 = method instead

Cheers,
Adrian

--_000_BY5PR03MB4965271A9AE58B7367D1DB52A3A70BY5PR03MB4965namp_--