Hardening PostgreSQL for rConfig
Hardening PostgreSQL for rConfig
Section titled “Hardening PostgreSQL for rConfig”These settings follow the CIS PostgreSQL Benchmark. From V8.5.0, Security Review checks them with rConfig’s own role, read-only; the root server check reads pg_hba.conf.
postgresql.conf
Section titled “postgresql.conf”Usually /var/lib/pgsql/data/postgresql.conf (RHEL) or /etc/postgresql/<version>/main/postgresql.conf (Ubuntu). Reload PostgreSQL afterwards.
# Database on the same server as rConfig (db.bind_address)listen_addresses = 'localhost'
# SCRAM passwords, then reset the rConfig role's password (db.password_hashing)password_encryption = 'scram-sha-256'
# Log schema changes, not every statement (db.statement_logging)log_statement = 'ddl'log_connections = onpg_hba.conf
Section titled “pg_hba.conf”No trust lines, and scram-sha-256 instead of md5 or password (server.db.pg_hba):
# TYPE DATABASE USER ADDRESS METHODlocal all postgres peerlocal rconfig8 rconfig scram-sha-256host rconfig8 rconfig 127.0.0.1/32 scram-sha-256host rconfig8 rconfig ::1/128 scram-sha-256rConfig’s role
Section titled “rConfig’s role”The rConfig role should own the rConfig database and nothing more (db.app_user_privileges). As a superuser:
ALTER ROLE rconfig NOSUPERUSER NOCREATEROLE NOREPLICATION NOBYPASSRLS;SUPERUSER fails the check; CREATEROLE, REPLICATION or BYPASSRLS warn.
A database on another server
Section titled “A database on another server”Set ssl = on on the server and DB_SSLMODE=require (or verify-full with a CA) in rConfig’s .env, then run php artisan config:cache (db.transport_tls). See Encrypted database connections.
db.version_eol warns six months before a PostgreSQL major version reaches end of life.
Standards: CIS PostgreSQL Benchmark, NIST SP 800-53 AC-6, IA-5, SC-7, SC-8.