OLS-2459 enforce TLS security profile on Postgres connections#2921
OLS-2459 enforce TLS security profile on Postgres connections#2921onmete wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
8f96125 to
3c0f55d
Compare
Self-review: Round 1 findings and fixesCritical finding:
|
37787e7 to
7c33c89
Compare
Change the default sslmode from "prefer" to "require" so the service never silently downgrades to cleartext even when the operator config is absent. Add a shared build_ssl_context() helper that constructs an SSLContext with minimum TLS version and cipher restrictions from the configured TLS security profile. Thread the profile through PostgresBase, the cache factory, quota limiter factory, token usage history, and the quota scheduler so every Postgres connection enforces the cluster's TLS policy when configured. Fix the quota scheduler's sslrootcert which was accidentally commented out, leaving it without CA verification. Co-authored-by: Cursor <cursoragent@cursor.com>
7c33c89 to
5a15367
Compare
|
@onmete: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Description
Enforce the cluster's TLS security profile on all Postgres connections
(cache, quota limiters, token usage history, quota scheduler).
This is the service-side half of OLS-2459. The operator-side changes
(APIServer CR propagation) will follow in a separate PR.
Changes
sslmodehardened — changePOSTGRES_CACHE_SSL_MODEfrom"prefer"to"require"so the service never silently downgrades tocleartext, even when the operator config is absent (dev, test, or
misconfiguration scenarios)
build_ssl_contexthelper — new factory inols/utils/ssl.pythatbuilds an
ssl.SSLContextwithminimum_versionand cipher restrictionsfrom the configured TLS security profile. Returns
Nonewhen no profileis set (preserves current behaviour)
PostgresBase.__init__accepts anoptional
tls_security_profileand passes the resultingSSLContextassslcontext=topsycopg2.connect. Threaded through:PostgresCache,RevokableQuotaLimiter,UserQuotaLimiter,ClusterQuotaLimiter,QuotaLimiterFactory,TokenUsageHistory,CacheFactory, andAppConfigconnect()function also buildsand passes an
SSLContextwhen a profile is configuredsslrootcertbug fix — un-commentedsslrootcert=config.ca_cert_pathin the quota scheduler's
connect(), which was accidentally commented out,leaving it without CA verification
Type of change
Related Tickets & Documents
Checklist before requesting a review
Testing
make test-unit)make check-types)make format)build_ssl_contextwith IntermediateType, ModernType, None profile,None profile_type, CA cert path forwarding
PostgresBasewith and without TLS profile (sslcontext presence)connect()with sslrootcert and sslcontext assertionsPOSTGRES_CACHE_SSL_MODE == "require"assertionMade with Cursor