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: possible unauthenticated SQL injection when login #1383

Merged
merged 3 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions querybook/server/app/auth/ldap_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ def ldap_authenticate(ldap_conn: SimpleLDAPObject, user_dn: str, password: str):

@with_session
def login_user(username: str, email: str, full_name: str, session=None):
if not username or not isinstance(username, str):
raise AuthenticationError("Please provide a valid username")

# Case-insensitive search of the user for backward compatibility.
# Because it was possible to create e.g. uppercase usernames before.
user = get_user_by_name(username, case_sensitive=False, session=session)
Expand Down
4 changes: 2 additions & 2 deletions querybook/server/app/auth/oauth_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ def _parse_user_profile(self, profile_response):

@with_session
def login_user(self, username, email, session=None):
if not username:
raise AuthenticationError("Username must not be empty!")
if not username or not isinstance(username, str):
raise AuthenticationError("Please provide a valid username")

user = get_user_by_name(username, session=session)
if not user:
Expand Down
4 changes: 2 additions & 2 deletions querybook/server/app/auth/okta_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def _parse_user_profile(self, resp):

@with_session
def login_user(self, username, email, fullname, session=None):
if not username:
raise AuthenticationError("Username must not be empty!")
if not username or not isinstance(username, str):
raise AuthenticationError("Please provide a valid username")

user = get_user_by_name(username, session=session)
if not user:
Expand Down
4 changes: 2 additions & 2 deletions querybook/server/app/auth/password_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def authenticate(username, password, session=None):
:raise AuthenticationError: if an error occurred
:return: a PasswordUser
"""
if not username:
raise AuthenticationError("Please provide a username")
if not username or not isinstance(username, str):
raise AuthenticationError("Please provide a valid username")

if not password:
raise AuthenticationError("Please provide a password")
Expand Down