It feels weird to me that this blog post would suggest acquiring Let's Encrypt certificates for certificate encryption. While it's great for something public facing that needs your CA installed by default, creating certificates for things that you probably don't want being public - like your database backend - just makes it more discoverable. For example, certificate transparency logs mean that anybody can see what c…
Securing a Postgres Database
71–80 of 104 posts
Re: Securing a Postgres Database
#72Earlier quoted context omitted.
The worst of both worlds: not accessible from the outside, yet insecure because it’s accessible to any user on the inside. What is the advantage of listening on localhost compared to using a socket, with free access control?
> What is the advantage of listening on localhost compared to using a socket, with free access control? Can install and use right away locally without figuring out where your distro puts the socket at. Edit: Also no need to play with permissions of the socket in such a case.
Re: Securing a Postgres Database
#73>By default, PostgreSQL listens on a TCP port 5432. This post seems to outright state that by default postgres is listening to everyone via TCP for connection. This is not true. Unless you edit pg_ident.conf, your postgres install will not listen for connections outside of on localhost. So, while it's correct to say that it listens to TCP port 5432, there is a very narrow limit to whom it's listening for. Namely, the…
Re: Securing a Postgres Database
#74>By default, PostgreSQL listens on a TCP port 5432. This post seems to outright state that by default postgres is listening to everyone via TCP for connection. This is not true. Unless you edit pg_ident.conf, your postgres install will not listen for connections outside of on localhost. So, while it's correct to say that it listens to TCP port 5432, there is a very narrow limit to whom it's listening for. Namely, the…
https://github.com/postgres/postgres/blob/master/src/backend...
Re: Securing a Postgres Database
#75Earlier quoted context omitted.
The worst of both worlds: not accessible from the outside, yet insecure because it’s accessible to any user on the inside. What is the advantage of listening on localhost compared to using a socket, with free access control?
Modern linux security thinking is that any sort of code running inevitably leads to root privilege. Put another way, any user can become root through privilege escalation, so access control is pointless, since any untrusted user can take over the machine. The real unit of security is the whole OS (VM), not its internal user boundaries.
Also, the loopback is used as a networking interconnect or guest->host channel for sandboxed containers and VMs, so it's security sensitive in this way.
Re: Securing a Postgres Database
#76Earlier quoted context omitted.
Stored procedures are really not used enough. They’re incredibly useful, and not just for security. People can make out-of-band updates to the query, like making it more efficient or migrating it, without requiring any changes to the all.
I have an impression that many developers actively avoid stored procedures, trigger or any 'complex' database features because they don't fit well into a typical CI/CD pipeline which deals only with application code. It is quite possible to test stored procedures, it's just requires some additional work/infrastructure.
Re: Securing a Postgres Database
#77>By default, PostgreSQL listens on a TCP port 5432. This post seems to outright state that by default postgres is listening to everyone via TCP for connection. This is not true. Unless you edit pg_ident.conf, your postgres install will not listen for connections outside of on localhost. So, while it's correct to say that it listens to TCP port 5432, there is a very narrow limit to whom it's listening for. Namely, the…
I've checked postgres repository and default has been to listen on localhost for at least 15 years. https://github.com/postgres/postgres/blob/master/src/backend...
Re: Securing a Postgres Database
#78Earlier quoted context omitted.
When used for business logic they also execute about 20x faster than the same logic encoded in a client, and in far fewer LOC. Getting rid of all those round-trips has a huge effect!
Running a slow hash operation that should take a non-negligible amount of CPU on your single core per process database server isn’t a great idea. That’s not a rag on stored procedures more generally. Just that specific use case scales poorly to a large number of operations as its inherently cpu bound.
Re: Securing a Postgres Database
#79Earlier quoted context omitted.
I've checked postgres repository and default has been to listen on localhost for at least 15 years. https://github.com/postgres/postgres/blob/master/src/backend...
To be super clear, because it can be less than perfectly obvious, this means on `localhost` but also on loopback. There is no 'real' network device talking to this port.
IE; the 'postgres' unix user is required to access databases as the 'postgres' database user.
Re: Securing a Postgres Database
#80>By default, PostgreSQL listens on a TCP port 5432. This post seems to outright state that by default postgres is listening to everyone via TCP for connection. This is not true. Unless you edit pg_ident.conf, your postgres install will not listen for connections outside of on localhost. So, while it's correct to say that it listens to TCP port 5432, there is a very narrow limit to whom it's listening for. Namely, the…
I saw nobody mentioning Docker here, so just a reminder: If you do `-p 5432:5432`, there is no different than listening `0.0.0.0`.