Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hee4z-00032b-7v for pgsql-general@arkaria.postgresql.org; Sat, 22 Jun 2019 11:21:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hee4w-0008H2-3N for pgsql-general@arkaria.postgresql.org; Sat, 22 Jun 2019 11:21:06 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hee4v-0008Al-G5 for pgsql-general@lists.postgresql.org; Sat, 22 Jun 2019 11:21:05 +0000 Received: from mail-qt1-x841.google.com ([2607:f8b0:4864:20::841]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hee4m-0003PR-GM for pgsql-general@lists.postgresql.org; Sat, 22 Jun 2019 11:21:03 +0000 Received: by mail-qt1-x841.google.com with SMTP id n11so9667975qtl.5 for ; Sat, 22 Jun 2019 04:20:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joeconway.com; s=google; h=to:cc:references:from:openpgp:autocrypt:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=hphQnVA70MCVoCROZe9+LzvDH1GQcvPKIz1pvCfOdbg=; b=f+Dpbz7NALkUrgQheWPY+9g1k1ucfgPyZMCNwaDYltMabBovq6LHwsfS4KkGQ3I5hE 1klsOHD7ukSJeGf5ASqD05OzWfJ7L8cMgXCcSDdzUH6BTigTEdFxsY3CE+fMNT7qSqPy EKQm5RmAUixdBFvIdbZAuxtdW5knbmEuuxQb35L+JRB4SiRLD4sntMaF6qfIxR2YR+NM kLZbakAVb9aPCzGkQM+eHBQXQrepsNDW0sHDIb7YItRn8VSaQnm2v6RMaVkBmXyX3/je aT6uixe6kxGn6QFEzZtNxzPcE1swF12QWU52fW9v2aOOr+xDu3pd+Nzj7ARVVAgZi5IB 7aMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:references:from:openpgp:autocrypt:subject :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=hphQnVA70MCVoCROZe9+LzvDH1GQcvPKIz1pvCfOdbg=; b=bEv/ZfUvc8Wv4datnQrmuKtF+4Qp+L4jgZ9HzBpLRgWeMt3dIQQS9w5Js3MtlrWDKI eSAigRu1l5QEeUhThUj2Pqhg/l/+QO0wCriGJpPJOBJVJJkXrUJjBmIRfvU088dUUZCU vwtDnIGRIDF0CvesGEP0ZzokPwgrLTLhUky90ZeencAh6yjpihwXTYBe/jNNaYBie78F TiuT7i6OtaqPkaMCKsaUF9PJA0S9/Ljn8dCpC4winUfhtvGBiLhPF2/F6FxksnNdCOWs rrPImrsokZokksV0HDGL4jNLayT+K+p4UrasojForLR1Emwbf6u3HICzakSd11NN5KGq 6IUQ== X-Gm-Message-State: APjAAAXYCvTdVTDLCzXkarXoF5Co0SW8LD0c67DfE2uRTUnRF6Vq16yF eSHbbBwmqM8mu7NRP5qId+QZxceaAKc= X-Google-Smtp-Source: APXvYqxMdZshgM1ahN8e3Kpxs38CF3bFlXY31trto9CLoyotLi1aDu1vYNyNPec+vyw0SNN4hMEU4w== X-Received: by 2002:aed:21c6:: with SMTP id m6mr59293475qtc.173.1561202452484; Sat, 22 Jun 2019 04:20:52 -0700 (PDT) Received: from [10.204.0.243] ([205.153.92.178]) by smtp.gmail.com with ESMTPSA id b69sm3036755qkg.105.2019.06.22.04.20.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 22 Jun 2019 04:20:51 -0700 (PDT) To: William Denton , Karsten Hilbert Cc: pgsql-general@lists.postgresql.org References: <20190620114527.GD30366@hermes.hilbert.loc> <20190620152741.GG30366@hermes.hilbert.loc> <13631.1561047413@sss.pgh.pa.us> <20190621095754.GA2222@hermes.hilbert.loc> From: Joe Conway Openpgp: preference=signencrypt Autocrypt: addr=mail@joeconway.com; prefer-encrypt=mutual; keydata= mQINBEpXMCsBEADDnXUQzjlyi/cX02Gtdy2CLcroE5CsC7DJKdOBDbfgn0kfiIYoV5JniG4l VyzZUodY8yUAagqLYolh0UkBzs9N+qkm7erde4ypw3jzVQ37BuzIvk3nMUbuDZDgxWqX+nVS sKc+BQ5BpzgCHg48leoRO2ohjvYnUhgH3j2rFZCzaj6qQ7mv+XoxOJmUlVQtG06Jwkk7Vu14 7U9nMMM6hyUKzVnmCphnlcMNo26UyVU70MwFfFJgcI0c5fpp8byN56eD6VJVnufO5WAuEhzE qcrSJR2FAlmM90GBY+6vP29twLDCHuSFvrnujNCx/BvCC/a3/gPvyAFp4JtMm9eXAmq3m/Kw 94nTJXVdcbQeQQDp3KIG7MmWS4lnGvPn8v0CjgNaLvZXFLo1FgmUVsyEq1Lww4iRLa6sbpXJ ESx15UEue1k1YZM9C+4F/o3aeKNsAienjw2EXFzcaxIg/C4P493VMi3Qa8ycVxR5iYhUbYdo DFIUQhbFNsYfrtW/qZAELT3FCYFpZYG01e9Hj+cBrXXgyDDkQ5Lq4mlvmkRvuxn61V6Au4HA 0sJiCox5pM1FvzT+aI8HY1BYaiB9Pl4fhpKgmhhlSuglk9v39S4jmlUIb45iLAUVpeNM6Qjm 69pf5da9sm4aGFa7YlDSKf/WcU7z9ITZxsilOi2n7YJiwG7kTQARAQABtB9Kb2UgQ29ud2F5 IDxtYWlsQGpvZWNvbndheS5jb20+iQI8BBMBAgAmAhsDBwsJCAcDAgEGFQgCCQoLBBYCAwEC HgECF4AFAlpoksUCGQEACgkQMyt+aLaZQ0p4XQ/9F4WSf4ZFuL3ae356ApVqnLxphHXeXHli ePZe7qosvXMQLN9Y2m5cQw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Uuj/Tuzvz9ZmucFNbQbauDQw6V Q38ofGnoYDZFJsGncprB8dBi4tDrIQ+1RlIh6C2Z/eMipqJOT26+spluTjouvnKT0S5yOgyX 0PjbsysgwQdCGNJLHOjhHbSpSmOLaduV3CQo/0+DHT/TBjYfIXjTWouY9TkGxG4eNrxU0u2x Ay5bMqOPmsFdjLTWlQUlF/fTMhB54XwI3FHWgnSnXZzStDTmTebLNdT/ftgliAzA81uMj49j 0exv731/v+7udLA1bV8gnZ01zQCASDpWiRQR3fgwcugSUqgRABEBAAGJAh8EGAEIAAkFAkpX MicCGwwACgkQMyt+aLaZQ0pwAQ//bjcWnZg/jjRQ9gbZUGMqniItZYRglBMKIqt4Fia379Jm HwTvavnFkJ8XMZ56UB0FIrgS+sUkRH6cPRQR+7Qi392LD021DXgSsz9CwFHjFyBGHwLEOTRc fYQbtJy0shHDJB4aQTOX3ERDH1PsvJNuevmQMzS0DWFav9+xMz9rKP4N+HffoBIZE0C1xIE4 3nD4eLsbycte9sVIrmlNuUti3qUxJAQw8HwfJ6ZbBInHxquApR16uD1u99o6XlndFrDlY22t RmHCM0bR81GfGNdcU3Uo+rG/R/k4qa7s9/dgKvMbyH3fHhp/ceKag80Xo8IFurRl0ZJP3sHJ 2QDHCVLat7jRZ+43hi1WlIhFbrgn6IyI0i7XR/W8JjrC5MsKq4TUwGH077sU/kcHYebVJZRb UUst2hAGHDFVBcG12qoKf+ltL9qXJc1y7BGeCoUW6QjOpljpq6ZL4FQUsM0RSRjs5egE3szP cIf5SyPK6WDOApoAq6M7BBFMGDZwEylYMtr0YekA1u86UA9D2xwLHEbBBp/uiby1c9JbPJ1P n8zJP8WZNeRw4Q9TtqVK09+oLirMUSpIDd6KdZ1VgRxOK2re7tjDvkVuYsSrsiJ+1iJNEnp9 iK0ok0DlJpSCe6KhkxpaTdeoWMXdKuJWec0NIqoAd54ZgBPnr+UPxTixgPq/p6Q= Subject: Re: Row data is reflected in DETAIL message when constraints fail on insert/update Message-ID: Date: Sat, 22 Jun 2019 07:20:51 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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