{"id":"GHSA-xxmp-x77j-mc26","aliases":[],"summary":"PostgreSQL backend: documented sslmode=require does not authenticate the server, and sql_tls_ca_file cannot complete a handshake","published_at":"2026-10-13T09:15:47Z","modified_at":"2026-10-13T09:15:47Z","products":[{"slug":"puppet","name":"Puppet / OpenVox","category":"iac"}],"rating":{"severity":"medium","score":6.8,"vector":"CVSS:3.1/AV:A/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N","attack_path":"adjacent","user_interaction":false,"malicious":false},"fix_available":true,"kev":{"listed":false,"ransomware":false},"public_exploit":false,"exploits":[],"priority":6.8,"record_count":1,"vendors":["GitHub"],"details":"Before commit `67902b5b415c`, every PostgreSQL example in the docs and chart used `sslmode=require`, which in pgdriver encrypts the connection but skips certificate verification. The verifying alternative, `sql_tls_ca_file`, failed every handshake because the TLS config never got a `ServerName`. An operator who followed the docs had no working way to authenticate the database through `sql_tls_ca_file`, and each replica reads the CA key over that connection at startup.\r\n\r\nFound in an independent audit at `fb856f1` and re-checked against `main` at `145cb53` with `github.com/uptrace/bun/driver/pgdriver v1.2.18`.\r\n\r\n## Where\r\n\r\nLine numbers are as of `145cb53`, before the fix.\r\n\r\n- `internal/storage/sql.go:252-254` passed `pgdriver.WithDSN(cfg.DSN)`, then added `pgdriver.WithTLSConfig(cfg.TLS)` when any `sql_tls_*_file` was set.\r\n- In pgdriver v1.2.18, the default config has `InsecureSkipVerify: true` (`config.go:67`), and `sslmode=require` without `sslrootcert` keeps it (`config.go:311-313`). That matches libpq's meaning of `require`.\r\n- `WithTLSConfig` replaces the driver's TLS config wholesale (`config.go:125-128`) and runs after `WithDSN`, so any `ServerName` derived from the DSN was lost.\r\n- `loadBackendTLS` (`internal/storage/spec.go:334`) built `&tls.Config{MinVersion: tls.VersionTLS12}` with `RootCAs` but no `ServerName`. pgdriver hands it to `tls.Client` on the open socket (`proto.go:127`), and crypto/tls refuses: \"either ServerName or InsecureSkipVerify must be set\".\r\n- `sslmode=require` examples: `docs/storage-backends.md:651,669`, `docs/helm-chart.md:122`, `charts/openvox-ca/values.yaml:363`, `charts/openvox-ca/ci/postgres-ha-values.yaml:53`. `docs/storage-backends.md:664` presented `require` as the DSN way to get TLS.\r\n\r\nNo test exercised `sql_tls_ca_file` against a real server. MySQL and Redis set or infer `ServerName` and aren't affected.\r\n\r\n## Reproduction\r\n\r\nOn a build before the fix, set `sql_tls_ca_file` to the server's CA and connect to a TLS-enabled PostgreSQL. Startup fails with the crypto/tls error above. With the documented `sslmode=require` DSN instead, the connection succeeds against a server presenting any certificate.\r\n\r\n## Impact\r\n\r\nAn attacker who can get on path on the database network (shared segment, compromised sidecar, cloud network misconfiguration) can impersonate the database. At startup each replica reads `ca_key` (plaintext unless `encrypt_ca_key` is on), the inventory HMAC key, the CRL and every certificate. The attacker can read the CA key, or feed back a forged CRL and inventory.\r\n\r\n## Fix\r\n\r\nFixed on `main` on 2026-10-13 in commit [`67902b5b415c81d7535338c74e73a7f3e2d410fa`](https://github.com/voxpupuli/openvox-ca/commit/67902b5b415c81d7535338c74e73a7f3e2d410fa) (PR #479, closes #475), Go module version `v0.0.0-20261013085950-67902b5b415c`. The PostgreSQL backend now follows libpq: `sslmode` decides how the server is checked, and the `sql_tls_*_file` settings only supply the certificates.\r\n\r\n- `sslmode=verify-full`, with the CA given either as `sslrootcert` in the DSN or as `sql_tls_ca_file`, authenticates the server by chain and host name. `ServerName` is now set from the host actually dialled (the DSN host, `host=`, or `PGHOST`), so `sql_tls_ca_file` completes its handshake.\r\n- `verify-ca`, and `require` with a CA, check the chain only, as libpq does.\r\n- With `sql_tls_*` files set, startup is refused if `sslmode` is `disable`, `allow`, `prefer` or missing, or if the DSN also sets `sslrootcert`, `sslcert` or `sslkey`.\r\n- The docs, chart values and the HA fixture now use `verify-full`, and say plainly that `require` alone does not verify the server.\r\n- `postgres_integration` specs connect through `sql_tls_ca_file`, and refuse a server whose certificate is untrusted or issued for another host.\r\n\r\n## What to do\r\n\r\nMove to a build that includes `67902b5b415c` (2026-10-13 or later), and change any `sslmode=require` DSN to `sslmode=verify-full&sslrootcert=/path/to/ca.pem`, or set `sql_tls_ca_file` with `sslmode=verify-full`.\r\n\r\nUntil you can upgrade, put `sslmode=verify-full&sslrootcert=...` in the DSN and leave the `sql_tls_*` settings unset; earlier builds already authenticate the server that way.","affected_stack":[{"ecosystem":"Go","package":"github.com/voxpupuli/openvox-ca","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"0.0.0-20261013085950-67902b5b415c"}]}],"fixed":["0.0.0-20261013085950-67902b5b415c"],"provider":"github-repo-advisories","source":"GHSA-xxmp-x77j-mc26","relation":"self"}],"affected_other":[],"product_status":[],"records":[{"provider":"github-repo-advisories","source_id":"GHSA-xxmp-x77j-mc26","relation":"self","url":"https://github.com/voxpupuli/openvox-ca/security/advisories/GHSA-xxmp-x77j-mc26","license":"GitHub Terms of Service","published_at":"2026-10-13T09:15:47Z","modified_at":"2026-10-13T09:15:47Z","summary":"PostgreSQL backend: documented sslmode=require does not authenticate the server, and sql_tls_ca_file cannot complete a handshake","details":"Before commit `67902b5b415c`, every PostgreSQL example in the docs and chart used `sslmode=require`, which in pgdriver encrypts the connection but skips certificate verification. The verifying alternative, `sql_tls_ca_file`, failed every handshake because the TLS config never got a `ServerName`. An operator who followed the docs had no working way to authenticate the database through `sql_tls_ca_file`, and each replica reads the CA key over that connection at startup.\r\n\r\nFound in an independent audit at `fb856f1` and re-checked against `main` at `145cb53` with `github.com/uptrace/bun/driver/pgdriver v1.2.18`.\r\n\r\n## Where\r\n\r\nLine numbers are as of `145cb53`, before the fix.\r\n\r\n- `internal/storage/sql.go:252-254` passed `pgdriver.WithDSN(cfg.DSN)`, then added `pgdriver.WithTLSConfig(cfg.TLS)` when any `sql_tls_*_file` was set.\r\n- In pgdriver v1.2.18, the default config has `InsecureSkipVerify: true` (`config.go:67`), and `sslmode=require` without `sslrootcert` keeps it (`config.go:311-313`). That matches libpq's meaning of `require`.\r\n- `WithTLSConfig` replaces the driver's TLS config wholesale (`config.go:125-128`) and runs after `WithDSN`, so any `ServerName` derived from the DSN was lost.\r\n- `loadBackendTLS` (`internal/storage/spec.go:334`) built `&tls.Config{MinVersion: tls.VersionTLS12}` with `RootCAs` but no `ServerName`. pgdriver hands it to `tls.Client` on the open socket (`proto.go:127`), and crypto/tls refuses: \"either ServerName or InsecureSkipVerify must be set\".\r\n- `sslmode=require` examples: `docs/storage-backends.md:651,669`, `docs/helm-chart.md:122`, `charts/openvox-ca/values.yaml:363`, `charts/openvox-ca/ci/postgres-ha-values.yaml:53`. `docs/storage-backends.md:664` presented `require` as the DSN way to get TLS.\r\n\r\nNo test exercised `sql_tls_ca_file` against a real server. MySQL and Redis set or infer `ServerName` and aren't affected.\r\n\r\n## Reproduction\r\n\r\nOn a build before the fix, set `sql_tls_ca_file` to the server's CA and connect to a TLS-enabled PostgreSQL. Startup fails with the crypto/tls error above. With the documented `sslmode=require` DSN instead, the connection succeeds against a server presenting any certificate.\r\n\r\n## Impact\r\n\r\nAn attacker who can get on path on the database network (shared segment, compromised sidecar, cloud network misconfiguration) can impersonate the database. At startup each replica reads `ca_key` (plaintext unless `encrypt_ca_key` is on), the inventory HMAC key, the CRL and every certificate. The attacker can read the CA key, or feed back a forged CRL and inventory.\r\n\r\n## Fix\r\n\r\nFixed on `main` on 2026-10-13 in commit [`67902b5b415c81d7535338c74e73a7f3e2d410fa`](https://github.com/voxpupuli/openvox-ca/commit/67902b5b415c81d7535338c74e73a7f3e2d410fa) (PR #479, closes #475), Go module version `v0.0.0-20261013085950-67902b5b415c`. The PostgreSQL backend now follows libpq: `sslmode` decides how the server is checked, and the `sql_tls_*_file` settings only supply the certificates.\r\n\r\n- `sslmode=verify-full`, with the CA given either as `sslrootcert` in the DSN or as `sql_tls_ca_file`, authenticates the server by chain and host name. `ServerName` is now set from the host actually dialled (the DSN host, `host=`, or `PGHOST`), so `sql_tls_ca_file` completes its handshake.\r\n- `verify-ca`, and `require` with a CA, check the chain only, as libpq does.\r\n- With `sql_tls_*` files set, startup is refused if `sslmode` is `disable`, `allow`, `prefer` or missing, or if the DSN also sets `sslrootcert`, `sslcert` or `sslkey`.\r\n- The docs, chart values and the HA fixture now use `verify-full`, and say plainly that `require` alone does not verify the server.\r\n- `postgres_integration` specs connect through `sql_tls_ca_file`, and refuse a server whose certificate is untrusted or issued for another host.\r\n\r\n## What to do\r\n\r\nMove to a build that includes `67902b5b415c` (2026-10-13 or later), and change any `sslmode=require` DSN to `sslmode=verify-full&sslrootcert=/path/to/ca.pem`, or set `sql_tls_ca_file` with `sslmode=verify-full`.\r\n\r\nUntil you can upgrade, put `sslmode=verify-full&sslrootcert=...` in the DSN and leave the `sql_tls_*` settings unset; earlier builds already authenticate the server that way.","severity":[{"type":"CVSS_V3","score":"CVSS:3.1/AV:A/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N","source":"GHSA-xxmp-x77j-mc26"}],"affected":[{"ecosystem":"Go","package":"github.com/voxpupuli/openvox-ca","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"0.0.0-20261013085950-67902b5b415c"}]}],"fixed":["0.0.0-20261013085950-67902b5b415c"],"provider":"github-repo-advisories","source":"GHSA-xxmp-x77j-mc26","relation":"self"}],"product_status":[],"references":[{"type":"ADVISORY","url":"https://github.com/voxpupuli/openvox-ca/security/advisories/GHSA-xxmp-x77j-mc26"}]}],"references":[{"type":"ADVISORY","url":"https://github.com/voxpupuli/openvox-ca/security/advisories/GHSA-xxmp-x77j-mc26"}],"sources":[{"provider":"github-repo-advisories","source_id":"GHSA-xxmp-x77j-mc26","url":"https://github.com/voxpupuli/openvox-ca/security/advisories/GHSA-xxmp-x77j-mc26","license":"GitHub Terms of Service","modified_at":"2026-10-13T09:15:47Z","relation":"self"}]}
