[BUG] GCP gateway example connects to Cloud SQL with sslmode=require (no server certificate verification), unlike the AWS example's verify-full

Status Open
Maintainer reply None cached
Activity 0 comments · opened Sep 30, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The GCP apps-gateway example builds the Postgres connection string with sslmode=require:

  • examples/gateway/gcp/terraform/main.tf line 164: ...@${google_sql_database_instance.db.private_ip_address}:5432/${var.db_name}?sslmode=require
  • examples/gateway/gcp/setup.sh lines 319-320 (same string, "guide §4")
  • examples/gateway/gcp/gateway.yaml.example line 90 comment

sslmode=require encrypts the connection but does not verify the server certificate or hostname, so it does not protect against an in-path attacker impersonating the database. The server side (ssl_mode = "ENCRYPTED_ONLY", main.tf line 120) likewise only requires encryption.

The AWS example deliberately does the opposite: sslmode=verify-full, with the RDS CA bundle baked into the image and loaded via NODE_EXTRA_CA_CERTS (examples/gateway/aws/terraform/main.tf lines 276-285, whose comment explains the choice). The two reference deployments of the same gateway therefore give different TLS guarantees for the database that holds gateway sessions and state, and the GCP one's comments don't mention the trade-off.

Exposure is limited (private IP only, inside the example's VPC), so this is a hardening / consistency issue rather than a directly exploitable bug.

What Should Happen?

Either verify the database server's identity, as the AWS example does, or document why the GCP example doesn't.

Possible approaches (not tested):

  • Verify against the instance's Cloud SQL server CA (from google_sql_database_instance.db.server_ca_cert), made available to the driver the way the AWS example uses NODE_EXTRA_CA_CERTS. Note Cloud SQL's server certificate doesn't name the private IP, so hostname verification (verify-full by IP) likely won't work as-is; CA verification may be the practical option, if the gateway's driver supports it.
  • Or connect through the Cloud SQL Auth Proxy / Cloud SQL connector, which handles mTLS and identity.
  • At minimum, a comment in main.tf / setup.sh explaining that require doesn't authenticate the server and why it was chosen here.

Error Messages/Logs

Steps to Reproduce

  1. Read examples/gateway/gcp/terraform/main.tf line 164 and examples/gateway/gcp/setup.sh line 320: both produce ?sslmode=require.
  2. Compare examples/gateway/aws/terraform/main.tf lines 276-285: ?sslmode=verify-full with a pinned CA bundle.
  3. Per the PostgreSQL docs (https://www.postgresql.org/docs/current/libpq-ssl.html, table "SSL Mode Descriptions"), require protects against eavesdropping but not against MITM; only verify-ca / verify-full do.

Claude Model

Not sure / Multiple models

Is this a regression?

No, this never worked

Last Working Version

_No response_

Claude Code Version

N/A: example deployment code in examples/gateway/gcp on main @ 525d3b3

Platform

Google Vertex AI

Operating System

Other

Terminal/Shell

Other

Additional Information

Found during a review of the examples. I searched existing issues and PRs for gateway + sslmode and found nothing related.

View original on GitHub ↗