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

Fix clickhouse password leak #4078

Merged
merged 2 commits into from
Aug 18, 2019
Merged

Fix clickhouse password leak #4078

merged 2 commits into from
Aug 18, 2019

Conversation

vv-p
Copy link

@vv-p vv-p commented Aug 17, 2019

What type of PR is this? (check all applicable)

  • Bug Fix

Description

Clickhouse credentials appear in web-interface after unsuccessfully http connection while query running:

Error running query: HTTPConnectionPool(host='10.1.2.3', port=8123): Max retries exceeded with url: /?password=123qweasd&user=redashreadonly&database=default (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7ff36739bd90>: Failed to establish a new connection: [Errno 111] Connection refused',))

So every user with access to redash web-interface can get it. In this PR I catch all requests exceptions and generate new, without private data.

Copy link
Member

@arikfr arikfr left a comment

Choose a reason for hiding this comment

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

Thanks! Please see comment.

# logging.warning(r.json())
return r.json()
except requests.RequestException:
raise Exception('Connection error to %s' % url)
Copy link
Member

Choose a reason for hiding this comment

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

The problem now is that the error message is very light on details. How about something like the following (assuming e is the exception):

if e.response:
    details = "({}, Status Code: {})".format(e.__class__.__name__, e.response.status_code)
else:
    details = "({})".format(e.__class__.__name__)

message = "Connection error to: {} {}.".format(url, details)

Copy link
Author

Choose a reason for hiding this comment

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

It sounds good, fixed, thank you. Now exceptions look like:
Exception: Connection error to: http://127.0.0.1:8123 (ReadTimeout).
or
Exception: Connection error to: http://127.0.0.1:8123 (ConnectionError).

@arikfr arikfr merged commit b426e4f into getredash:master Aug 18, 2019
@arikfr
Copy link
Member

arikfr commented Aug 18, 2019

Thanks!

@vv-p vv-p deleted the db-password-leak-fix branch August 18, 2019 09:25
harveyrendell pushed a commit to pushpay/redash that referenced this pull request Nov 14, 2019
* Fix clickhouse password leak

* Fix after review
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