-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(inputs.postgres*)!: Prevent leaking sensitive data in server tag #14829
Conversation
I am the person who originally reported this issue. I didn't look closely at the updated implementation, but glancing through the new test cases, it makes sense to me and seems to be working. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am of course weary when we make these larger changes to fix an issue. Can you please add a note the change log about this change as it is breaking tags for some small percentage of users.
I would also like to land this in 1.30 and not 1.29.5. Agreed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the PR looks fine overall. I didn't desk check the sanitizer but the existing tests show it is working better. Marking as 'request changes' since I'd like to see even more tests for this (there is an opportunity to refactor to make that better as well as a question on zero-ing out addr
).
c24328a
to
432a855
Compare
@jdstrand I hopefully addressed your comments. If I got things wrong, please let me know! |
Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip. 👍 This pull request doesn't change the Telegraf binary size 📦 Click here to get additional PR build artifactsArtifact URLs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jdstrand I don't think using the temporary string is a problem, so let's try as-is. |
Summary
The current implementation of
SanitizedAddress()
does not handle quoted parameter values containing spaces or equal signs (e.g.host=localhost user=john password='a secret=good'
). Additionally to those issues, the parsing of URI connection strings is completely broken for spaces and equal signs as values containing those need to be single-quoted which does not happen. Furthermore, that function escapes "special characters" (space, backslash and single-quote) which subsequently breaks the sanitize function.This PR adds unit-tests for both of the mentioned functions. It also removes the useless escaping of spaces during URI handling and replaces this part by quoting the value. Finally, the PR improves the regular-expression used to remove sensitive data to correctly handle quoted values, equal-signs and other corner cases.
Checklist
Related issues