Skip to content

Hardening PostgreSQL for rConfig

These settings follow the CIS PostgreSQL Benchmark. From V8.5.0, Security Center checks them with rConfig’s own role, read-only; the root server check reads pg_hba.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 = on

No trust lines, and scram-sha-256 instead of md5 or password (server.db.pg_hba):

# TYPE DATABASE USER ADDRESS METHOD
local all postgres peer
local rconfig8 rconfig scram-sha-256
host rconfig8 rconfig 127.0.0.1/32 scram-sha-256
host rconfig8 rconfig ::1/128 scram-sha-256

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.

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.