[BUG] GCP gateway example connects to Cloud SQL with sslmode=require (no server certificate verification), unlike the AWS example's verify-full
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.tfline 164:...@${google_sql_database_instance.db.private_ip_address}:5432/${var.db_name}?sslmode=requireexamples/gateway/gcp/setup.shlines 319-320 (same string, "guide §4")examples/gateway/gcp/gateway.yaml.exampleline 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 usesNODE_EXTRA_CA_CERTS. Note Cloud SQL's server certificate doesn't name the private IP, so hostname verification (verify-fullby 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
requiredoesn't authenticate the server and why it was chosen here.
Error Messages/Logs
Steps to Reproduce
- Read
examples/gateway/gcp/terraform/main.tfline 164 andexamples/gateway/gcp/setup.shline 320: both produce?sslmode=require. - Compare
examples/gateway/aws/terraform/main.tflines 276-285:?sslmode=verify-fullwith a pinned CA bundle. - Per the PostgreSQL docs (https://www.postgresql.org/docs/current/libpq-ssl.html, table "SSL Mode Descriptions"),
requireprotects against eavesdropping but not against MITM; onlyverify-ca/verify-fulldo.
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.