CommitFest 7151 Review: Let OpenSSL auto-select DH parameters by default

code-review · generated from canonical Markdown

Type
code-review
Source
postgresql-master
Slug
commitfest-7151-review
Tags
code-reviewcommitfest-7151patch-reviewpostgresqlssl
Updated
2026-10-08T06:26:01.368753+00:00
Verdict / Summaryready-for-committer
Front matter
schema: review-report-v2
target: "Let OpenSSL auto-select DH parameters by default (CommitFest 7151)"
base: 061065e28f086e3e2d7191a7785b9f218b7976d8
head: 061065e28f086e3e2d7191a7785b9f218b7976d8
verdict: ready-for-committer
blocker_counts:
  verified: 0
  unverified: 0
scope_identity: diff-1c2869e3213b098446abf57bfafbf7556a6b2fd4e474c534293ce4da57ddec08
model: glm-5.2:cloud

CommitFest 7151 Review: Let OpenSSL auto-select DH parameters by default

Patch: "Let OpenSSL auto-select DH parameters by default" by Peter Eisentraut Message-ID: 953bceb7-340d-4717-9682-0ebe65c4b57e@eisentraut.org Thread-ID: 653832 (2026-08-11) Verdict: ready-for-committer Blockers: 0 verified, 0 unverified

Patch Summary

The patch removes the hardcoded 2048-bit DH parameter blob (FILE_DH2048, RFC 3526 MODP group) from src/include/libpq/libpq-be.h, removes the load_dh_buffer() helper from src/backend/libpq/be-secure-openssl.c, and rewrites initialize_dh() so that when ssl_dh_params_file is empty it calls SSL_CTX_set_dh_auto(context, 1) instead of falling back to the compiled-in blob. The "Ephemeral DH" section of README.SSL is removed, and the ssl_dh_params_file docs are updated to mark the parameter obsolescent and cross-reference ssl_groups for TLS 1.3.

Notable behavior change: When ssl_dh_params_file is set but loading fails during reload, the code no longer falls back to built-in params — it returns false (keeping the old SSL context). The author identifies this as a bugfix.

Changed files:

Verification Summary

FindingSeverityClassStatusRepair
SEC-1BLOCKERsecurityrefutednot-applicable-refuted
PATCH-1MINORdocsverifiedpassed
SEC-2MINORsecuritycannot-verify (design choice)waived
SEC-3MINORsecuritycannot-verify (net improvement)waived
PATCH-2MINORdocsverifiedpassed
PATCH-3NITmaintainabilitycannot-verify (pre-existing)waived
SEC-4NITdocsverifiedpassed
PATCH-5NITtestscannot-verify (pre-existing gap)waived

SEC-1 (BLOCKER) — REFUTED: The security reviewer claimed SSL_CTX_set_dh_auto() is not available in LibreSSL, breaking the build on a documented-supported platform. This claim is false: the official LibreSSL ssl.h header (verified from the libressl/openbsd GitHub repository) defines both SSL_CTRL_SET_DH_AUTO (118) and SSL_CTX_set_dh_auto(ctx, onoff) as a preprocessor macro wrapping SSL_CTX_ctrl, identical to OpenSSL's definition. The macro is always available when <openssl/ssl.h> is included in both OpenSSL >= 1.1.0 and LibreSSL >= 3.4. No #ifdef guard or configure probe is needed, consistent with how PostgreSQL uses other macro-based OpenSSL APIs.

Repair Validation Summary

Three verified findings have concrete repair patches that were validated by apply-check, compile, and static inspection:

  1. PATCH-1 (stale GUC long_desc): Update guc_parameters.dat line 2801 to replace "compiled-in default parameters" with "SSL library selects the DH parameters." Build-validated.
  2. PATCH-2 (docs wording): Replace "well-known DH parameters" with "appropriate DH parameters" in config.sgml line 1690. Applies cleanly.
  3. SEC-4 (stale comment): Replace misleading comment in load_dh_file() at line 1523. Build-validated.

Four findings (SEC-2, SEC-3, PATCH-3, PATCH-5) are cannot-verify with typed safety waivers — they are design choices, net improvements, or pre-existing conditions that require no code fix.

Changed-Code Coverage

Coverage requirement: Required (1 instrumentable C file changed) Measurement lane: host-disposable (fresh gcov counter epoch) Test suite: make installcheck PG_TEST_EXTRA=ssl in src/test/ssl — all 4 TAP tests passed (450 tests)

Coverage Metrics

MetricValue
Changed executable lines11
Covered changed lines1
Uncovered changed lines10
Structural uncovered0
Changed branches10
Covered changed branches1
Lines without coverage coordinates0

Coverage rate: 1/11 changed executable lines (9.09%)

Covered changed line

Uncovered regions

Region A (lines 2097-2112): ssl_dh_params_file-set path — coverable-now

Region B (lines 2120-2124): SSL_CTX_set_dh_auto failure path — infeasible-with-reason

Uncovered branches

9 uncovered branches on changed lines:

Touched functions

FunctionLinesEnteredChanged?
initialize_dh2089-2129Yes (1117 calls)Yes (rewritten)
load_dh_file1517-1574No (0 calls)No (unchanged)

Non-instrumentable changes

COV-* finding determination

No COV-* finding warranted. The uncovered lines are either a pre-existing test gap (the ssl_dh_params_file-set path was equally untested before the patch) or infeasible defensive error checks. The patch's core new behavior (SSL_CTX_set_dh_auto at line 2118) is covered.

Security Review

The security review identified one BLOCKER (SEC-1, refuted) and three MINOR/NIT findings:

No memory-safety defects found in the new DH ownership/free paths. DH_free is correctly called on both success and failure paths in the ssl_dh_params_file-set branch. The SSL_CTX_set_dh_auto path allocates no DH* object.

Test Gap Analysis

No existing tests exercise ssl_dh_params_file or DH parameter loading in any form. The 450 SSL TAP tests (001_ssltests.pl, 002_scram.pl, 003_sslinfo.pl, 004_sni.pl) do not set ssl_dh_params_file. This is a pre-existing gap, not introduced by the patch. The new SSL_CTX_set_dh_auto default path is exercised by every SSL test connection (count=1117).

Thread Reconciliation

Status: no-thread-found

The original patch email (953bceb7-340d-4717-9682-0ebe65c4b57e@eisentraut.org, Thread-ID 653832, 2026-08-11) was found in the imported mail archive. No replies or review messages were found in the thread. All findings are dispositioned as new.

Provenance

SeatModelHandoff slug
pg-patch-reviewerglm-5.2:cloudcommitfest-7151-review-handoff-patch
pg-security-reviewerglm-5.2:cloudcommitfest-7151-review-handoff-security
pg-finding-verifierglm-5.2:cloudcommitfest-7151-review-handoff-verifier
pg-change-coverage-reviewerglm-5.2:cloudcommitfest-7151-review-handoff-coverage

Deterministic Verdict

Verdict: ready-for-committer

Recommended actions before commit:

  1. Update guc_parameters.dat long_desc for ssl_dh_params_file (PATCH-1)
  2. Change "well-known" to "appropriate" in config.sgml (PATCH-2, optional)
  3. Update stale comment in load_dh_file() (SEC-4)