Re: Prevent remote libpq notices from being sent to clients

Поиск
Список
Период
Сортировка
Искать

Re: Prevent remote libpq notices from being sent to clients

От:
Jacob Champion <jacob.champion@enterprisedb.com>
Дата:
On Fri, Jun 5, 2026 at 7:43 AM Tom Lane  wrote:
> Also, I don't buy the argument that this is a "leak": if the remote
> server was willing to send the message to its client, it doesn't think
> that the message is security-critical.

I don't think the remote gets to decide that, in general. It's up to
the middle layer to know whether it's operating at the same level of
trust as the end client.

--Jacob


Re: Prevent remote libpq notices from being sent to clients

От:
"Tristan Partin" <tristan@partin.io>
Дата:
On Fri Jun 5, 2026 at 9:32 AM UTC, Chao Li wrote:
> Hi,
>
> This is another issue with “[112faf137] Log remote NOTICE, WARNING, and similar messages using ereport()”. From the commit message, the intention of the feature is to log remote messages with ereport() to get better formatting:
> ```
>     Log remote NOTICE, WARNING, and similar messages using ereport().
>
>     Previously, NOTICE, WARNING, and similar messages received from remote
>     servers over replication, postgres_fdw, or dblink connections were printed
>     directly to stderr on the local server (e.g., the subscriber). As a result,
>     these messages lacked log prefixes (e.g., timestamp), making them harder
>     to trace and correlate with other log entries.
>
>     This commit addresses the issue by introducing a custom notice receiver
>     for replication, postgres_fdw, and dblink connections. These messages
>     are now logged via ereport(), ensuring they appear in the logs with proper
>     formatting and context, which improves clarity and aids in debugging.
> ```
>
> So remote messages should only be output to the server log, but currently they can leak to the client if client_min_messages is set to log.
>
> This is a simple repro:
> ```
> evantest=# set client_min_messages=log;
> SET
> evantest=# select * from dblink('host=localhost dbname=postgres’,
> 'do $$ begin raise warning ''hello, client!!!''; end $$; select 1’)
> as t(x int);
> LOG:  received message via remote connection: WARNING:  hello, client!!!
>  x
> ---
>  1
> (1 row)
> ```
>
> The one-line fix is straightforward, just change the ereport() level from LOG to LOG_SERVER_ONLY. I also added a test in the patch.

This looks good to me. Do you think we should also copy the test to 
postgres_fdw? Or, I wonder if there is an even better location for the 
test outside of either's regression suite.

-- 
Tristan Partin
PostgreSQL Contributors Team
AWS (https://aws.amazon.com)


Re: Prevent remote libpq notices from being sent to clients

От:
Chao Li <li.evan.chao@gmail.com>
Дата:


> On Jun 5, 2026, at 23:20, Jacob Champion  wrote:
> 
> On Fri, Jun 5, 2026 at 7:43 AM Tom Lane  wrote:
>> Also, I don't buy the argument that this is a "leak": if the remote
>> server was willing to send the message to its client, it doesn't think
>> that the message is security-critical.
> 
> I don't think the remote gets to decide that, in general. It's up to
> the middle layer to know whether it's operating at the same level of
> trust as the end client.
> 
> --Jacob

Thanks to all for the input. It looks like people have different opinions on this topic. BTW, I realized that my previous wording of "leak" was too strong, sorry about that.

Here, I think the main concern is that this is an “unintentional" user-visible behavior change. I went through the original discussion thread [1], and I don't see this behavior change being explicitly discussed. I am not against Fujii's idea that emitting a remote WARNING to the client could be helpful, and I also like Tom's idea of mapping the remote severity to the local log level. But if we really want to do that, I think we need a dedicated discussion, and that seems too late for v19. Also, if we eventually decide to change the client-visible behavior, I think we should document it explicitly.

How about preserving the old client-visible behavior for v19?  I can add this topic to my TODO list and follow up with this work for v20.

[1] https://postgr.es/m/CALDaNm2xsHpWRtLm-VL_HJCsaE3+1Y_n-jDEAr3-suxVqc3xoQ@mail.gmail.com

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/






FAQ