Free audit

View Audit Scope
PostgreSQL Security Audit · CIS · pgaudit · RLS · RBACSCRAM-SHA-256 · Row-Level Security · TLS 1.3 · SOC 2 / HIPAA

PostgreSQL Security Audit & Compliance Hardening.

We audit and harden production PostgreSQL estates across self-managed Linux, Kubernetes, AWS RDS/Aurora, Google Cloud SQL, and Azure Flexible Server. Our senior PostgreSQL architects deliver CIS Benchmark & RBAC privilege reviews, pg_hba.conf & SCRAM-SHA-256 lockdown, high-performance Row-Level Security (RLS), and targeted pgaudit compliance logging for SOC 2, HIPAA, PCI-DSS, and ISO 27001.
  • CIS PostgreSQL Benchmark
  • pg_hba.conf & SCRAM-SHA-256
  • Row-Level Security (RLS) & RBAC
  • pgaudit session & object logging
  • TLS 1.3 & KMS / CMEK encryption
  • SOC 2 · HIPAA · PCI-DSS evidence

postgresql-security-posture

4 security & compliance tracks we audit

pg_hba.conf & SCRAM-SHA-256

ok

Eliminate legacy md5/trust rules, enforce hostssl + SCRAM-SHA-256 or cloud IAM tokens, and lock down CIDR rules.

Explore details

Includes executable SQL diffs for zero-downtime privilege and TLS hardening.

P1 Incident Response
15 minutes

Under a 24x7 support agreement for security & availability incidents

Authentication & TLS
SCRAM-SHA-256 + TLS 1.3

Eliminate legacy MD5 hashes, non-SSL connections, and broad CIDRs

Access & Isolation
Least-Privilege + RLS

Role hierarchy separation, PUBLIC lockdown, and indexed tenant RLS

Audit & Compliance
pgaudit + CIS Benchmark

Targeted DDL, role, and PII audit trails without runaway log bloat

Selected clients

  • Innoviti
  • Blitz
  • Freecharge
  • Nango
  • Recochain
  • Screen Facts
  • Nexora
  • WeCredit

01 · High-Risk Findings We Uncover in Production PostgreSQL

Six PostgreSQL security gaps we close cleanly.

Passing a cloud infrastructure scan does not mean your database catalog is secure. Most PostgreSQL vulnerabilities live inside role grants, legacy pg_hba.conf rules, unforced RLS policies, and unredacted query logs.

Security Finding / ExposureArchitectural Root CauseJusDB Engineering Remediation
Applications connect using shared superuser or rds_superuser credentialsEarly-stage services used the bootstrap postgres or cloud admin account for both schema migrations and runtime CRUD traffic, leaving runtime pods able to bypass Row-Level Security (BYPASSRLS) and drop tables.Separate migration owner roles (NOSUPERUSER, NOLOGIN group role) from least-privilege runtime application roles (SELECT, INSERT, UPDATE, DELETE only) with zero connection downtime.
Legacy md5 password hashes or permissive host rules in pg_hba.confClusters upgraded from PostgreSQL 10-13 kept password_encryption = md5 or left pg_role.rolpassword entries hashed with MD5 alongside broad 0.0.0.0/0 non-SSL host rules.Switch password_encryption = 'scram-sha-256', rotate all role hashes via staged dual-credential cutovers, and enforce hostssl rules with minimum TLSv1.2 / TLSv1.3.
Row-Level Security (RLS) policies silently bypassed or causing 10x query slowdownsTables have ENABLE ROW LEVEL SECURITY without FORCE ROW LEVEL SECURITY (allowing table owners to bypass policies), or RLS policy expressions invoke volatile functions that prevent index usage.Audit pg_class (relrowsecurity and relforcerowsecurity), and rewrite RLS predicates using stable (SELECT current_setting('app.tenant_id', true)) subplans so PostgreSQL uses B-tree indexes.
Plaintext PII and credentials leaked into PostgreSQL and CloudWatch/GCP logsEnabling log_statement = 'all' or broad pgaudit logging with log_parameter = on writes raw customer PII, payment tokens, and password strings into log sinks.Configure object-scoped pgaudit (via pgaudit.role = 'auditor_watch') on sensitive tables only, disable parameter value logging on auth paths, and enforce log redaction rules.
SECURITY DEFINER functions and PUBLIC schema grants allow privilege escalationPrior to PostgreSQL 15, the PUBLIC pseudo-role held CREATE privileges on schema public, and SECURITY DEFINER functions lacking an explicit SET search_path are vulnerable to object shadowing.Revoke CREATE ON SCHEMA public FROM PUBLIC across all databases, and audit pg_proc for SECURITY DEFINER functions to pin SET search_path = pg_catalog, public.
Unencrypted pg_dump / pgBackRest backups or readable snapshot bucketsProduction EBS/PD disks are encrypted, but logical dumps or WAL archives are shipped to S3/GCS buckets without server-side KMS encryption, bucket policies, or pgBackRest cipher passphrases.Enforce AES-256-CBC client-side encryption in pgBackRest alongside KMS/CMEK bucket policies, and restrict backup bucket IAM roles to write-only from database nodes.

