Skip to content

SEC-04: Connections to CNPG do not verify the server #91

Closed

Description

@ephico2real2

Part of #13

What is wrong: With the default CloudNativePG database, the api, worker and migrate containers read CMAPI_DATABASE_URL from key uri of Secret cmapi-db-app. No file in deploy/manifests sets sslmode for that connection, so libpq uses its default, sslmode=prefer. prefer does not verify the server's certificate or name, and it can fall back to plaintext.

Where: deploy/manifests/components/cmapi/20-api.yaml:52 and :87, and 30-worker.yaml:49 and :84, in env for CMAPI_DATABASE_URL. The lines exist at ecc5cb3. An external server is not affected in the same way: docs/12-existing-postgresql.md gives a URI with sslmode=verify-full and sslrootcert.

How to prove it: On a kind cluster with CNPG:

  1. pg_stat_ssl shows ssl = t for the api, worker and migrate connections.
  2. With a CA that does not cover the server, each container refuses to connect and does not fall back to plaintext.
  3. Both checks fail before the fix.

deploy/kind-test.sh holds the pg_stat_ssl check of the migrate connection today (line 107). The test of check 2 is new, in deploy/kind-test.sh, not written yet.

Measured or inferred: Measured on PostgreSQL 16 (PR #89 review): PGSSLROOTCERT with a CA that does not cover the server makes sslmode=prefer fall back to plaintext silently. PR #89 removes that variable from the migrate container for this reason (ruling 4 in docs/reviews/2026-11-05-pr89/README.md). That change does not add verification. The tracker records the later kind result: the migrate connection gives pg_stat_ssl True TLSv1.3. H1, H2 and H4 of the fix are PLAUSIBLE until the kind proof K1 runs (HANDOVER-AND-RESUME.md).

Severity: Medium. The connection has a weak control, with no direct loss. An attack needs a position inside the cluster network.

What must hold after the fix: Each container connects to CNPG with sslmode=verify-full against CNPG's CA, from Secret <cluster>-ca. Each container refuses to connect without TLS.

Research: Not complete. The record of the stopped work is docs/reviews/2026-11-06-pr112/night/91/.

Solution: Not complete. Branch fix-cnpg-verify-full holds a work-in-progress commit 920b938, and night/91/91-on-top-of-wip.patch continues it. Nothing is proven. OB1-PROMPT.md decides that this fix lands before the first CRC run.

Class: INV. The fix adds server verification, a control that the connection never had.

Activity

  1. ephico2real2 commented on Nov 6, 2026

    @ephico2real2
    OwnerAuthor

    Unfinished work on branch fix-cnpg-verify-full. The implementer was stopped to save tokens, at the owner's request, during its kind proof, so nothing here is proven. Parked until Wave 1 is on CRC.

  2. added 4 commits that reference this issue on Nov 6, 2026
  3. added
    In-Progress
    bug
    on Nov 13, 2026
  4. changed the title [-]Connections to CNPG do not verify the server[/-] [+]SEC-04: Connections to CNPG do not verify the server[/+] on Nov 13, 2026
  5. added
    class:INV
    sev:medium
    status:open
    on Nov 13, 2026
  6. ephico2real2 commented on Nov 13, 2026

    @ephico2real2
    OwnerAuthor

    Work tag: In-Progress. Commit 920b938 on branch fix-cnpg-verify-full holds unfinished work. The branch has no pull request, and its kind proof did not run. Read from gh and git at 2026-11-13T09:18Z.

  7. added 2 commits that reference this issue on Nov 13, 2026
  8. added
    In-QA
    and removed
    In-Progress
    on Nov 13, 2026
  9. ephico2real2 commented on Nov 13, 2026

    @ephico2real2
    OwnerAuthor

    In-QA: pull request #158 closes this issue. Proven on kind on 2026-11-13: before the fix each container connected with sslmode prefer and fell back to plaintext with a wrong CA; with the fix each connects verify-full and refuses it. CI on its head was not read yet when this was written.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-QAbugclass:INVsev:mediumstatus:open

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions