VAITP Dataset

← Back to the dataset

CVE-2023-34233

Snowflake Connector for Python < 3.0.2 vulnerable to SSO URL command injection

  • CVSS 8.8
  • CWE-77 Improper Neutralization of Special Elements used in a Command ('Command Injection')
  • Input Validation and Sanitization
  • Remote

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.

CVSS base score
8.8
Published
2023-06-08
OWASP
A06 Vulnerable and Outdated Components
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Input Validation and Sanitization
Subcategory
Command Injection
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Fixed by upgrading
Yes

Solution

Update to Snowflake Connector for Python version 3.0.2 or higher.

Vulnerable code sample

class SnowflakeConnector:
    def authenticate(self, sso_url):
        self.perform_authentication(sso_url)

    def perform_authentication(self, sso_url):
        print(f"Authenticating with SSO URL: {sso_url}")

connector = SnowflakeConnector()
connector.authenticate("http://example-domain.com/auth?payload=example_code")

Patched code sample

import re
from urllib.parse import urlparse

class SnowflakeConnector:
    def __init__(self, valid_redirect_urls):
        self.valid_redirect_urls = valid_redirect_urls

    def authenticate(self, sso_url):
        parsed_url = urlparse(sso_url)
        if not self.is_valid_redirect_url(parsed_url):
            raise ValueError("Invalid SSO URL")

        self.perform_authentication(sso_url)

    def is_valid_redirect_url(self, parsed_url):
        return any(re.match(valid_url, parsed_url.geturl()) for valid_url in self.valid_redirect_urls)

    def perform_authentication(self, sso_url):
        print(f"Authenticating with SSO URL: {sso_url}")

valid_urls = [
    r"https://example-domain.com/.*",
    r"https://another-example-domain.com/.*"
]

connector = SnowflakeConnector(valid_urls)
connector.authenticate("http://example-domain.com/auth?payload=example_code")
connector.authenticate("http://example1-domain.com/auth")

Cite this entry

@misc{vaitp:cve202334233,
  title        = {{Snowflake Connector for Python < 3.0.2 vulnerable to SSO URL command injection}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2023},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2023-34233},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2023-34233/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::