Skip to content

mysql/gcpmysql: redact password from connection error - #3753

Merged
vangent merged 1 commit into
google:masterfrom
herdiyana256:fix-gcpmysql-credential-leak
Jul 23, 2026
Merged

mysql/gcpmysql: redact password from connection error#3753
vangent merged 1 commit into
google:masterfrom
herdiyana256:fix-gcpmysql-credential-leak

Conversation

@herdiyana256

Copy link
Copy Markdown
Contributor

lazyCredsOpener.OpenMySQLURL formats the raw *url.URL with %v when Application Default Credentials fail to load:

https://github.com/google/go-cloud/blob/master/mysql/gcpmysql/gcpmysql.go#L80

url.URL's default String() method includes the userinfo password in plain text, so any password supplied in the gcpmysql:// URL ends up in the returned error.

This switches the call site to url.URL.Redacted(), which masks the password with "xxxxx" while keeping the rest of the URL for debugging. Same fix as the companion PR for postgres/gcppostgres (#3752). Added a test for the negative-credentials path.

go test ./mysql/... passes.

lazyCredsOpener.OpenMySQLURL formats the raw *url.URL into the
returned error with %v when Application Default Credentials fail to
load. Since url.URL's default String() includes the userinfo
password in plain text, any password supplied in the gcpmysql:// URL
ends up in the returned error. Use url.URL.Redacted() instead,
matching the same fix in postgres/gcppostgres.
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@0361726). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #3753   +/-   ##
=========================================
  Coverage          ?   75.32%           
=========================================
  Files             ?      104           
  Lines             ?    14202           
  Branches          ?        0           
=========================================
  Hits              ?    10698           
  Misses            ?     2767           
  Partials          ?      737           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vangent
vangent merged commit 562122a into google:master Jul 23, 2026
13 checks passed
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