Skip to content
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

Sercurity issue: remove clickhouse server ip & port in the exception #364

Merged
merged 5 commits into from
Jun 23, 2024

Conversation

andy1xx8
Copy link
Contributor

@andy1xx8 andy1xx8 commented Jun 23, 2024

Hi,
The issue is the HTTPDriver return the Clickhouse server sensitive detail: IP & Port in the error exception.
Example:

Error: HTTPDriver for http://10.15.27.43:8123 returned response code 404)
 Code: 60. DB::Exception: Table test.users_1 does not exist. Maybe you meant test.users? (UNKNOWN_TABLE) (version 23.12.3.40 (official build))

Expected:

Error: HTTPDriver returned response code 404)
 Code: 60. DB::Exception: Table test.users_1 does not exist. Maybe you meant test.users?. (UNKNOWN_TABLE) (version 23.12.3.40 (official build))

This will lead to an issue that the downstream application using this Clickhouse Connect driver,
They will return the details to the client side and the UI will show the IP & Port then the hacker may use this to attack.
We might run into these 2 cases:

  • They will wrap the exception and not return the detailed error to the client side => This is a bad practice cause the user will not know the message details.
  • They will try to manipulate the message string to search in the string to remove IP & Port ==> This is also an ad-hoc fix since the message string may have many different templates and formats, that they can not cover every case.

Summary

Checklist

Delete items not relevant to your PR:

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG
  • For significant changes, documentation in https://github.com/ClickHouse/clickhouse-docs was updated with further explanations or tutorials

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Andy seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@genzgd
Copy link
Collaborator

genzgd commented Jun 23, 2024

Thanks for your submission! However, instead of always removing that information (which could be useful for multi-client applications), please make that behavior configurable using the new show_clickhouse_errors global setting.

@andy1xx8
Copy link
Contributor Author

@genzgd WWow thanks, if there is a global setting like that I will add a logic to turn off sensitive information respect the value of show_clickhouse_errors.
How do u think?

Thanks

@genzgd
Copy link
Collaborator

genzgd commented Jun 23, 2024

That sounds good -- for reference it was added in response to #344 where it came up, but I missed those places where it was exposed directly in the error message. Here's the v0.7.9 changelog message too:

- The new client keyword argument `show_clickhouse_errors` controls whether the full ClickHouse error (including possibly
sensitive information) is displayed when there is an error in ClickHouse processing.  It defaults to True.  If False,
the simple string 'The ClickHouse server returned an error.' will be displayed.  Closes https://github.com/ClickHouse/clickhouse-connect/issues/344.

…tion log respect the value of show_clickhouse_errors
@andy1xx8
Copy link
Contributor Author

@genzgd

I have just changed the code logic to respect the config show_clickhouse_errors. Please help me to review and merge if it's ok.

We are facing this issues that showing the sensitive info to the client even if we turn off the show_clickhouse_errors

@genzgd
Copy link
Collaborator

genzgd commented Jun 23, 2024

I think you need the same check in the _error_handler method where you removed the url before?

…tion log respect the value of show_clickhouse_errors
@andy1xx8
Copy link
Contributor Author

@genzgd
Yes. Done. Please help me to review and merge if it's ok.

…tion log respect the value of show_clickhouse_errors
@genzgd genzgd merged commit 9ae90d2 into ClickHouse:main Jun 23, 2024
33 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.

None yet

3 participants