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 1n5une-0002o1-2L for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Jan 2022 19:21:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n5unc-0003Tt-Pk for pgsql-hackers@arkaria.postgresql.org; Fri, 07 Jan 2022 19:21:16 +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 1n5unc-0003Tk-Dl for pgsql-hackers@lists.postgresql.org; Fri, 07 Jan 2022 19:21:16 +0000 Received: from mail-io1-xd29.google.com ([2607:f8b0:4864:20::d29]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1n5unZ-000071-7d for pgsql-hackers@lists.postgresql.org; Fri, 07 Jan 2022 19:21:15 +0000 Received: by mail-io1-xd29.google.com with SMTP id x6so8251152iol.13 for ; Fri, 07 Jan 2022 11:21:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=wYv6q7+WfDX8qhoRoY3gB1i5vox0PjEmRnHZEQbe3h0=; b=4NbiO2Y7UKIf22ewPwegDmlCh1Xz2LzKEZZAzeU3TKXZvqtkxGJXtRPj2IY3bjAwnp OffPrcCdC3wmRc+/O4SIf7ddRxJKJYHNbCrjwbB/bUa4+ulbMJz+tbweOeHKOzKHMy3t wCJr9RfPSEslz6rrbCR98UlRQouSJqlhk/nzMqwNrYhaAxN71R7/64+kgWerRfwdiTbn d5uyX9Ii9ZSpRwfTgZpfSMpRzj0BlZIVg+zSygqGKwI+lD+awXMVEv9pARTyOuTgcUn4 mFLOryYkwbanv1E75ssqJUTTbvTeqB8Bt0k2DFzHbDhtzylMM7WKopv/bqh3vMim5Dq1 bQnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=wYv6q7+WfDX8qhoRoY3gB1i5vox0PjEmRnHZEQbe3h0=; b=wh6WGTJv1vbT54/vWmSO+8AQ3HQHwAJV1zi37r8brAzrSB7SOVYVUpfBLQcBYonzMr OKspTW2YkS60eADcC8rNjU2/UVolYwoHqbbeo5jh7atrDAlFcoChz2sZJePrevJFx80w XwRpAKE67wzPocwxodin3SN1tkYtZBNDCzzUO3dDHqrW/7i5wJSE9bPefq7xk429ZzgG MrMvQJ/tXcQVONZIq8296/8FxNS9L5t/eryBaMp96w2AqSViU65t525jzY1Z6cBM8mmv dhSgH+EliCNjDARb8sEdqSPG1oYQIDj06rv7sWfXQNvJcaTn88v47WYX5TLHBwx5I+HJ BJQw== X-Gm-Message-State: AOAM532npaZ7zZ9uZhH2zAGxDHfAxwffq9SZ5J0eULqQ8+QMXwTw1yTM eoT3hoeT1eWIU2qnXc+8QLrx9YyttroLYw== X-Google-Smtp-Source: ABdhPJyLXGmrtchuseWnvFfoo0fqMMSicoUDSyQr43K7K93kCdaXGXKNRLByhdcb0aalg3ScRpVXYQ== X-Received: by 2002:a05:6638:57:: with SMTP id a23mr26043654jap.243.1641583272137; Fri, 07 Jan 2022 11:21:12 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id z17sm3398210ior.22.2022.01.07.11.21.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Jan 2022 11:21:11 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id EADC4800E15; Fri, 7 Jan 2022 13:21:10 -0600 (CST) Date: Fri, 7 Jan 2022 13:21:10 -0600 From: Justin Pryzby To: Bruce Momjian Cc: Daniil Zakhlystov , pgsql-hackers@lists.postgresql.org Subject: Re: libpq compression (part 2) Message-ID: <20220107192110.GG14051@telsasoft.com> References: <20220101172504.GW24477@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Jan 07, 2022 at 01:46:00PM -0500, Bruce Momjian wrote: > On Sat, Jan 1, 2022 at 11:25:05AM -0600, Justin Pryzby wrote: > > Thanks for working on this. The patch looks to be in good shape - I hope more > > people will help to review and test it. I took the liberty of creating a new > > CF entry. http://cfbot.cputube.org/daniil-zakhlystov.html > > > > +zpq_should_compress(ZpqStream * zpq, char msg_type, uint32 msg_len) > > +{ > > + return zpq_choose_compressor(zpq, msg_type, msg_len) == -1; > > > > I think this is backwards , and should say != -1 ? > > > > As written, the server GUC libpq_compression defaults to "on", and the client > > doesn't request compression. I think the server GUC should default to off. > > I failed to convince Kontantin about this last year. The reason is that 1) > > it's a new feature; 2) with security implications. An admin should need to > > "opt in" to this. I still wonder if this should be controlled by a new "TYPE" > > in pg_hba (rather than a GUC); that would make it exclusive of SSL. > > I assume this compression happens before it is encrypted for TLS > transport. Second, compression was removed from TLS because there were > too many ways for HTTP to weaken encryption. I assume the Postgres wire > protocol doesn't have similar exploit possibilities. It's discussed in last year's thread. The thinking is that there tends to be *fewer* exploitable opportunities between application->DB than between browser->app. But it's still a known concern, and should default to off - as I said. That's also why I wondered if compression should be controlled by pg_hba, rather than a GUC. To require/allow an DBA to opt-in to it for specific hosts. Or to make it exclusive of ssl. We could choose to not suppose that case at all, or (depending on the implement) refuse that combination of layers. -- Justin