---
title: "Why Postgres needs better connection security defaults"
description: "Postgres's widely used sslmode=require encrypts connections but never authenticates the server, leaving them open to trivial MITM attacks via a self-signed certificate and DNS poisoning."
url: "https://swe.quest/articles/why-postgres-needs-better-connection-security-defaults-d78d4b6f863ed01c"
canonical: "https://neon.com/blog/postgres-needs-better-connection-security-defaults"
source: "Neon"
published: "2025-06-25"
difficulty: "medium"
kind: "Opinion"
reading_minutes: 8
tags: ["postgres","cryptography","identity-auth","security"]
---

# Why Postgres needs better connection security defaults

A post on [Neon](https://swe.quest/sources/neon.md), published 2025-06-25, 8 min read, Opinion. Original: [https://neon.com/blog/postgres-needs-better-connection-security-defaults](https://neon.com/blog/postgres-needs-better-connection-security-defaults)

## Summary

Postgres's widely used sslmode=require encrypts connections but never authenticates the server, leaving them open to trivial MITM attacks via a self-signed certificate and DNS poisoning. The Postgres 16 option sslrootcert=system should verify servers against system CA roots, but it still fails on Windows because OpenSSL's default verify paths don't include the Windows certificate store, and it initially failed on Docker and several macOS builds. Neon's workaround is SCRAM-SHA-256-PLUS channel binding (channel\_binding=require), where the client signs a hash of the server certificate with password-derived proof, defeating MITM even with rogue CA-issued certs. It works with libpq-based clients but is ignored by most non-libpq drivers. The post argues Postgres should rename require to something like insecure and add a secure default combining verify-full with system roots.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Cryptography](https://swe.quest/tags/cryptography.md) (Security)
- [Identity & auth](https://swe.quest/tags/identity-auth.md) (Security)
- [Security](https://swe.quest/tags/security.md) (Security)

## Prerequisites

- TLS certificates and PKI ([easy posts on Cryptography](https://swe.quest/tags/cryptography.md?difficulty=easy))
- Postgres connection strings ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- MITM attacks

## Keywords

sslmode=require, sslrootcert=system, SCRAM-SHA-256-PLUS, channel binding, libpq, OpenSSL, Neon, psql

## Related posts

- [MITM attacks are easier to avoid with psql (Postgres) 16](https://swe.quest/articles/mitm-attacks-are-easier-to-avoid-with-psql-postgres-16-ea4ca88c3d78880f.md): Neon · 2023-10-05 · Medium · 8 min read · PostgreSQL, Cryptography, Security, Identity & auth
  Postgres 16's psql adds \`sslrootcert=system\`, which uses the OS's trusted CA store and implies \`sslmode=verify-full\`.
- [Shipping psql without psql: a pure-TypeScript Postgres client in neonctl](https://swe.quest/articles/shipping-psql-without-psql-a-pure-typescript-postgres-client-in-neonctl-621e0ac130c536d1.md): Neon · 2026-06-12 · Medium · 7 min read · PostgreSQL, TypeScript, Testing, AI for coding, Developer tools
  neonctl now embeds a pure-TypeScript reimplementation of psql that activates when no native psql is on the PATH.
- [How Does psql -h pg.neon.tech Work?](https://swe.quest/articles/how-does-psql-h-pg-neon-tech-work-b4339dcc3b96f63b.md): Neon · 2024-08-14 · Medium · 3 min read · PostgreSQL, Identity & auth, Networking
  Neon's passwordless \`psql -h pg.neon.tech\` connects to a "Link Proxy", a server that speaks the Postgres wire protocol, rather than to a real Postgres instance.
- [Security Disclosure Recommendation: Rotate PostgreSQL Database Credentials](https://swe.quest/articles/security-disclosure-recommendation-rotate-postgresql-database-credentials-101ad2e32389050e.md): Railway · 2026-10-22 · Medium · 4 min read · PostgreSQL, Security, Identity & auth, Incidents & postmortems
  After Railway's October 21, 2026 security disclosure, PostgreSQL users on the Railway template should regenerate the database password from the Database View, which changes it inside PostgreSQL and updates POSTGRES\_PASSWORD and the variables that reference it in one step.
- [Better Postgres with Prisma Experience](https://swe.quest/articles/better-postgres-with-prisma-experience-595f740758817ccf.md): Neon · 2024-03-07 · Medium · 4 min read · PostgreSQL, Schema migrations, Serverless, TypeScript
  Prisma users on Neon can now use a single pooled Postgres connection string for both serverless queries and schema migrations, replacing separate pooled, direct and shadow database URLs.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
