Re: pgaudit - an auditing extension for PostgreSQL

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, MauMau <maumau307(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <bruce(at)momjian(dot)us>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Ian Barwick <ian(at)2ndquadrant(dot)com>
Subject: Re: pgaudit - an auditing extension for PostgreSQL
Date: 2015-01-22 00:05:55
Message-ID: 54C03EE3.6080303@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 1/21/15 5:38 PM, Stephen Frost wrote:
> * Jim Nasby (Jim(dot)Nasby(at)BlueTreble(dot)com) wrote:
>> On 1/20/15 9:01 PM, Stephen Frost wrote:
>>> * Jim Nasby (Jim(dot)Nasby(at)BlueTreble(dot)com) wrote:
>>>>> +1. In particular I'm very concerned with the idea of doing this via roles, because that would make it trivial for any superuser to disable auditing. The only good option I could see to provide this kind of flexibility would be allowing the user to provide a function that accepts role, object, etc and make return a boolean. The performance of that would presumably suck with anything but a C function, but we could provide some C functions to handle simple cases.
>>> Superusers will be able to bypass, trivially, anything that's done in
>>> the process space of PG. The only possible exception to that being an
>>> SELinux or similar solution, but I don't think that's what you were
>>> getting at.
>>
>> Not if the GUC was startup-only. That would allow someone with OS access to the server to prevent a Postgres superuser from disabling it.
>
> That is not accurate.
>
> Being startup-only won't help if the user is a superuser.

Crap, I thought postgresql.auto.conf was handled as an #include and therefore you could still preempt it via postgresql.conf

>>> I certainly don't think having the user provide a C function to specify
>>> what should be audited as making any sense- if they can do that, they
>>> can use the same hooks pgaudit is using and skip the middle-man. As for
>>> the performance concern you raise, I actually don't buy into it at all.
>>> It's not like we worry about the performance of checking permissions on
>>> objects in general and, for my part, I like to think that's because it's
>>> pretty darn quick already.
>>
>> I was only mentioning C because of performance concerns. If SQL or plpgsql is fast enough then there's no need.
>
> If this is being done for every execution of a query then I agree- SQL
> or plpgsql probably wouldn't be fast enough. That doesn't mean it makes
> sense to have pgaudit support calling a C function, it simply means that
> we need to find another way to configure auditing (which is what I think
> I've done...).

I'm still nervous about overloading this onto the roles system; I think it will end up being very easy to accidentally break. But if others think it'll work then I guess I'm just being paranoid.
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2015-01-22 00:50:02 Re: pgaudit - an auditing extension for PostgreSQL
Previous Message Andrew Dunstan 2015-01-21 23:51:34 jsonb, unicode escapes and escaped backslashes