feat(cli): honor `PGSSL*` env on `db push --linked` (CLI-2753) by 7ttp · Pull Request #7261 · supabase/cli · GitHub
Skip to content

feat(cli): honor PGSSL* env on db push --linked (CLI-2753) - #7261

Merged
7ttp merged 3 commits into
developfrom
7ttp/cli-2753-db-push-linked-silently-ignores-pgsslmodepgsslrootcert-on
Oct 20, 2026
Merged

7ttp merged 3 commits into
developfrom
7ttp/cli-2753-db-push-linked-silently-ignores-pgsslmodepgsslrootcert-on

Conversation

@7ttp

@7ttp 7ttp commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

TL;DR

supabase db push --linked stops silently dropping PGSSLMODE and PGSSLROOTCERT when the direct host answers

whats introduced?

--linked commands that connect from the CLI itself (db push, migration commands, inspect db, …
now read PGSSLMODE, PGSSLROOTCERT and PGSSLCERT/PGSSLKEY from the shell on the direct host, the way the pooler fallback already did.

ps: the pg_dump steps in db dump, db pull and migration squash still don't forward them.

PGSERVICE and PGCONNECT_TIMEOUT apply too, and a missing PGSSLROOTCERT file now fails instead of being ignored.

host, role and database stay pinned. an invalid mode fails naming the vars on either route, and sslmode=disable now dials plaintext without reading cert files.

visual rep
supabase db push --linked before now
direct host PGSSL* ignored read from the shell
pooler fallback read from the shell unchanged
invalid PGSSLMODE ignored / IPv6 error fails naming the vars

why this?

--db-url and the pooler fallback already read these vars.

the linked direct host was skipped by mistake during the port, so it now reads them too

ref:

@7ttp 7ttp self-assigned this Oct 20, 2026
@7ttp
7ttp requested a review from a team as a code owner October 20, 2026 12:22

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

Confirmed the missing malformed-pooler-URL regression test. The TLS downgrade is verified, but the claim of plaintext password transmission remains uncertain because it depends on server authentication and SSL enforcement. Codex reported no findings. Verification was static; tests were not run.

Findings

Severity Location Category Sources Claim
🟡 MINOR apps/cli/src/command-internal/db-config.layer.ts:501 security claude Linked direct-host connections now honor shell PGSSLMODE=disable without warning, downgrading previously TLS-only connections and potentially exposing the database password over an unencrypted connection.
⚪ NIT apps/cli/src/command-internal/db-config.layer.ts:326 test-coverage claude The new pooler error-classification branch lacks a regression test proving that a malformed saved pooler URL with valid environment settings still produces DbConfigIpv6Error rather than DbConfigLibpqEnvError.

Stats

Claude findings: 2 · Codex findings: 0 · Confirmed: 1 · Refuted: 0 · Uncertain: 1


Models: claude-opus-5-5 + gpt-6.1-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

Comment thread apps/cli/src/command-internal/db-config.layer.ts
Comment thread apps/cli/src/command-internal/db-config.layer.ts

@avallete avallete left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dogfooded on a staging project against develop. On the direct host, verify-full with a CA it shouldn't trust, a missing PGSSLROOTCERT file and PGSSLMODE=bogus now all fail as described; develop ignored the first two. require pushes fine.

One non-blocking note on the description: "--linked db commands now read PGSSL*" is broader than the change. db dump, db pull and migration squash build their pg_dump env in pg-dump.env.ts, which forwards only host, port, user, password and database. So db dump --linked with PGSSLMODE=verify-full and an untrusted CA still succeeds. develop has the same gap, so this PR doesn't cause it. Could you narrow the wording to the commands that connect through the resolver? Forwarding SSL settings to pg_dump can be a follow-up.

@7ttp
7ttp added this pull request to the merge queue Oct 20, 2026
Merged via the queue into develop with commit 8803a3e Oct 20, 2026
57 checks passed
@7ttp
7ttp deleted the 7ttp/cli-2753-db-push-linked-silently-ignores-pgsslmodepgsslrootcert-on branch October 20, 2026 13:40
github-merge-queue Bot pushed a commit that referenced this pull request Oct 23, 2026
## TL;DR

remote `db dump` and the first `db pull` seed now pass the resolved TLS
settings to `pg_dump`
## whats introduced?

`pg_dump` only got host, port, user, password and database, so a
container dump ignored `PGSSLMODE=verify-full`, trusted any CA, and got
turned away by servers that require a client cert.

for the linked project and a remote `--db-url`, it now gets the resolved
`sslmode` and connect timeout, the root cert under `require` or
`verify-*`, and the client cert unless the key needs `sslpassword`
In a container the cert files are mounted read only, and a missing one
fails before docker runs

> [!NOTE]
> a remote dump that only worked because verification was skipped now
fails. local targets and runs without TLS or timeout settings are
unchanged

<details>
<summary>visual rep:</summary>

```mermaid
flowchart TD
  conn["resolved connection"] --> remote{"remote target?"}
  remote -- no --> plain["host, port, user, password, database"]
  remote -- yes --> tls["+ sslmode and connect timeout<br/>+ root cert under require or verify-*<br/>+ system root cert forces verify-full<br/>+ client cert unless the key needs sslpassword"]
  tls --> where{"where pg_dump runs"}
  where -- container --> box["cert files checked, then mounted read only<br/>key copied to a private file<br/>verify-* without root cert, or system, uses the image CA bundle"]
  where -- native --> host["host paths kept<br/>verify-* without root cert uses ~/.postgresql/root.crt, else the host CA bundle<br/>system uses the host CA bundle"]
  plain --> dump["pg_dump"]
  box --> dump
  host --> dump
```

</details>

## ref

- spotted while working on: #7261
- related: CLI-2753
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants