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 1tLS15-00Eru2-Gc for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Dec 2024 19:04:59 +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 1tLS11-001FM0-NK for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Dec 2024 19:04:56 +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 1tLS11-001FLH-Ci for pgsql-hackers@lists.postgresql.org; Wed, 11 Dec 2024 19:04:56 +0000 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tLS0z-002JyR-57 for pgsql-hackers@lists.postgresql.org; Wed, 11 Dec 2024 19:04:56 +0000 Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-7b6e5c74cb7so132317585a.2 for ; Wed, 11 Dec 2024 11:04:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733943892; x=1734548692; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=T4D2ox0t3gfRADHCDVtyRqdJsylc6VzW7ycQoAjsLqs=; b=OBQ+dtAh1R+h7/KX1gCxLPhnOWW9+10p4kHoupjn0G87vTJzNOgsff1E1GoSKo2Z9p vzGYEJ6bLUS6SBzOG1rgMUA+OdDV96k3DACw8Ha1LxJtjx3XgmPxW8Zo+uPqgn9qDkVY piCqrARkd4Ue8vDh1dKhku4DVqEPZ1/408Z4v8AzMlLmyynANVQ1a3+p9Kee8UQ4sCAf oab/tB6UIOaw/XwwUHKOmpdXl7wOOJ4UlbA2fE/DQGvf6olGsg7tZY6D3Wt4a3rQaqb0 AwifW8Iut8hAmWLZIPgZuoiW7cBy7xV22Zuac3hu04iivuRegVqtUSO3wonvMZ8zyUu7 YfGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733943892; x=1734548692; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T4D2ox0t3gfRADHCDVtyRqdJsylc6VzW7ycQoAjsLqs=; b=XTYo6EFATXzQj6OFaS7Br1CvtTfANtdc5LfvIRI5B4za+fG46i5Tk7Xo8j/27ml1X9 SolhsGabcqeVLzourmlLzMM8K0jcwILeGImnxxm7OwuF36zDPsLd0pQCIO1vnICQ2/yh Rn9N45sFYkXp+H/eimYQn80tIiR8V3omIWgKarxQT+5SURCa48iauP5HdjCsKy0N/D1k rs8BAsj/ZHseI7gVs0NrUraSzPSG/shd3lNXa9VA4wrBu5dq+bXjSHk76YBb4OEYSLWA OcoHivJhyT3SfsXzxKBnb0Mw7tHWQBEetplgYG+J1OuPX7kD14NcMTwGqitS3xh2obIZ xxFQ== X-Forwarded-Encrypted: i=1; AJvYcCV7Sm6T0enaylB0Ff54wK7vNqhQ5lDZpMYcX6DCpU3Pknb+hCuw4z/uEeaQ7GstyOgJWwZ6+ccDM0LEaEtS@lists.postgresql.org X-Gm-Message-State: AOJu0Yz2liPy/8TMCWnd2eGeGg25ElYPgvCjztxYyqbRKvn2ENmRXf8F 7gHlU/E7pJcmqHVNR454vjYVJeWOHofmJPM6+SGmyZ3TlZDgTvp9DzCRY2UnAgA1198vgLmzZrW vu79zo2cIO3IMsnJGNMEiciVVGlM= X-Gm-Gg: ASbGncsLUKKbYdYWBdQM0gzReC+Q+OQG++X+3IJI0yD+3uurFTa1NM3m0/EPurDfhY7 UDoa1V3Bp+yUw9cUbWu9e7pounRLZPt1U4OkfOd9mV4qW6CJ7tzqv0obCzTsqW+m2EJk= X-Google-Smtp-Source: AGHT+IHvVXtP0wI/jCGwiclxU2iEKA+ai+nNmZfbqMuAi1OuHDJU7EoIGaDfQyHVWVmUP/SCm6T5l+rjbSYaMXJZTH8= X-Received: by 2002:a05:620a:471e:b0:7b6:cfab:987b with SMTP id af79cd13be357-7b6f2543c42mr88499385a.14.1733943891935; Wed, 11 Dec 2024 11:04:51 -0800 (PST) MIME-Version: 1.0 References: <27b29a35-9b96-46a9-bc1a-914140869dac@gmail.com> In-Reply-To: From: Matheus Alcantara Date: Wed, 11 Dec 2024 16:04:41 -0300 Message-ID: Subject: Re: SCRAM pass-through authentication for postgres_fdw To: Jacob Champion Cc: Jelte Fennema-Nio , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Em qua., 4 de dez. de 2024 =C3=A0s 20:39, Jacob Champion escreveu: > > On Wed, Dec 4, 2024 at 3:05=E2=80=AFPM Jelte Fennema-Nio wrote: > > I only see advantages over the > > alternative, which is copying the plaintext password around. In case > > of compromise of the server, only the salt+verifier has to be rotated, > > not the actual user password. > > Sure, I'm not saying it's worse than plaintext. But a third > alternative might be actual pass-through SCRAM [1], where either you > expect the two servers to share a certificate fingerprint, or > explicitly disable channel bindings on the second authentication pass > in order to allow the MITM. (Or, throwing spaghetti, maybe even have > the primary server communicate the backend cert so you can verify it > and use it in the binding?) I'm not understanding how these options would work for this scenario. I understand your concern about making the users copying the SCRAM verifiers around but I don't understand how this third alternative fix this issue. Would it be something similar to what you've implemented on [1]? The approach on this patch is that when the backend open the connection with the foreign server, it will use the ClientKey stored from the first client connection with the backend to build the final client message that will be sent to the foreign server, which was created/validated based on verifiers of the first backend. I can't see how the foreign server can validate the client proof without having the identical verifiers with the first backend. I tested a scenario where the client open a connection with the backend using channel binding and the backend open a connection with the foreign server also using channel binding and everything seems to works fine. I don't know if I missing something here, but here is how I've tested this: - Configure build system to use openssl meson setup build -Dssl=3Dopenssl ... - Start two Postgresql servers - Configure to use ssl on both servers ssl =3D on ssl_cert_file =3D '/path/to/server.crt' ssl_key_file =3D '/path/to/server.key' - Changed pg_hba to use ssl on both servers hostssl all all 127.0.0.1/32 scram-sha-256 hostssl all all ::1/128 scram-sha-256 - Performed all foreign server setup (CREATE SERVER ...) - Connect into the backend using channel_binding=3Drequire psql "host=3D127.0.0.1 dbname=3Dlocal sslmode=3Drequire channel_binding= =3Drequire" - Execute a query on fdw server I've also put a debug message before strcmp(channel_binding, b64_message) [2] to ensure that channel binding is being used on both servers and I got the log message on both servers logs. Sorry if I misunderstood your message, I probably missed something here. [1] https://www.postgresql.org/message-id/9129a012-0415-947e-a68e-59d423071= 525%40timescale.com [2] src/backend/libpq/auth-scram.c#read_client_final_message --=20 Matheus Alcantara EDB: https://www.enterprisedb.com