Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have a single postgres database, with two users; Alice and Bob.

I would like to be able to do a NOTIFY alice_channel 'sensitive data' without Bob being able to sneakily LISTEN in just by guessing that the channel name is 'alice_channel'.

In practice the channel names are very hard to guess, but this is security through obscurity at best.

Am I correct in believing that there is no way to prevent a database user from using (abusing) LISTEN & NOTIFY? i.e. there does not appear to be any associated privileges that can be granted or revoked.

Is this a dead end?

share|improve this question
    
I don't know of a way to exclude users from listening. But if you pick a name for the channel like you would pick a secure password, wouldn't this do the job? –  Erwin Brandstetter May 18 '13 at 22:37
    
Yeah, that's what I'm doing at the moment (using large random strings), but it feels dirty and is rather limiting. There are some pretty cool things I could do with LISTEN/NOTIFY if I could lock it down a bit. As it stands it's a rather course-grained "poke a client to re-poll for all the data you 'might' need" feature. –  Chris Farmiloe May 18 '13 at 23:04
    
I just wanted to know if things have changed since this was answered. Were you able to implement something? –  Phill Pafford Aug 1 at 18:22

1 Answer 1

up vote 2 down vote accepted

There are no permissions on LISTEN and NOTIFY. It would not have made sense to have any until support for notify payloads was introduced in more recent versions.

If you want access control, create a table with the information that you want and then send a NOTIFY that's empty or has nothing but a primary key for that table in it. SELECT the row(s) of interest from the table, which can have access control, to get the sensitive data. This used to be the only way to use LISTEN and NOTIFY to send specific data before payloads were added.

share|improve this answer
    
Thanks Craig I thought as much. I might take a peek at the source and see how hard it will be to implement but I'm guessing it will require a completely new database level AclMode and pg_database_aclcheck call somewhere, it's been a while since I've looked :/ –  Chris Farmiloe May 19 '13 at 15:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.