02 · Security Audit & Hardening Workstreams

Defense-in-depth across six PostgreSQL security layers.

We combine CIS PostgreSQL Benchmark rigor with production DBA pragmatism so security hardening never breaks application connection pools or degrades p99 query latency.

01

CIS PostgreSQL Benchmark Assessment

We evaluate your self-managed, Kubernetes, or cloud-managed PostgreSQL clusters against the CIS PostgreSQL Benchmark across installation, file permissions, logging, authentication, and runtime flags.

  • Control-by-control CIS pass/fail scorecard with SQL verification evidence
  • Tailored assessment profiles for AWS RDS/Aurora, Cloud SQL, Azure, and CNPG
  • Prioritized remediation scripts ranked by exploitability and operational impact
CIS Benchmark · pg_settings · pg_file_settings · Cloud Security Posture
PostgreSQL Consulting
02

RBAC Least-Privilege & Role Hierarchy Refactoring

We untangle organic permission sprawl, replacing shared superuser accounts with a clean three-tier role model (schema_owner, app_rw, analytics_ro) and default privileges.

  • Complete audit of pg_roles, pg_auth_members, and table/schema ACL grants
  • ALTER DEFAULT PRIVILEGES standardization so new tables inherit clean grants
  • Removal of PUBLIC schema creation rights and SECURITY DEFINER search_path traps
pg_roles · pg_auth_members · ALTER DEFAULT PRIVILEGES · SECURITY DEFINER
PostgreSQL Remote DBA
03

Row-Level Security (RLS) Design & Performance Tuning

Multi-tenant SaaS applications rely on PostgreSQL Row-Level Security to isolate tenant data. We audit RLS correctness and optimize policy expressions so queries stay fast.

  • Verification of ENABLE + FORCE ROW LEVEL SECURITY and BYPASSRLS role flags
  • Index-friendly RLS policy rewrites eliminating per-row current_setting() evaluations
  • PgBouncer transaction-pooling compatibility using SET LOCAL tenant context
pg_policies · relrowsecurity · relforcerowsecurity · SET LOCAL
PostgreSQL Performance Tuning
04

pgaudit Engineering & SIEM Log Pipelines

Compliance auditors require verifiable trails of DDL changes, role grants, and access to sensitive tables. We configure pgaudit without flooding your disks or log bills.

  • Session auditing (pgaudit.log = 'ddl, role') combined with object-level auditing
  • PII and credential redaction across log_min_duration_statement and pgaudit
  • Structured CSV/JSON log shipping to Datadog, Splunk, Panther, or CloudWatch/GCP
pgaudit · pgaudit.role · log_destination = csvlog/jsonlog · SIEM
Read our pgaudit Compliance Playbook
05

Authentication, TLS 1.3 & Network Isolation

We harden how clients and replication standbys authenticate to PostgreSQL, eliminating plaintext connections and weak password hashes across every entrypoint.

  • pg_hba.conf lockdown with hostssl, clientcert=verify-full, and SCRAM-SHA-256
  • AWS IAM Auth, GCP Cloud SQL IAM Auth, and Microsoft Entra ID token setups
  • TLS 1.3 cipher enforcement across PostgreSQL, PgBouncer, and HAProxy
pg_hba_file_rules · SCRAM-SHA-256 · TLS 1.3 · IAM / Entra ID Auth
PgBouncer TLS & Auth Pooling
06

SOC 2, HIPAA, PCI-DSS & ISO 27001 Evidence Package

Preparing for an external security audit or enterprise customer questionnaire? We produce auditor-ready technical evidence and remediation attestations.

  • Encryption at-rest (KMS/CMEK/LUKS) and backup encryption verification
  • Point-in-Time Recovery (PITR) and access revocation test evidence
  • Automated SQL compliance checks wired into your CI/CD or monitoring stack
AWS KMS · Cloud KMS · Azure Key Vault · pgBackRest AES-256
PostgreSQL Managed Support

03 · Compliance Mapping & Incident Response Targets

Mapping PostgreSQL controls to SOC 2, HIPAA & P1-P4 response.

