Repository navigation
Closed
Labels
P2Medium priority / Parity & RefactoringMedium priority / Parity & RefactoringbugSomething isn't workingSomething isn't workingconnectionsDatabase connections, URI parsing, poolsDatabase connections, URI parsing, poolscoreCore library logic and servicesCore library logic and servicesstabilityTheme parser epic label: stabilityTheme parser epic label: stability
Description
Summary
In PostgresConnection (lib/core/database/postgres_connection.dart, lines 46–60, 187–212):
SslMode postgresResolveSslMode({
SslMode? uriSslMode,
required bool encrypt,
required bool hasRootCert,
}) {
if (uriSslMode != null) return uriSslMode;
if (!encrypt && !hasRootCert) return SslMode.disable;
if (hasRootCert) return SslMode.verifyFull;
return SslMode.require;
}When a user enables SSL (useSSL == true) without uploading a custom sslrootcert file:
_buildSettings()keepssecurityContext = null.postgresResolveSslModedefaults toSslMode.require.- In
postgres3.5.x,SslMode.requiredisables CA root verification and disables hostname verification (onBadCertificate: (cert) => true). Traffic is encrypted, but open to Man-in-the-Middle (MITM) interception on untrusted networks (public Wi-Fi, compromised routers, cloud VPC gateways). - Furthermore, the standard Postgres connection form does not expose
sslmode(require,verify-ca,verify-full), preventing users from configuring strict certificate validation against system CAs.
Problem Details
- Cloud providers (AWS RDS, Supabase, Neon, GCP Cloud SQL) provide certificates signed by public CAs or installed system roots.
- Even when connecting to these secure cloud endpoints with "Enable SSL" turned on, MITM attacks are possible because
SslMode.requireignores certificate trust chains. - As noted in
postgres_connection.dart: "requiredoes not check the CA — MITM is possible." - When
uriSslMode == SslMode.verifyFullis passed via URL query withoutsslRootCert,_buildSettings()still leavessecurityContext = null, rather than usingSecurityContext(withTrustedRoots: true).
Scope
- In
PostgresConnection._buildSettings(), whenuseSSLorverifyFull/verifyCais enabled without a custom root cert, initializeSecurityContext(withTrustedRoots: true)so system root CAs are available. - Expose
sslmodeoption (require,verify-ca,verify-full,disable) in the connection configuration and URL parser. - Add unit tests verifying
SecurityContextandSslModeresolution for various SSL configurations.
Out of Scope
- SSH tunnel encryption (already covered in
SshTunnelManager).
Metadata
Metadata
Assignees
Labels
P2Medium priority / Parity & RefactoringMedium priority / Parity & RefactoringbugSomething isn't workingSomething isn't workingconnectionsDatabase connections, URI parsing, poolsDatabase connections, URI parsing, poolscoreCore library logic and servicesCore library logic and servicesstabilityTheme parser epic label: stabilityTheme parser epic label: stability
Activity
ZhuchkaTriplesix commentedon Oct 11, 2026
Done in #1386 (merged into
dev).