Why PostgreSQL security hardening needs a plan before the first login
PostgreSQL security hardening is the work of tightening how a self-hosted cluster authenticates users, accepts network connections, encrypts traffic, limits privileges, protects individual rows, records activity and receives patches. A cluster that works but was built with default authentication and broad grants is functional, not hardened, and an audit or customer security review will test exactly those gaps. The plan should be written before anyone changes a live setting, because the hard part is not knowing what to change but changing live behavior without breaking the applications, batch jobs and administrators who already depend on the current setup.
Start by inventorying the current state. Confirm which authentication method each entry in pg_hba.conf uses, which roles still hold passwords stored with MD5, which roles have superuser or broad schema grants, and which clients connect without TLS. Then confirm your major version. PostgreSQL 18 deprecated MD5 password authentication in favor of SCRAM, so a cluster that still relies on MD5 will need a planned migration of role passwords and client drivers. The support window adds urgency: each major version is supported for five years after its initial release, and the dates for each supported version are listed in the PostgreSQL versioning policy. If your cluster runs a version near its end of life, hardening and upgrading should be planned together, since both change the same connection and authentication behavior.
Decide the order of changes early. Authentication and network rules affect every client at once, so they need a rollback path and a test against each application. Privilege reductions and row-level security can silently return empty results or permission errors, so they need test queries that run under the new roles. Auditing and TLS add overhead and configuration that operations teams must own after handover. Ask your provider or internal team to produce a written change list with, for each item, the affected clients, the test that proves it works, and the owner who signs off. Without that list, hardening tends to stall after the first breakage or is rushed before an audit date.
The PostgreSQL settings and features that carry security
Most PostgreSQL security comes from a small set of server settings, authentication rules and database features that interact with each other. Each card names one of them, what it controls and whether changing it needs a reload or a full restart, so your team can review the configuration against its own policy.
Password encryption with SCRAM
The password_encryption setting decides how new passwords are stored. Set it to scram-sha-256 so new role passwords are hashed with SCRAM rather than MD5. PostgreSQL 18 deprecated MD5 password authentication in favor of SCRAM, so existing MD5 roles should be listed and reset during hardening. Changing this setting needs only a reload, but existing passwords keep their old hash until the password is set again.
Client access rules in pg_hba.conf
The pg_hba.conf file decides which hosts, users and databases may connect and which authentication method each connection must use. Reject broad rules such as 0.0.0.0/0 with weak methods, and place specific rules above general ones because the first match wins. Editing this file needs only a reload, but a mistake can lock out administrators, so test changes from a second session before closing the first.
TLS with ssl, certificate and key files
Enable ssl and point ssl_cert_file and ssl_key_file at a certificate and private key issued by your certificate authority. Keep the key readable only by the PostgreSQL service account, and confirm clients verify the server certificate rather than accepting any certificate. Turning on ssl requires a restart, while certificate file changes can be picked up by a reload, so confirm which mode your version and deployment use.
Listening addresses and network exposure
The listen_addresses setting controls which network interfaces PostgreSQL accepts connections on. Bind only to the interfaces your application and replicas need, and combine this with firewall rules and pg_hba.conf so the database is not reachable from untrusted networks. Changing listen_addresses requires a full restart, which should be scheduled with the maintenance window for the cluster.
- Required to change
- Restart
Least-privilege roles and privileges
Create separate roles for schema owners, application logins and read-only reporting, and grant only the privileges each needs. Revoke the default PUBLIC privileges on the public schema where your policy requires it, and avoid giving application logins superuser or CREATEROLE rights. Role and grant changes take effect immediately, so review them in a change record and keep a versioned copy of the grants.
Row-level security policies
Row-level security lets you attach policies to a table so each query returns only the rows a role may see. Enable it with ALTER TABLE ... ENABLE ROW LEVEL SECURITY and write policies that match your data ownership model. Table owners and superusers bypass policies unless forced, so decide whether FORCE ROW LEVEL SECURITY is needed and test each role's visible rows before go-live.
Connection and statement logging
Logging settings such as log_connections, log_disconnections and log_statement create the evidence trail for who connected and what they ran. Balance detail against volume and against the sensitivity of logged data, since statement logs can capture personal data or secrets. Most of these settings take effect on reload, and you should confirm where logs are shipped, how long they are kept and who can read them.
External authentication methods
PostgreSQL supports GSSAPI, LDAP, certificate authentication and, from PostgreSQL 18, the OAuth 2.0 method, so logins can be tied to central identity rather than local passwords. Each method changes how pg_hba.conf entries are written and what the server trusts, so confirm the identity provider's settings and role mapping with your identity team before switching. Certificate and external methods reduce password exposure but add certificate and directory dependencies to plan for.
Which authentication and access decisions to make before changing anything
This table compares the main login and isolation options for a PostgreSQL hardening project, with the operational cost of each. Read it before editing pg_hba.conf, because the choice of login method determines which client drivers, certificate processes and directory dependencies your team must support afterward.
| Decision | When it fits | Operational cost | Confirm before choosing |
|---|---|---|---|
| Password logins with SCRAM | Small estates with few clients, or drivers that cannot use certificates or directory logins yet | Password rotation and secret storage in every client; the MD5 method is deprecated in PostgreSQL 18, so existing MD5 roles need reset | That every client driver and connection pooler in use supports SCRAM |
| Certificates for service accounts | Applications and batch jobs that run unattended and can hold a private key | Issuing, distributing and rotating client certificates; expiry causes outages if not monitored | Your certificate authority process and who owns renewal |
| LDAP or GSSAPI for people | Staff who already log in through a central directory or Kerberos realm | Directory outages block logins; group-to-role mapping must be maintained; some clients need Kerberos configuration | Whether the directory is highly available and who approves group changes |
| OAuth method (PostgreSQL 18) | Organizations standardizing on OAuth 2.0 identity providers and short-lived tokens | Newer method with fewer mature client libraries; token validation and identity provider configuration to test | Client driver support in your stack and the identity provider setup required |
| TLS enforced everywhere | Estates where all clients can negotiate TLS and no plaintext path is acceptable | Certificate management on every server and client; some legacy clients may fail to connect | Which clients cannot negotiate TLS today and whether they can be upgraded |
| hostssl-only rules | Mixed estates where you want remote connections forced onto TLS while local socket access stays available | Rules must be reviewed carefully because a broad host line earlier in pg_hba.conf can still allow plaintext | Ordering of rules in pg_hba.conf and a test that plaintext attempts are rejected |
| Row-level security for tenant isolation | One database and schema shared by many tenants, with policies enforced per row | Policies must be written, tested and kept in step with schema changes; table owners can bypass policies unless configured | Whether the application sets a session identity that policies can rely on |
| Separate schemas or databases per tenant | Strong separation needs, few tenants, or tenants that need independent restores | More objects to migrate, back up and monitor; cross-tenant reporting becomes harder | Number of tenants expected and whether per-tenant restore is a requirement |
How to harden a PostgreSQL cluster in sequence
This sequence moves a PostgreSQL cluster from inherited authentication and broad privileges to a deny-by-default, encrypted, audited and patched configuration. Each step produces evidence you can hand to your security and compliance reviewers.
Inventory roles and pg_hba.conf entries
Your DBA or platform engineer lists every login role, its attributes and its memberships, and every line in pg_hba.conf, with the address range, database, user and method for each. Start with a query against pg_roles to find roles with superuser, createdb or createrole attributes, and record which accounts belong to people, applications or batch jobs. Mark entries that use the trust or MD5 methods for later change. The step is done when the inventory is a reviewed document that every remaining step can reference, and the team agrees on which accounts are still needed.
Confirm SCRAM support in client drivers
Before changing any password method, the application team checks that each client driver, connection library and ORM in use supports SCRAM-SHA-256 authentication. Older drivers or outdated bundled libraries can fail to connect once MD5 is removed, so this check belongs before the cutover. Ask each vendor or check the driver release notes, and test against a non-production copy of the cluster. The check is complete when every application has logged in successfully over SCRAM in a test environment, and the list of exceptions with owners and remediation tasks is written down.
Move passwords to SCRAM
The DBA sets password_encryption to scram-sha-256 in postgresql.conf and reloads the configuration, so new and changed passwords are stored as SCRAM verifiers. Each login role is then given a new password through a secure channel, which replaces its MD5 hash. Because PostgreSQL 18 deprecated MD5 password authentication in favor of SCRAM, this change also prepares the cluster for future releases. The check is a query against pg_authid for rolpassword values, confirming that the prefix SCRAM-SHA-256 is present on every role that holds a password and that no MD5 hashes remain.
Rewrite pg_hba.conf with deny-by-default rules
Replace the inherited file with a rule set that rejects everything first and then permits only named combinations of source network, database, user and method. Use hostssl entries for every remote connection so that traffic is encrypted, keep local socket access restricted to the operating system accounts that need it, and remove trust entries entirely. Place the most specific rules above broader ones, because PostgreSQL uses the first matching line. The check is a deliberate failed login: connect from an address or user not listed and confirm the server rejects the attempt, then reload and confirm the expected accounts still connect.
Enable TLS with a managed certificate chain
The platform or security team issues a server certificate from your internal or public certificate authority, including the full chain, and points ssl, ssl_cert_file, ssl_key_file and ssl_ca_file at those files in postgresql.conf. Set a minimum TLS protocol version that your policy requires and restrict the private key file to the PostgreSQL service account. Plan renewal before expiry and record the owner of the process. The check is a client connection that requires TLS and shows an encrypted session, plus a connection attempt with a non-matching or untrusted certificate that the server or client rejects. Confirm the exact parameter names against the version you run.
Restrict roles with a documented grant matrix
Using the inventory, the DBA creates group roles for each function, such as read-only reporting, application read-write, schema migration and administration, and grants privileges to those groups rather than to individuals. Revoke default PUBLIC privileges on the public schema where they are not needed, remove superuser from application accounts, and limit ownership of objects to a dedicated owner role. The grant matrix, a table of roles against schemas, tables and functions with the privileges each holds, is stored with the change record. The check is a query against pg_roles and information_schema table privileges that matches the matrix exactly, with no unexpected superuser or CREATE rights left.
Add row-level security where scoping is required
Where one database holds records for several tenants, business units or data classifications, the developer enables row-level security on the relevant tables with ALTER TABLE ... ENABLE ROW LEVEL SECURITY and writes policies that compare each row with a session or role attribute. Confirm that the application sets that attribute on every connection, and decide whether table owners are exempt. Row-level security is not needed for every table, so document which tables are covered and why. The check is a test in which two sample accounts query the same table and each sees only its own rows, along with a query against pg_policies that lists every expected policy.
Turn on connection and DDL audit logging
The DBA sets log_connections and log_disconnections in postgresql.conf and selects a log_line_prefix that records time, user, database and client address. Auditing of data definition changes and privileged activity usually relies on an extension such as pgAudit, which needs its own installation and review, so confirm its availability and compatibility with your version before adopting it. Route logs to a central store with retention that your policy defines. The check is a login and a schema change generated in a test session, followed by confirmation that both entries appear in the central log with the expected user and timestamp.
Set a minor-release patch routine
The platform team subscribes to PostgreSQL minor release announcements and sets a recurring review, because minor releases arrive at least once every three months and include security fixes. A minor update replaces executables and requires a restart, and it does not change the storage format, so the routine covers staging first, a documented maintenance window, a rollback plan and a post-update connection test. Track the version against the support end dates for your major release. The check is a recorded run of the routine in which SHOW server_version confirms the target minor version on every node, and the change record is filed for auditors.
How hardening changes break applications and how to avoid it
Most PostgreSQL hardening changes do not break the database. They break the applications that connect to it, and they usually break at connection time. Moving password storage from MD5 to SCRAM, forcing TLS with hostssl rules, and tightening pg_hba.conf all reject clients that do not meet the new rule. The failures appear as authentication errors or refused connections, often in older drivers that only speak MD5 or do not negotiate TLS, and often in connection pools that hold credentials or sessions created before the change. Before you change anything, inventory the client libraries, driver versions and pooler settings in use, because the server will not tell you which of them are affected until a rejected login happens.
Row-level security fails in a different way. When a policy is enabled on a table, queries from roles that the policy applies to return only the rows the policy allows, and nothing in the application reports that rows were filtered out. A report can show fewer customers, a batch job can skip records, and a count can drop without an error. Test RLS with the same application roles that run in production, compare row counts against a known baseline, and check whether table owners or roles with BYPASSRLS were expected to see more data than they now do. Be aware that table owners bypass policies unless the table is set to force RLS, so confirm that behavior in your own environment.
Stage each change where you can observe it. A parallel listener on a new port, or a test cluster restored from a recent backup, lets you point a copy of the application at the hardened settings and watch what fails without affecting production traffic. During staging and after cutover, read the server log for rejected connections, which record the user, database, client address and reason. Plan the activation method too: some settings take effect on a configuration reload, while others, such as changes to shared_preload_libraries and certain connection or memory parameters, need a restart. Confirm which applies to each change in the PostgreSQL documentation for your version, schedule restarts with the application owners, and keep the previous pg_hba.conf ready for a quick rollback.
What drives the effort in a PostgreSQL hardening project
Hardening effort rarely comes from PostgreSQL configuration alone. It grows with how many applications connect, how many roles and grants exist, how sensitive the data is, and how many environments must match. Each driver below can be measured before a quote is written, and most can be reduced by inventory and standardization.
Number of applications and drivers
Every application, batch job, reporting tool and admin client that connects needs its own login path, password method and TLS setting. Connection counts and driver versions decide whether SCRAM and TLS can be enforced everywhere in one change or must be phased. Reduce this by inventorying connections from server logs for several weeks before scoping, so unused or forgotten clients are found early and retired rather than hardened.
- Current major release
- 18
Number of roles and grants
Roles inherited through group membership, default privileges and schema-level grants multiply quickly in databases that grew without a model. Each distinct access pattern adds review and testing work. Reduce this by defining a small set of role templates, such as read-only, read-write and migration owner, and mapping people and services onto them rather than granting privileges one object at a time.
Row-level security on large tables
Row-level security is needed when one table holds data for several tenants, business units or classification levels. Policies on large tables add planning cost and must be tested against real query patterns, since a poorly written policy can slow every read. Decide per table whether a view, a separate schema or a policy is the right boundary, and benchmark the busiest queries with policies enabled before rollout.
External directory integration
If logins must come from a central directory, the work includes choosing the method (LDAP, GSSAPI, certificates or the OAuth method in PostgreSQL 18), mapping directory groups to database roles, and handling accounts that leave the organization. Ask whether the directory team will provide a service account and test accounts before scoping begins, because that access often sets the schedule.
Compliance evidence requirements
Auditors often ask for documented configuration, audit log retention, access reviews and proof of patching on the minor release cadence. The volume of evidence depends on which control frameworks apply and how often reviews must repeat. Confirm the exact evidence list with your assessor early, and agree who owns recurring tasks such as quarterly access reviews. DeployOpen prepares evidence for assessments but does not issue audit reports.
Number of environments
Development, test, staging and production usually need the same authentication rules, TLS setup and role model, and each must be verified separately. Drift between environments is a common source of rework. Reduce effort by defining hardening as configuration that is applied from one source to every environment, and by keeping a single checklist that is run in each one before sign-off.
How hardening differs for single nodes, HA pairs and air-gapped sites
A single PostgreSQL server has one pg_hba.conf, one set of TLS files and one place where roles are defined, so the hardening work is the most contained. The main risk is that every change requires a restart or reload, and a configuration mistake can lock out administrators or applications until someone fixes it on the host. Planning changes around a maintenance window is the core operational concern.
- Simpler
pg_hba.conf: One file governs all client access, so rules can be reviewed in a single pass and ordered from most specific to least specific. - Restart windows: Settings such as
ssland some authentication-related parameters need a restart, so batch them and schedule them with the application owners. - Local recovery path: Keep console or out-of-band access to the host before you tighten
pg_hba.conf, so a bad rule can be reverted. - Minor release restarts: Applying a minor release replaces executables and requires a restart, so bundle security patching with the same window where possible.
Before you change anything, confirm which settings need a reload and which need a restart, and test the new rules from a client host that matches production.
With streaming replication, a primary and one or more hot standbys each run their own copy of the server configuration. Hardening applied only to the primary leaves a standby reachable in ways the primary is not, and a failover can promote a server that was never reviewed. Consistency across nodes becomes the main control objective, and replication traffic becomes an access path that needs its own rules.
- Same controls on every node: Apply the same
pg_hba.conflogic, TLS settings and role definitions to the primary and every standby. - Named replication sources: Allow replication connections only from the named standby hosts, and use a dedicated replication role instead of a superuser.
- Matching certificates: Keep server certificates, CA bundles and their renewal dates aligned across nodes, so a promoted standby does not fail clients or change trust.
- Drift checks: Compare configuration files and role lists across nodes after every change, because a standby may have been rebuilt from an older configuration.
After each change, confirm that replication still connects over the intended rules, then test a switchover in a non-production environment. Failover tooling is a separate subject and is outside the scope of this page.
In an air-gapped site, the server cannot reach public certificate authorities, package repositories or external log services, so each of those dependencies must be supplied locally. Hardening depends on an internal trust chain, a controlled way to bring patches in, and logs that stay inside the enclave while still being reviewable. The team carries more of the logistics that a connected site would handle automatically.
- Internal certificate authority: Issue and rotate server and client certificates from an internal CA, and document how revocation and renewal are handled without external lookups.
- Offline patch media: Download minor release packages and their checksums outside the enclave, verify them, then transfer them through an approved media process. Track which patch level each node runs.
- Local log shipping: Send connection and audit logs to a collector inside the enclave, and confirm that retention and access controls match your policy.
- Local documentation: Keep copies of the PostgreSQL documentation and your hardening baseline inside the enclave, so administrators can check settings without internet access.
Confirm with your security team how media transfers are approved and logged, and test one full patch cycle on a staging enclave before relying on it in production.
Secrets, certificates and access controls to lock down
A PostgreSQL deployment is only as locked down as the accounts, key files, configuration secrets and copies of data around it. The cards below cover the controls that most often drift after the first install, so a review can check each one on the running system.
Superuser lockdown and admin accounts
Keep the postgres superuser out of daily use. Give administrators named accounts with only the privileges their job needs, and reserve superuser for break-glass use with logging. Check which roles hold superuser, createrole and createdb, and whether application services ever connect as a superuser. Ask the vendor or your DBA to show the query used to list them.
Certificate private key permissions
The server private key used for TLS must be readable only by the operating system account that runs PostgreSQL, and it should not sit in a world-readable directory or in the data directory copied into backups. Confirm the file owner, group and mode on the running host, and check that key files are not committed to repositories or shared in tickets. Rotate keys when staff with access leave.
Passwords in configuration management
Playbooks, Helm values and environment files often carry database passwords in plain text. Store role passwords in a secrets manager or an encrypted vault, inject them at deploy time, and keep them out of version control and logs. Confirm that password-setting tasks do not echo values into job output, and that rotation can run without redeploying the application.
The postgres operating system account
The operating system account that owns the database files and runs the server should have no interactive login, no sudo rights and no membership in unrelated groups. Its home directory and data directory should be owned by that account and no one else. Verify this on each host, since administrators often log in as this account during maintenance and leave shells behind.
Restricting the network listener
Set listen_addresses to only the interfaces that clients need, rather than leaving the default that may expose every address. Pair this with firewall rules and pg_hba.conf entries that name the allowed client networks. Replication and monitoring hosts should appear in their own rules. Confirm the open ports from outside the database network, not only from inside the host.
Backups and WAL archives
Base backups and archived WAL files contain the same data as the live cluster, including password hashes and any data that row-level security would hide from a role. Encrypt them at rest, restrict who can read or restore them, and store copies where the production admin accounts cannot silently delete them. Ask for the access list and the retention settings, and test that a restore works under the same controls.
How to prove the hardening works and fails safely
Each hardening control needs a test that tries to break it, and the test should be run against the production-like cluster before sign-off. Start with a SCRAM login that succeeds for a current application role, then confirm that a role still carrying an MD5 password is refused or forced to reset its password before it can log in. Next, attempt a plain TCP connection from an allowed client network to a database whose pg_hba.conf entry requires hostssl, and confirm the server rejects it. Each test should record the exact role, client address, method and the server's response, because a reviewer will want to see the denial as well as the success.
Row-level security needs its own test, since a policy that looks correct on paper can still leak rows. Connect as a low-privilege role assigned to one tenant and attempt to read rows that belong to another tenant, including through views and simple joins. Then confirm the audit trail captures the events that matter: denied authentication attempts, denied queries and DDL statements such as a role change or a table alteration. Finally, apply a patched minor release to a staging copy, restart it, and confirm it starts cleanly and that the hardened settings still apply. Confirm the exact logging parameters and audit extension behavior for your chosen version in the official documentation before writing test expectations.
Store results as dated, signed-off records: the test ID, the command or script used, the expected outcome, the actual output, the tester and the configuration version tested. Keep the pg_hba.conf and TLS settings under version control so each record points to a specific file revision. A failed test is also evidence, provided it has a fix and a retest that passes. DeployOpen prepares this evidence for compliance assessments, but it does not issue audit reports, attestations or certifications. An independent auditor or certification body makes that determination, so ask your assessor in advance which evidence format they expect.
What to monitor, patch, log and document after hardening
This table assigns each post-hardening control to an owner, a review rhythm and the evidence to keep. Read it as an operating calendar: the items that lapse most often are minor release routines, certificate rotation and pg_hba.conf change review. The main takeaway is that hardening decays without named owners, so agree these assignments before go-live.
| Control | Owner and review rhythm | What to keep as evidence |
|---|---|---|
| Failed authentication and connection sources | Platform or DBA team, reviewed on a set schedule agreed in the runbook | Server log extracts showing failed logins, source addresses and alert history |
| Log retention and review | Security operations with DBA support, retention period set by the organization's policy | Retention configuration, log access records and sign-off on periodic reviews |
| Quarterly minor release routine | DBA team, applied in each minor release window (releases arrive at least every three months) | Installed version records, change tickets and restart confirmations |
| Support end dates for versions 14 to 18 | Platform owner, tracked against the published versioning policy | Dated upgrade plan showing when each cluster leaves support (14 ends November 12, 2026) |
| Certificate expiry and rotation | Security team issues, DBA team installs; confirm the schedule with your certificate authority policy | Certificate inventory with expiry dates and rotation records |
| Role and pg_hba.conf change control | Security approver and DBA author; review each change request before reload | Versioned pg_hba.conf and role definitions, approval records and periodic access recertification |
| Runbook for hardening and incident response | Platform owner, updated after each change or test; confirm review frequency internally | Current runbook, dated revision history and results of restore and failover drills |
Questions teams ask before hardening PostgreSQL
Can our own team harden PostgreSQL without outside help?
Yes, many teams do, provided someone on the team owns the database configuration and can test changes before they reach production. The work is mostly configuration and access design: authentication rules in pg_hba.conf, TLS settings, role and privilege design, auditing and a patching routine. The harder parts are usually knowing which application clients will break under stricter settings, and having a tested rollback. Teams without a DBA, or with a small platform group handling many systems, often bring in a partner for the review and the first pass, then keep the routine in-house. Ask yourself who will read the audit logs, approve minor releases and maintain the role model after the engagement ends, because that ongoing ownership is where in-house efforts usually stall.
What drives the cost and effort of a PostgreSQL hardening project?
The main drivers are the number of clusters, the number of applications and client types connecting to them, and how much of the current access model has to change. Effort rises when clients still use MD5 password authentication, when roles are shared between applications, when there is no existing inventory of who connects from where, or when row-level security must be retrofitted into schemas that were not designed for it. Cost is paid mostly as analyst and DBA time, plus test environment and change-window coordination. Some work is one-time, such as the baseline review and role redesign. Some recurs, such as minor release patching, log review and access recertification. Ask any provider for a quote that separates these two groups and lists which clusters, applications and environments are included.
How long does PostgreSQL hardening take for a typical scope?
Duration depends on scope rather than on a fixed template. A single cluster with a few well-documented applications is a much smaller piece of work than a fleet of clusters with undocumented connections and shared accounts. The schedule is shaped by discovery (finding every client and login path), by application testing for authentication changes, and by the change windows your operations team allows. Read-only assessment can usually be scoped separately from remediation, which lets you decide on remediation after seeing the findings. Ask any provider to state the phases, the environments used for testing, and which dependencies on your side could pause the work.
What does our team need to provide before hardening starts?
Four inputs make the difference between a smooth engagement and a stalled one:
- An inventory of clusters, versions and hosts, including which PostgreSQL versions are still in support according to the PostgreSQL versioning policy
- A list of applications, batch jobs and administrators that connect, with the accounts and authentication methods each one uses
- Change windows agreed with operations, plus an emergency rollback owner
- A test environment that mirrors production authentication, network paths and client driver versions, along with named application owners who can run their own regression tests
Ask the provider to confirm each of these in the written scope, and to say what happens if an input arrives late.
Will moving from MD5 to SCRAM break our client applications?
It can, and that is the main reason to test before changing anything. PostgreSQL 18 deprecated MD5 password authentication in favor of SCRAM, so SCRAM is the direction to plan for. Breakage usually comes from older client libraries, drivers or connection poolers that do not support SCRAM, or from application connection strings that never get updated. The safe sequence is to inventory which accounts still authenticate with MD5, confirm driver support in a test environment, set new passwords stored as SCRAM verifiers, and only then change the authentication rule in pg_hba.conf. Keep a documented fallback until every client has been verified. Confirm the exact behavior for your PostgreSQL version and driver stack against the PostgreSQL authentication methods documentation.
Does hardening PostgreSQL make an audit pass?
No. Hardening reduces risk and produces evidence, but a passing result depends on the auditor's scope, the framework being assessed and the controls the organization can demonstrate over time. Only independent auditors and certification bodies issue audit reports or certifications. What a hardening engagement can do is prepare the database side of the evidence: documented authentication rules, TLS configuration, role and privilege mappings, audit logging settings, patch records and access reviews. Ask your compliance lead which control requirements apply to the database, and map each one to a configuration or a log source before the engagement starts. Any provider that promises a pass is overstating what technical work can deliver.
How should we handle patching on the minor release cadence?
PostgreSQL publishes minor releases at least once every three months, and minor releases do not change the internal storage format. Updating means replacing executables and restarting the server, so it is a routine operational change rather than a data migration. The effort lies in tracking releases, testing them against your environment, and scheduling restarts, especially for clusters with replicas. Security fixes can arrive in a minor release, so the hardening plan should define who watches the release notes, how quickly a fix is assessed and which change window applies. Major versions have a limited support period, so confirm the end-of-life dates for your current version when you plan the routine, and check the PostgreSQL versioning policy for current dates.
Can row-level security be added to an existing schema safely?
Usually yes, but it needs careful design and testing. Row-level security policies filter rows based on the connected role or session context, so every query path, view and application role must be checked. Common problems include table owners bypassing policies unexpectedly, policies that slow queries because they are not indexed, and application code that assumes all rows are visible to a shared account. Start by identifying tables that hold sensitive rows and the roles that legitimately need them, then test policies with representative application queries before enabling them in production. Ask any provider to show how they will test each policy against real application paths, not only against simple select statements.
How client connections pass through the hardened trust boundaries
A client or application connection starts outside the database network and must cross TLS before PostgreSQL reads anything else. The server then checks pg_hba.conf to decide which connection type, database, user and authentication method apply, and SCRAM or certificate authentication confirms the identity. Once a session is open, role privileges and row-level security policies limit which rows and operations succeed, and the audit log records the attempt. The primary and its standbys sit inside the protected boundary, so every path to data crosses these checks. Confirm each step in your own environment, because the exact pg_hba.conf rules and audit settings are yours to define.
Connection path through TLS, authentication, role checks, row-level security and audit logging.
How DeployOpen scopes, hardens and hands over PostgreSQL security work
DeployOpen plans, implements, hardens, documents and supports self-hosted PostgreSQL inside your own infrastructure, including your cloud accounts, data centers or air-gapped networks. Each PostgreSQL security engagement starts from a written scope so your security, compliance and database teams know what changes, what evidence is produced and who owns each control afterward.
How we scope
- Inventory every PostgreSQL version, cluster, client application and login path in scope before any setting changes.
- Agree in writing which authentication methods, TLS settings, role model and audit controls the engagement covers.
- Confirm the minor release process, maintenance windows and the owner who approves each restart or patch.
How we build
- Move password logins from MD5 to SCRAM and review every pg_hba.conf rule for scope and address ranges.
- Configure TLS for client and replication connections, then test certificate validation and rotation procedures.
- Design least-privilege roles and row-level security policies, and test them against real application queries in a staging copy.
How we hand over
- Deliver configuration files, role and policy definitions, and audit logging settings as version-controlled artifacts.
- Provide a findings report with fixes applied, open items and retest results for each hardening control.
- Walk your operations team through the patching runbook for minor releases, which do not change the storage format.
How we support
- Offer ongoing support, minor release application and periodic retesting as a retainer after handover.
- Plan the move from PostgreSQL versions near end of life, using the support dates in the versioning policy.
- Ask any partner to confirm the support scope, response expectations and evidence format before signing.