We translate high-level regulatory requirements into concrete PostgreSQL catalog states and configuration parameters, backed by published incident response targets.

Security Control DomainPostgreSQL Technical MechanismCompliance FrameworksJusDB Engineering Deliverable
Authentication & Password Cryptographypassword_encryption = 'scram-sha-256', pg_hba_file_rules, Cloud IAM / Entra IDSOC 2 CC6.1 · PCI-DSS v4.0 Req 8 · CIS 3.1 / 6.2Staged MD5-to-SCRAM rotation script + zero-trust pg_hba.conf / IAM policy
Least-Privilege Authorization & Tenant IsolationRBAC role hierarchy, REVOKE ALL ON SCHEMA public, Row-Level Security (RLS)SOC 2 CC6.3 · HIPAA 164.312(a) · GDPR Art. 32Role permission matrix, RLS policy test suite, and SECURITY DEFINER lockdown
Audit Trail & Privileged Action Loggingpgaudit (session DDL/ROLE + object auditor role), log_connections, jsonlogSOC 2 CC7.2 · PCI-DSS v4.0 Req 10 · HIPAA 164.312(b)Tuned pgaudit configuration + SIEM filter rules with PII redaction
Encryption In-Transit & At-Restssl = on, ssl_min_protocol_version = 'TLSv1.3', rds.force_ssl, KMS/CMEKSOC 2 CC6.7 · PCI-DSS v4.0 Req 4 · HIPAA 164.312(e)pg_stat_ssl verification report + TLS enforcement across poolers and standbys
Published Severity Response Targets

P1 to P4 response targets for ongoing PostgreSQL security & DBA support

Our engineering team is in India; business-hours coverage is Mon–Fri 09:00–18:00 IST (UTC+5:30), and 24x7 on-call is available under your service agreement. Standard business-hours coverage runs 03:30–12:30 UTC.

P1 · Critical15 minutes

Production database down, primary unreachable, data corruption risk, or active failover event.

P2 · High30 minutes

Severe latency spike, replication lag climbing rapidly, connection exhaustion, or degraded HA node.

P3 · Medium60 minutes

Non-critical slow query regression, staging issue, backup warning, or replication check alert.

P4 · Low90 minutes

Configuration question, index advisory, planned schema review, or general operational request.

Initial-response targets, not resolution guarantees. The target for your engagement is set in your service agreement. JusDB's security practices are aligned with ISO 27001 and SOC 2 Type II, and JusDB is pursuing both certifications (see Terms, section 12). Review SLA & legal terms.

04 · Interactive Security Hardening Lifecycle

Walk through a PostgreSQL security audit and hardening rollout.

Inspect how we take a PostgreSQL cluster from legacy MD5 passwords and over-privileged roles through zero-downtime SCRAM-SHA-256 and TLS 1.3 rotation into a verified RLS and pgaudit compliance posture.

pg-sec-audit · 3-Stage Hardening Progression

Select a phase to inspect audit queries, remediation SQL, and metrics

Application and routing

Initial security scan reveals legacy MD5 password hashes, non-SSL client connections, over-permissive PUBLIC schema grants, and zero object-level audit logging on PII tables.

