Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YxwX2-0001TU-FS for pgsql-hackers@arkaria.postgresql.org; Thu, 28 May 2015 12:03:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YxwX1-00081g-GB for pgsql-hackers@arkaria.postgresql.org; Thu, 28 May 2015 12:03:27 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YxwWq-0007mH-Hq for pgsql-hackers@postgresql.org; Thu, 28 May 2015 12:03:16 +0000 Received: from tamriel.snowman.net ([2001:4830:167b::11]) by magus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1YxwWm-0000al-MJ for pgsql-hackers@postgresql.org; Thu, 28 May 2015 12:03:15 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 9FC2F5F7A0; Thu, 28 May 2015 08:03:11 -0400 (EDT) Date: Thu, 28 May 2015 08:03:11 -0400 From: Stephen Frost To: Heikki Linnakangas Cc: "Joshua D. Drake" , Noah Misch , Robert Haas , Tom Lane , "pgsql-hackers@postgresql.org" Subject: Re: [COMMITTERS] pgsql: Add pg_audit, an auditing extension Message-ID: <20150528120311.GW26667@tamriel.snowman.net> References: <20150528010042.GB4097628@tornado.leadboat.com> <20150528011125.GO26667@tamriel.snowman.net> <55666FB5.8090209@commandprompt.com> <20150528013840.GP26667@tamriel.snowman.net> <556673E1.8090109@commandprompt.com> <20150528020201.GQ26667@tamriel.snowman.net> <556685BF.2010604@commandprompt.com> <5566C9F1.6020103@iki.fi> <20150528081416.GT26667@tamriel.snowman.net> <5566DD3C.6020700@iki.fi> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="iC9NPIRsVYcJsJ2l" Content-Disposition: inline In-Reply-To: <5566DD3C.6020700@iki.fi> X-Editor: Vim http://www.vim.org/ X-Info: http://www.snowman.net X-Operating-System: Linux/3.13.0-46-generic (x86_64) X-Uptime: 07:55:06 up 69 days, 17:43, 22 users, load average: 0.06, 0.04, 0.05 User-Agent: Mutt/1.5.21 (2010-09-15) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org --iC9NPIRsVYcJsJ2l Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Heikki, * Heikki Linnakangas (hlinnaka@iki.fi) wrote: > On 05/28/2015 11:14 AM, Stephen Frost wrote: > >* Heikki Linnakangas (hlinnaka@iki.fi) wrote: > >>1. it's not flexible enough. How do you specify that all READs on > >>super_secret table must be logged, but on less_secret table, it's > >>enough to log only WRITEs? > > > >This is actually what that pg_audit.role setting was all about. To do > >the above, you would do: > > > >CREATE ROLE pgaudit; > >SET pg_audit.role =3D pgaudit; > >GRANT SELECT ON TABLE super_secret TO pgaudit; > >GRANT INSERT, UPDATE, DELETE ON TABLE less_secret TO pgaudit; > > > >With this, all commands executed which require SELECT rights on the > >table super_secret are logged, and all commands execute which require > >INSERT, UPDATE, or DELETE on the less_secret table are logged. >=20 > Ah, I see. Wow, that's really Rube Goldbergian. It's certainly not ideal. It was discussed back in January, iirc. > >>2. GUCs can be changed easily on-the-fly, and configured flexibly. > >>But that's not really what you want for auditing. You want to have a > >>clear specification in one place. You'd want it to be more like > >>pg_hba.conf than postgresql.conf. Or more like Mandatory Access > >>Control, rather than Discretionary Access Control. > > > >I certainly appreciate the MAC vs. DAC discussion here, but I don't > >believe our AUDIT capability should explicitly require restarts of PG to > >be adjusted. >=20 > Sure, I didn't mean we should require a restart. Requiring SIGHUP > seems reasonable though. I wouldn't have any issue with that. > >>A separate config file in $PGDATA would be a better way to configure > >>this. You would then have all the configuration in one place, and > >>that file could have a more flexible format, with per-schema rules > >>etc. (Wouldn't have to implement all that in the first version, but > >>that's the direction this should go to) > > > >The difficulty with a separate config file is that we don't have any way > >of properly attaching information to the existing tables in the > >database- table renames, dropped columns, etc, all become an issue then. >=20 > True. I wouldn't be too worried about that though. If you rename a > table, that hopefully gets flagged in the audit log and someone will > ask "why did you rename that table?". If you're paranoid enough, you > could have a catch-all rule that audits everything that's not > explicitly listed, so a renamed table always gets audited. The general 'catch-all' approach was how we approached pg_audit in general, so, yes, that's the kind of auditing we expect people to want (or, at least, we would need to support it). You're right, in some environments that may be workable, but then it also has to be entirely managed outside of the database, which would make it extremely difficult to use in many environments, if not impossible.. > Of course, you could still support a labeling system, similar to the > pg_audit.role setting and GRANTs. For example, you could tag tables > with a label like "reads_need_auditing", and then in the config > file, you could specify that all READs on tables with that label > need to be audited. I think security labels would be a better system > to abuse for that than GRANT. You'd want to just label the objects, > and specify the READ/WRITE etc. attributes in the config file. Using SECURITY LABELs is certainly an interesting idea. GRANT was chosen because, with it, we also get information regarding the action that the user wants to audit (select/insert/update/delete, etc), without having to build all of that independently with some custom structure in the SECURITY LABEL system. > Who do you assume you can trust? Is it OK if the table owner can > disable/enable auditing for that table? In an ideal world, you would segregate the rights which the table owner has from both the permission system and the audit system. This has come up a number of times already and is, really, an independent piece of work. Having the permissions and auditing controlled by the same group is better than having all three pieces controlled by the ownership role, but having three distinct groups would be preferred. Thanks! Stephen --iC9NPIRsVYcJsJ2l Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJVZwP/AAoJEO1sijiDR2RVpCAQAMJmh7BP0Apg9MCQraAbNNEN o2Z339C76oo0OdxOwU+ynra9oksrBTzKj5oZMYSzJPDsTCARHjF5MjDYbfJg2TQE twjcEiEbg/0akbr6IW9kheJQe9ql8YKNNylbyoXf9rQGX6ld0eoSNxAFa30FOE7f O15xqLd95l82XTT7HdhIwxDML80J6tq+vDNipy9FRfmFMFbKkq2k7XJcl9WBo17+ kIA+NyF7jUNcXY6GScldtnZtYMp9g4ICfWqBe2yEUF//moNAxIDJrlcTAvBzT4EP lQgRVyON7qR6oWwSV6MvGDptVw2YFDWD1ssR02V1HF8ElDnE2AbotRu1FCkReaR1 hmx4slgX1zEa1CRJpP2G8YtSQp8Kh/TwQ5NUJaZRRYPir08xxeOYJ6cTp9hQcZHi +2ITXs09FedlAJypYhg7wcDB2DQOJmAzGpaAbN3aFYLVa/d4Sz3T/myfhF91j7k0 +HO6YGePvEu5GAs7RmqXKLzv0XAnuEY0lngqeQhMg0WS/FBihdagIDbcFFdA88kb pk8bnI+7YwkaBCHKJT7N57ihIJBnXm/vtHLpT10HQ7VwZW2nfzzlsFSZriga69qx UqW+Dj5+ZXqziGx2rl0cx1SckrPWSOFb4O+DSmMDJwtVN+P7tQKFCwQaRPWcrZYd k77GuXkNie33iEzkPyi1 =lyHh -----END PGP SIGNATURE----- --iC9NPIRsVYcJsJ2l--