CVE-2025-24795
Python connector caches credentials in world-readable file on Linux (v2.3.7-3.13.0)
- CVSS 5.5
- CWE-276
- Information Leakage
- Local
The Snowflake Connector for Python provides an interface for developing Python applications that can connect to Snowflake and perform all standard operations. Snowflake discovered and remediated a vulnerability in the Snowflake Connector for Python. On Linux systems, when temporary credential caching is enabled, the Snowflake Connector for Python will cache temporary credentials locally in a world-readable file. This vulnerability affects versions 2.3.7 through 3.13.0. Snowflake fixed the issue in version 3.13.1.
- CWE
- CWE-276
- CVSS base score
- 5.5
- Published
- 2025-01-29
- OWASP
- A07 Identification and Authentication Failures
- Orthogonal defect classification
- Interface
- Code defect classification
- Incorrect Functionality
- Category
- Information Leakage
- Subcategory
- Information Disclosure
- Accessibility scope
- Local
- Impact
- Information Disclosure
- Affected component
- Snowflake Co
- Fixed by upgrading
- Yes
Solution
Upgrade to version 3.13.1.
Vulnerable code sample
import os
import json
import stat
class CredentialCache:
def __init__(self, cache_dir="/tmp/.snowflake_cache"):
"""Vulnerable function that demonstrates the security issue."""
self.cache_dir = cache_dir
os.makedirs(self.cache_dir, exist_ok=True)
def cache_credentials(self, username, token):
"""Vulnerable function that demonstrates the security issue."""
cache_file = os.path.join(self.cache_dir, f"{username}_creds.json")
credentials = {"token": token}
with open(cache_file, "w") as f:
json.dump(credentials, f)
os.chmod(cache_file, 0o644)
def get_cached_credentials(self, username):
"""Vulnerable function that demonstrates the security issue."""
cache_file = os.path.join(self.cache_dir, f"{username}_creds.json")
if os.path.exists(cache_file):
with open(cache_file, "r") as f:
credentials = json.load(f)
return credentials.get("token")
return None
if __name__ == '__main__':
cache = CredentialCache()
username = "testuser"
token = "test_secret_token"
cache.cache_credentials(username, token)
retrieved_token = cache.get_cached_credentials(username)
print(f"Retrieved token: {retrieved_token}")
import subprocess
cache_file = os.path.join(cache.cache_dir, f"{username}_creds.json")
try:
result = subprocess.run(['cat', cache_file], capture_output=True, text=True, check=True)
print(f"Attacker read cache file content: {result.stdout.strip()}")
except subprocess.CalledProcessError as e:
print(f"Error reading cache file: {e}")Patched code sample
import os
import json
import stat
class CredentialCache:
def __init__(self, cache_dir=None):
"""Secure function that fixes the vulnerability."""
default_dir = os.path.expanduser("~/.secure_snowflake_cache")
self.cache_dir = cache_dir or default_dir
os.makedirs(self.cache_dir, exist_ok=True)
os.chmod(self.cache_dir, 0o700)
def cache_credentials(self, username, token):
"""Secure function that fixes the vulnerability."""
cache_file = os.path.join(self.cache_dir, f"{username}_creds.json")
credentials = {"token": token}
with open(cache_file, "w") as f:
json.dump(credentials, f)
os.chmod(cache_file, 0o600)
def get_cached_credentials(self, username):
"""Secure function that fixes the vulnerability."""
cache_file = os.path.join(self.cache_dir, f"{username}_creds.json")
if os.path.exists(cache_file):
if os.stat(cache_file).st_mode & (stat.S_IRWXG | stat.S_IRWXO):
raise PermissionError("Insecure file permissions on cache file")
with open(cache_file, "r") as f:
credentials = json.load(f)
return credentials.get("token")
return None
if __name__ == '__main__':
cache = CredentialCache()
username = "testuser"
token = "test_secret_token"
cache.cache_credentials(username, token)
retrieved_token = cache.get_cached_credentials(username)
print(f"Retrieved token: {retrieved_token}")
import subprocess
cache_file = os.path.join(cache.cache_dir, f"{username}_creds.json")
try:
result = subprocess.run(['cat', cache_file], capture_output=True, text=True, check=True)
print("Attempted file read by attacker:")
print(result.stdout.strip() if os.geteuid() == 0 else "[Access likely denied for non-owner]"):
except subprocess.CalledProcessError as e:
print(f"Error reading cache file: {e}")
except PermissionError as e:
print(f"PermissionError: {e}")Cite this entry
@misc{vaitp:cve202524795,
title = {{Python connector caches credentials in world-readable file on Linux (v2.3.7-3.13.0)
}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2025},
note = {VAITP Python Vulnerability Dataset, entry CVE-2025-24795},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2025-24795/}}
}
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 ::
