-
Notifications
You must be signed in to change notification settings - Fork 614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove upstream-breaking REVOKE CONNECT * FROM public #1616
base: main
Are you sure you want to change the base?
Conversation
The default installation of Pg allows public to connect - given proper pg_hba entries. The REVOKE subltely breaks expected usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to understand why it was even there, but it's ancient code. 1175ea2 is the earliest version where it was introduced. After that it was only minor stylistic changes or moving it around. Given that's 12 years old I wonder if it was a workaround for something.
Do you have any idea?
Yup. I looked at its origin as well. The commit doesn't lend itself to understanding why it was introduced. The comment in the code makes it seem like it is for "security" purposes. I suppose in theory it is more secure, but in practice I'm dubious of its security related benefits. Nevertheless, it deviates from upstream defaults and makes things more challenging when working with folks who don't know that this REVOKE is altering things. I know this would be a backwards incompatible change, but I'd vote for merging the PR. |
Any idea what it will take to get this PR merged? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You signed the CLA (IIRC you didn't when I last looked) and we can ignore the mend check. Not sure if I've ever seen that green.
Reading up on this (https://www.red-gate.com/simple-talk/databases/postgresql/postgresql-basics-roles-and-privileges/) tells me that in PostgreSQL < 15 any user could CREATE
objects if they had CONNECT
permissions. You can also (including >= 15) read schema information. As such I think this change has security implications.
Because of that I'd at the very least treat this as a breaking change. Even better if we can figure out why it breaks. My reading is that it should work and perhaps there's another solution that maintains the hardening
Hello @ekohl
Good to know.
There is still the pg_hba that affects whether users can login and what they can login to. The article reference above does state: """ Also, the default upstream is to allow connect to public. Nevertheless, I agree that merging this commit would be a breaking change, which you state below.
What do you mean by "figure out why it breaks"? Are you talking about the module before my commit - which revokes connect and breaks what upstream ships? or are you talking about post-merge of my commit, which would be a breaking change for the module? Either way, I thought we knew "why" it is 'breaking'. Also, what do you mean by "it should work"? I thought it was obvious why it didn't work. Thanks for filling in the gaps for me. Cheers, -m |
I'd like to know how it breaks.
If you could provide any details or even better, a reproducer where something relies on the |
Ah. Yes. I am trying to create read-only admins on for my Pg server to be able to view any database and corresponding objects in any database:
and I've got the following command being exec'ing via psql in puppet:
and I've got the correct pg_hba entry to allow local login. But I cannot connect to any of the databases on the system that were created with puppet (due to the REVOKE). However, if I manually create a database, I can connect and perform read-only operations on the data. The Pg users mailing list helped debug the disconnect between what I was trying to do and what reality was: |
I still like the hardening it provides so perhaps we should clearly document the behavior and how to deal with it if needed. |
If we're relying on this REVOKE because bad actors are connecting to the DB and:
...then the users of this puppet module have far greater security policies to implement. This isn't even considering that the bad actor(s) would have to be allowed access in the HBA, too. The breakage from upstream defaults is of more concern for admins who want to leverage this module. Either way, perhaps we can add an attribute:
to the defined type. Thus allowing admins to turn off the revoking if so desired. Thanks, -m |
The default installation of Pg allows public to connect - given proper pg_hba entries. The REVOKE subltely breaks expected usage.
Summary
Provide a detailed description of all the changes present in this pull request.
Additional Context
Add any additional context about the problem here.
Related Issues (if any)
Mention any related issues or pull requests.
Checklist
puppet apply
)