Skip to content

security: redact DSN from connection string parse errors - #48

Merged
rahulcrl merged 1 commit into
mainfrom
fix/redact-dsn-from-errors
Jul 21, 2026
Merged

rahulcrl merged 1 commit into
mainfrom
fix/redact-dsn-from-errors

Conversation

@rahulcrl

@rahulcrl rahulcrl commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Prevents credentials from leaking in error messages when the connection
string is malformed.

Changes

  • db/adapter.go: drop the upstream pgxpool.ParseConfig error (which can
    echo the raw DSN for keyword/value format connections) and return a
    generic message
  • config/config.go: drop the upstream url.Parse error (which echoes the
    full DSN including password) and return a generic message
  • db/adapter_test.go: add test asserting password does not appear in
    parse error output
  • config/config_test.go: add test asserting password does not appear in
    URL validation error output

@rahulcrl
rahulcrl requested a review from TheComputerM July 21, 2026 08:49
Comment thread db/adapter_test.go Resolved
Comment thread db/adapter.go Resolved
@rahulcrl
rahulcrl force-pushed the fix/redact-dsn-from-errors branch from 9c79cbc to bd57677 Compare July 21, 2026 08:57
Comment thread config/config_test.go Resolved
@rahulcrl
rahulcrl force-pushed the fix/redact-dsn-from-errors branch 2 times, most recently from 501fa91 to 22913b4 Compare July 21, 2026 09:03
Comment thread db/adapter_test.go Resolved
Comment thread config/config.go Resolved
pgxpool.ParseConfig and url.Parse can echo the raw connection URL in
their errors, which may include an embedded password. Drop the upstream
errors and return generic messages so credentials never reach stderr
or logs.
@rahulcrl
rahulcrl force-pushed the fix/redact-dsn-from-errors branch from 22913b4 to a0a4f95 Compare July 21, 2026 09:18
@rahulcrl
rahulcrl merged commit 627d732 into main Jul 21, 2026
5 checks passed
@rahulcrl
rahulcrl deleted the fix/redact-dsn-from-errors branch July 21, 2026 10:03
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.

3 participants

⌂ 换网址