Active

    Initial security scan reveals legacy MD5 password hashes, non-SSL client connections, over-permissive PUBLIC schema grants, and zero object-level audit logging on PII tables.

    05 · Representative Production Deliverable

    Privilege, pg_hba_file_rules, TLS & pgaudit verification SQL.

    Every security audit delivers copy-pasteable verification and remediation SQL. Below is an excerpt from our audit diagnostic script inspecting superuser/BYPASSRLS roles, pg_hba_file_rules, unencrypted connections, and pgaudit.log coverage. For a deeper dive into audit logging, read our pgaudit PostgreSQL compliance guide.

    postgresql-cis-and-pgaudit-verification.sql

    -- 1. Audit roles with SUPERUSER, CREATEROLE, CREATEDB, or BYPASSRLS privileges
    SELECT
        rolname,
        rolsuper,
        rolcreaterole,
        rolcreatedb,
        rolbypassrls,
        rolcanlogin,
        rolconnlimit
    FROM pg_roles
    WHERE rolname NOT LIKE 'pg_%'
      AND (rolsuper OR rolcreaterole OR rolcreatedb OR rolbypassrls)
    ORDER BY rolsuper DESC, rolname;
    
    -- 2. Inspect active pg_hba.conf rules for insecure 'trust', 'password', or 'md5' methods
    SELECT
        line_number,
        type,
        database,
        user_name,
        address,
        netmask,
        auth_method,
        options
    FROM pg_hba_file_rules
    WHERE auth_method IN ('trust', 'password', 'md5')
       OR type = 'host'; -- Flag non-SSL host rules (prefer 'hostssl')
    
    -- 3. Detect live unencrypted client connections or weak TLS protocol versions
    SELECT
        a.usename,
        a.application_name,
        a.client_addr,
        s.ssl,
        s.version AS tls_version,
        s.cipher,
        count(*) AS connection_count
    FROM pg_stat_ssl s
    JOIN pg_stat_activity a ON a.pid = s.pid
    WHERE a.backend_type = 'client backend'
    GROUP BY a.usename, a.application_name, a.client_addr, s.ssl, s.version, s.cipher
    ORDER BY s.ssl ASC, connection_count DESC;
    
    -- 4. Verify Row-Level Security (RLS) enforcement and pgaudit settings
    SELECT
        n.nspname AS schema_name,
        c.relname AS table_name,
        c.relrowsecurity AS rls_enabled,
        c.relforcerowsecurity AS rls_forced
    FROM pg_class c
    JOIN pg_namespace n ON n.oid = c.relnamespace
    WHERE c.relkind = 'r'
      AND n.nspname = 'public'
    ORDER BY c.relrowsecurity ASC, c.relname;
    
    SELECT name, setting
    FROM pg_settings
    WHERE name IN ('password_encryption', 'ssl', 'ssl_min_protocol_version', 'pgaudit.log', 'pgaudit.role');

    06 · Ways to Work Together

    Fixed-scope security audit, turnkey hardening, or ongoing compliance DBA.

    Engage our senior PostgreSQL security architects for a standalone CIS & compliance audit, hands-on remediation execution, or retained managed DBA coverage under a 24x7 support agreement.

    Comprehensive AssessmentRecommended

    CIS & Compliance Security Audit

    A deep-dive technical audit of your PostgreSQL authentication, RBAC roles, RLS policies, TLS/KMS encryption, and pgaudit logging mapped to CIS, SOC 2, HIPAA, and PCI-DSS.

    Included in scope

    • Control-by-control CIS Benchmark pass/fail scorecard
    • Executable SQL & Terraform remediation scripts
    • Auditor-ready attestation report & walkthrough call
    Hands-On RemediationHands-On Remediation

    Turnkey Hardening & RLS Engineering

    We implement the security fixes directly with your team: migrating MD5 to SCRAM-SHA-256 or IAM auth, refactoring RBAC roles, tuning RLS policies, and deploying pgaudit.

    Included in scope

    • Zero-downtime SCRAM-SHA-256 & TLS 1.3 rollout
    • Least-privilege role split (migration owner vs runtime)
    • Index-optimized multi-tenant RLS & pgaudit deployment
    Retained OperationsRetained Operations

    Managed Compliance & Remote DBA

    Continuous security posture monitoring, quarterly access reviews, CVE minor/major patching, and monthly backup restore verification.

    Included in scope

    • P1 response in 15 minutes under a 24x7 support agreement
    • Quarterly RBAC, pg_hba.conf & pgaudit compliance reviews
    • Scheduled CVE patching & encrypted PITR restore drills

    Procurement and security

    Ready for legal and security review.

    Mutual NDA before any access, least-privilege credentials in your vault, and security controls aligned with ISO 27001 and SOC 2 Type II.
    • Mutual NDA before any access
    • Named individual accounts only
    • Read-only access by default
    • ISO 27001 & SOC 2 Type II: aligned, certification in progress
    • Mutual NDA before any access

      We sign a mutual NDA before viewing schemas, logs, slow-query captures, or cloud topology.

    • Least-privilege, named credentials

      Engineers connect through your bastion, VPN, or SSM using named accounts with read-only permissions by default.

    • Change control & approval gates

      Production DDL, parameter changes, and failovers follow your change-management workflow with rollback steps prepared first.

    • Named leadership & direct escalation

      Engagements are led by named senior database reliability engineers in India with direct Slack, Teams, and PagerDuty channels.

    07 · Frequently Asked Questions

    PostgreSQL security audit & compliance FAQs.

    Technical answers on pgaudit log volume control, MD5-to-SCRAM migration, Row-Level Security with PgBouncer, and CVE-2018-1058.

    Still have a question?

    Ask it on a scoping call. No production access needed.

    Book a 30-min scoping call (opens Google Calendar in a new tab)

    What is included in a JusDB PostgreSQL Security Audit?

    Our PostgreSQL Security Audit inspects six layers of your database estate: (1) Authentication and pg_hba.conf rules (SCRAM-SHA-256 vs legacy MD5/trust, IAM/Entra ID token auth); (2) RBAC privilege hierarchies, superuser exposure, PUBLIC schema grants, and SECURITY DEFINER search_path safety; (3) Row-Level Security (RLS) policy correctness and performance; (4) In-transit TLS 1.2/1.3 and at-rest KMS/LUKS + backup encryption; (5) pgaudit and logging configuration including PII redaction; and (6) OS, container, or cloud parameter group alignment with the CIS PostgreSQL Benchmark.

    How do you enable pgaudit without generating terabytes of expensive log noise?

    Setting pgaudit.log = 'all' in production logs every single SELECT and INSERT statement, which quickly saturates disk I/O and explodes CloudWatch, GCP Cloud Logging, or Datadog bills. Instead, we configure session auditing strictly for schema and privilege changes (pgaudit.log = 'ddl, role') and pair it with pgaudit's Object Auditing mode (pgaudit.role = 'pii_auditor'), granting that marker role permissions only on high-sensitivity PII, financial, or credential tables.

    How do we migrate from MD5 to SCRAM-SHA-256 password encryption without breaking live apps?

    PostgreSQL allows MD5 and SCRAM-SHA-256 password hashes to coexist during a transition window. First, we verify that all client drivers (libpq, pgjdbc, node-postgres, pgx) and PgBouncer versions support SCRAM-SHA-256; second, we set password_encryption = 'scram-sha-256' in postgresql.conf while keeping pg_hba.conf set to scram-sha-256 (which still permits existing MD5 hashes in PostgreSQL 14+ or uses staged CIDR rules); third, we rotate role passwords so pg_authid stores SCRAM-SHA-256 verifiers; and finally, we confirm zero remaining 'md5%' entries in pg_authid.

    Does Row-Level Security (RLS) work with PgBouncer in transaction pooling mode?

    Yes, provided session context is scoped to the transaction rather than the connection. If an application sets tenant context via session-level SET app.tenant_id = '...', transaction pooling will leak that setting across pooled requests or break isolation. We refactor application middleware to execute SET LOCAL app.tenant_id = '...' inside each transaction block, ensuring tenant context automatically resets at COMMIT or ROLLBACK.

    Why do Row-Level Security policies sometimes slow down PostgreSQL queries by 10x or more?

    When an RLS policy writes USING (tenant_id = current_setting('app.tenant_id')::uuid), PostgreSQL may evaluate current_setting() for every candidate row or treat security barrier views as optimization fences. Wrapping the session lookup in a scalar subquery, such as USING (tenant_id = (SELECT current_setting('app.tenant_id', true)::uuid)), allows the planner to evaluate the tenant ID once as an InitPlan constant and drive a fast B-tree Index Scan.

    Why is CVE-2018-1058 (PUBLIC schema and SECURITY DEFINER search_path) still a major risk?

    On databases created before PostgreSQL 15 (or migrated via pg_dump/pg_upgrade without ACL cleanup), the PUBLIC pseudo-role still holds CREATE privileges on the public schema, allowing any unprivileged user to create trojan functions or operators that intercept queries executed by superusers or SECURITY DEFINER functions. We audit every database ACL and function definition to close this privilege escalation vector.

    Do you remediate the findings you uncover, or just hand over a PDF report?

    We are hands-on PostgreSQL engineers, not checkbox auditors. Alongside the formal CIS & compliance audit report, we author the exact SQL scripts, pg_hba.conf rules, Terraform parameter diffs, and PgBouncer configurations required to fix every finding, and we can execute the hardening changes directly during your maintenance windows.

    What response targets apply if we engage JusDB for ongoing security and DBA support?

    Initial-response targets are 2 to 4 hours during covered business hours, Mon–Fri 09:00–18:00 IST (UTC+5:30). Where your service agreement includes 24x7 on-call, the initial-response target for P1 incidents is 15 minutes. Targets are not resolution guarantees. Our engineering team is in India; business-hours coverage is Mon–Fri 09:00–18:00 IST (UTC+5:30), and 24x7 on-call is available under your service agreement. Initial-response targets, not resolution guarantees. The target for your engagement is set in your service agreement.

    Preparing for SOC 2, HIPAA, PCI-DSS, or an enterprise security review?

    Harden your PostgreSQL estate with senior database engineers.

    Speak directly with a senior PostgreSQL security architect to scope a CIS Benchmark review, RBAC & RLS refactoring, or pgaudit rollout.

    Direct with a senior engineer · No sales handoff · Our engineering team is in India; business-hours coverage is Mon–Fri 09:00–18:00 IST (UTC+5:30), and 24x7 on-call is available under your service agreement.

    Explore all PostgreSQL services

    Need a different PostgreSQL service? Browse our complete offerings.