pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <mail@joeconway.com>
To: William Denton <wdenton@gmail.com>
To: Karsten Hilbert <Karsten.Hilbert@gmx.net>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Row data is reflected in DETAIL message when constraints fail on insert/update
Date: Sat, 22 Jun 2019 07:20:51 -0400
Message-ID: <d1ba185d-7c57-0669-a5f9-51e6a138f96d@joeconway.com> (raw)
In-Reply-To: <CAO8wz8TFWvqx+zVhpr-vp1X5vcC5+Z_W+QujCkKXXQ5LdPnsmQ@mail.gmail.com>
References: <CAO8wz8QdKRTJUnW--AZ2N-BvJAemS+P9=Sr7zUbkO+wmAmA7LQ@mail.gmail.com>
	<b2afcfd3-a2c2-9bdc-3e62-a28392f0b8f6@aklaver.com>
	<CADT4RqDYLKWxxHejU2ZE6Wmveo8x09Zf8aw4pdT-=0uU82Us=Q@mail.gmail.com>
	<20190620114527.GD30366@hermes.hilbert.loc>
	<CADT4RqB8ZdqRguV05JdXpSr6dwK3azcebu0c_4Eg0ADnUtK=tg@mail.gmail.com>
	<20190620152741.GG30366@hermes.hilbert.loc>
	<13631.1561047413@sss.pgh.pa.us>
	<20190621095754.GA2222@hermes.hilbert.loc>
	<CAO8wz8TFWvqx+zVhpr-vp1X5vcC5+Z_W+QujCkKXXQ5LdPnsmQ@mail.gmail.com>

On 6/22/19 6:00 AM, William Denton wrote:
>>I guess the original question basically boils down to "Given a
>>rogue/dumb app, and a DBA who neglected his job, is it PG's
>>business (or even within its possibilities) to mop up ?"
> 
> It feels like you aren't setting people up to land in the pit of success. 
> It's easy to sit back and call people negligent because they failed to 
> change settings from their defaults. Data breaches are all too common 
> due to mis-configured systems, we can all have a good laugh at the 
> poor people who have suffered breaches due to defaults that 
> come/came with s3, mongo and many other data stores, but why must 
> we operate on that level to rather than being a little more defensive?
> 
> How is it useful in a normally configured database to return row data in
> error messages?
> 
> Is the client application supposed to parse that data?
> 
> Must the client perform another query to discover column names and 
> attributes so the data can be parsed?

+many

I agree entirely.

> I can definitely see a use for it during debugging and development where a 
> human has their eyes on what the database is returning, but I would argue 
> if you wanted that information for debugging purposes you would enable 
> verbose logging.

Exactly.

Dev and test environments it makes sense to send verbose messages to the
client. In production it does not.

> I have spent a few minutes searching google for terms like 
> "harden postgres for production" or "locking down postgres" or  
> "postgres production configuration". NONE mention log_error_verbosity. 
> Searching the postgres wiki yields no results for log_error_verbosity. Only 
> once you start searching for the problems caused by log_error_verbosity 
> can you become aware that this setting exists and should be changed in 
> production environments. Yet the only mention on of this parameter on any
> postgres site (docs or wiki) is the one pasted below Calling people
> negligent
> for not knowing something, when you have failed to tell them seems
> disingenuous.
> 
> Further, the documentation for log_error_verbosity mentions nothing
> about the 
> data returned to the client. This text is explicitly talking about the
> server log.
> 
>>Controls the amount of detail written in the server log for each
> message that is 
>>logged. Valid values are TERSE, DEFAULT, and VERBOSE, each adding more 
>>fields to displayed messages. TERSE excludes the logging of DETAIL, 
>>HINT, QUERY, and CONTEXT error information. VERBOSE output includes the 
>>SQLSTATE error code (see also Appendix A) and the source code file name, 
>>function name, and line number that generated the error. Only
> superusers can 
>>change this setting.
> 
> I would suggest that row data should be reclassified as only appearing in 
> VERBOSE configurations as there is nothing an application client could
> do with 
> that information, it is only useful to a human operating interactively
> with the db.

In my experience the log files are generally required to be locked down
similarly to postgres itself, as was pointed out by (I think) Tom
elsewhere on this thread. To me, logging these details to the log file
is not the issue. And log files can be controlled in such a way as to
protect them even from the superuser and/or be shipped off to a log
collector for audit purposes.

The issue is the level of detail sent to the client. There is a setting,
client_min_messages, which could be used as a broad hammer to clamp what
gets sent to the client except that it is user settable. I think if we
made that superuser set instead it might at least be a step in the right
direction, although I have not tested to see what the results of an
error look like at the client in that case.

Separately I previously submitted a patch to optionally redact the
messages that go to the client. That would allow the client app to get
the SQL error code at least, but not the message. But it was rejected in
the last commitfest. See the relevant thread here:

https://www.postgresql.org/message-id/flat/2811772.0XtDgEdalL@peanuts2

Joe

-- 
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development





view thread (22+ messages)  latest in thread

Message-ID: <d1ba185d-7c57-0669-a5f9-51e6a138f96d@joeconway.com>
Permalink:  ../d1ba185d-7c57-0669-a5f9-51e6a138f96d@joeconway.com/
Also on:    postgresql.org/message-id/d1ba185d-7c57-0669-a5f9-51e6a138f96d@joeconway.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: mail@joeconway.com, wdenton@gmail.com, Karsten.Hilbert@gmx.net
  Subject: Re: Row data is reflected in DETAIL message when constraints fail on insert/update
  In-Reply-To: <d1ba185d-7c57-0669-a5f9-51e6a138f96d@joeconway.com>
  References: <CAO8wz8QdKRTJUnW--AZ2N-BvJAemS+P9=Sr7zUbkO+wmAmA7LQ@mail.gmail.com> <b2afcfd3-a2c2-9bdc-3e62-a28392f0b8f6@aklaver.com> <CADT4RqDYLKWxxHejU2ZE6Wmveo8x09Zf8aw4pdT-=0uU82Us=Q@mail.gmail.com> <20190620114527.GD30366@hermes.hilbert.loc> <CADT4RqB8ZdqRguV05JdXpSr6dwK3azcebu0c_4Eg0ADnUtK=tg@mail.gmail.com> <20190620152741.GG30366@hermes.hilbert.loc> <13631.1561047413@sss.pgh.pa.us> <20190621095754.GA2222@hermes.hilbert.loc> <CAO8wz8TFWvqx+zVhpr-vp1X5vcC5+Z_W+QujCkKXXQ5LdPnsmQ@mail.gmail.com> <d1ba185d-7c57-0669-a5f9-51e6a138f96d@joeconway.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox