Skip to content

fix(sql): redact passwords in connection URI errors - #1067

Merged
wgtmac merged 2 commits into
apache:mainfrom
gty404:fix/sql-uri-password-redaction
Nov 1, 2026
Merged

wgtmac merged 2 commits into
apache:mainfrom
gty404:fix/sql-uri-password-redaction

Conversation

@gty404

@gty404 gty404 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Redact passwords from MySQL and PostgreSQL connection failure messages.
  • Redact passwords from all SQL connection URI parse errors while preserving diagnostic URI context.
  • Add coverage for normal credentials, @ in passwords, path delimiters, and parse failures.

@zhjwpku zhjwpku left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

+1

wgtmac
wgtmac previously approved these changes Oct 30, 2026
} catch (const std::exception& e) {
return IOError("Failed to connect to PostgreSQL '{}': {}", options.uri, e.what());
return IOError("Failed to connect to PostgreSQL '{}': {}",
RedactConnectionUri(options.uri), e.what());

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.

The URI is redacted, but e.what() is still treated as safe. With sqlpp23 0.69, a password containing whitespace is passed unquoted in libpq conninfo; libpq can then include the following password fragment in its parse error. Sanitize or replace the driver text, and add a factory-level regression test using a password such as secret fragment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 90f9f40. PostgreSQL and MySQL connection failures no longer append driver-provided e.what(), which can contain password fragments from libpq conninfo parsing. Added a PostgreSQL factory-level regression test with secret fragment; it asserts neither the password nor the leaked fragment appears in the returned error.

@wgtmac
wgtmac dismissed their stale review October 30, 2026 09:05

Superseded by the latest request-changes review.

@wgtmac
wgtmac merged commit fd7b2cc into apache:main Nov 1, 2026
15 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.

3 participants