Headline
CVE-2023-34233: SNOW-761004 Added URL Validator and URL escaping of strings (#1480) · snowflakedb/snowflake-connector-python@1cdbd3b
The Snowflake Connector for Python provides an interface for developing Python applications that can connect to Snowflake and perform all standard operations. Versions prior to 3.0.2 are vulnerable to command injection via single sign-on(SSO) browser URL authentication. In order to exploit the potential for command injection, an attacker would need to be successful in (1) establishing a malicious resource and (2) redirecting users to utilize the resource. The attacker could set up a malicious, publicly accessible server which responds to the SSO URL with an attack payload. If the attacker then tricked a user into visiting the maliciously crafted connection URL, the user’s local machine would render the malicious payload, leading to a remote code execution. This attack scenario can be mitigated through URL whitelisting as well as common anti-phishing resources. Version 3.0.2 contains a patch for this issue.
Expand Up
@@ -23,6 +23,7 @@
)
from …errorcode import (
ER_IDP_CONNECTION_ERROR,
ER_INVALID_VALUE,
ER_NO_HOSTNAME_FOUND,
ER_UNABLE_TO_OPEN_BROWSER,
)
Expand All
@@ -32,6 +33,7 @@
EXTERNAL_BROWSER_AUTHENTICATOR,
PYTHON_CONNECTOR_USER_AGENT,
)
from …url_util import is_valid_url
from . import Auth
from .by_plugin import AuthByPlugin, AuthType
Expand Down Expand Up
@@ -131,18 +133,29 @@ def prepare(
socket_connection.listen(0) # no backlog
callback_port = socket_connection.getsockname()[1]
logger.debug(“step 1: query GS to obtain SSO url”)
sso_url = self._get_sso_url(
conn, authenticator, service_name, account, callback_port, user
)
logger.debug(“Validate SSO URL”)
if not is_valid_url(sso_url):
self._handle_failure(
conn=conn,
ret={
"code": ER_INVALID_VALUE,
“message": (f"The SSO URL provided {sso_url} is invalid”),
},
)
return
print(
"Initiating login request with your identity provider. A "
"browser window should have opened for you to complete the "
"login. If you can’t see it, check existing browser windows, "
“or your OS settings. Press CTRL+C to abort and try again…”
)
logger.debug(“step 1: query GS to obtain SSO url”)
sso_url = self._get_sso_url(
conn, authenticator, service_name, account, callback_port, user
)
logger.debug(“step 2: open a browser”)
print(f"Going to open: {sso_url} to authenticate…")
if not self._webbrowser.open_new(sso_url):
Expand Down
Related news
### Issue Snowflake was informed via our bug bounty program of a command injection vulnerability in the Snowflake Python connector via SSO browser URL authentication. ### Impacted driver package: snowflake-connector-python ### Impacted version range: before [Version 3.0.2](https://community.snowflake.com/s/article/Snowflake-Connector-for-Python-Release-Notes) ### Attack Scenario In order to exploit the potential for command injection, an attacker would need to be successful in (1) establishing a malicious resource and (2) redirecting users to utilize the resource. The attacker could set up a malicious, publicly accessible server which responds to the SSO URL with an attack payload. If the attacker then tricked a user into visiting the maliciously crafted connection URL, the user’s local machine would render the malicious payload, leading to a remote code execution. This attack scenario can be mitigated through URL whitelisting as well as common anti-phishing resources. ### ...