{"id":1262,"cve":"CVE-2025-24794","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2025-24794\/","cwe":"CWE-502","cwe_number":502,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/502","cvss_score":7.8,"published":"2025-01-29","owasp":"A08 Software and Data Integrity Failures","odc":"Timing\/Serialization","cdc":"Serialization Issues","category":"Configuration Issues","subcategory":"Insecure Parsing or Deserialization","scope":"Local","impact":"Privilege Escalation","summary":"Python Snowflake connector <3.13.1 OCSP cache uses pickle, allows local priv escalation.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2025-24794\/","description":"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. The OCSP response cache uses pickle as the serialization format, potentially leading to local privilege escalation. This vulnerability affects versions 2.7.12 through 3.13.0. Snowflake fixed the issue in version 3.13.1.","solution":"Upgrade to version 3.13.1.","affected_component":"Snowflake Connector for Python","fixed_by_upgrading":true,"vulnerable_code":"import pickle\nimport os\n\nclass OCSPResponseCache:\n    def __init__(self, cache_dir):\n        \"\"\"Vulnerable function that demonstrates the security issue.\"\"\"\n        self.cache_dir = cache_dir\n        os.makedirs(cache_dir, exist_ok=True)\n\n        def get(self, key):\n            \"\"\"Vulnerable function that demonstrates the security issue.\"\"\"\n            cache_file = os.path.join(self.cache_dir, key)\n            if os.path.exists(cache_file):\n                with open(cache_file, 'rb') as f:\n                    try:\n                        return pickle.load(f)\n                        except:\n                            return None\n                            return None\n\n                            def set(self, key, value):\n                                \"\"\"Vulnerable function that demonstrates the security issue.\"\"\"\n                                cache_file = os.path.join(self.cache_dir, key)\n                                with open(cache_file, 'wb') as f:\n                                    pickle.dump(value, f)\n\n                                    if __name__ == '__main__':\n                                        cache = OCSPResponseCache(\"ocsp_cache\")\n\n                                        data = {\"response\": \"OCSP OK\", \"timestamp\": 1234567890}\n                                        cache.set(\"valid_key\", data)\n\n                                        cached_data = cache.get(\"valid_key\")\n                                        print(\"Cache read:\", cached_data)\n\n                                        os.system('rm -rf ocsp_cache')","patched_code":"import json\nimport os\n\nclass OCSPResponseCache:\n    def __init__(self, cache_dir):\n        \"\"\"Secure function that fixes the vulnerability.\"\"\"\n        self.cache_dir = cache_dir\n        os.makedirs(cache_dir, exist_ok=True)\n\n        def _sanitize_key(self, key):\n            \"\"\"Secure function that fixes the vulnerability.\"\"\"\n            return \"\".join(c for c in key if c.isalnum() or c in ('-', '_')):\n            def get(self, key):\n                \"\"\"Secure function that fixes the vulnerability.\"\"\"\n                key = self._sanitize_key(key)\n                cache_file = os.path.join(self.cache_dir, key + \".json\")\n                if os.path.exists(cache_file):\n                    with open(cache_file, 'r') as f:\n                        try:\n                            return json.load(f)\n                            except json.JSONDecodeError:\n                                return None\n                                return None\n\n                                def set(self, key, value):\n                                    \"\"\"Secure function that fixes the vulnerability.\"\"\"\n                                    key = self._sanitize_key(key)\n                                    if not isinstance(value, (dict, list, str, int, float, bool, type(None))):\n                                        raise ValueError(\"Unsupported type for caching\"):\n                                        cache_file = os.path.join(self.cache_dir, key + \".json\")\n                                        with open(cache_file, 'w') as f:\n                                            json.dump(value, f)\n\n                                            if __name__ == '__main__':\n                                                cache = OCSPResponseCache(\"ocsp_cache\")\n\n                                                data = {\"response\": \"OCSP OK\", \"timestamp\": 1234567890}\n                                                cache.set(\"valid_key\", data)\n\n                                                cached_data = cache.get(\"valid_key\")\n                                                print(\"Cache read:\", cached_data)\n\n                                                os.system('rm -rf ocsp_cache')\n","payload_needed":true,"payload":"```python\nimport pickle\nimport os\n\nclass Evil(object):\n    def __reduce__(self):\n        return (os.system, ('whoami > \/tmp\/pwned',))\n\npickle.dumps(Evil())\n```","payload_status":"available","published_fix":[{"repository":"snowflakedb\/snowflake-connector-python","commit_url":"https:\/\/github.com\/snowflakedb\/snowflake-connector-python\/commit\/3769b43822357c3874c40f5e74068458c2dc79af","commit_subject":"SNOW-1902019: Python CVEs january batch (#2154)","units":[{"file":"src\/snowflake\/connector\/auth\/_auth.py","function":null},{"file":"src\/snowflake\/connector\/auth\/_auth.py","function":"flush_temporary_credentials"},{"file":"src\/snowflake\/connector\/cache.py","function":null},{"file":"src\/snowflake\/connector\/cache.py","function":"SFDictFileCache._load"},{"file":"src\/snowflake\/connector\/cache.py","function":"SFDictFileCache._save"},{"file":"src\/snowflake\/connector\/cache.py","function":"SFDictFileCache.__init__"},{"file":"src\/snowflake\/connector\/encryption_util.py","function":null},{"file":"src\/snowflake\/connector\/encryption_util.py","function":"SnowflakeEncryptionUtil.decrypt_file"},{"file":"src\/snowflake\/connector\/file_util.py","function":null},{"file":"src\/snowflake\/connector\/ocsp_snowflake.py","function":null},{"file":"src\/snowflake\/connector\/storage_client.py","function":null},{"file":"src\/snowflake\/connector\/storage_client.py","function":"SnowflakeStorageClient.prepare_download"},{"file":"src\/snowflake\/connector\/storage_client.py","function":"SnowflakeStorageClient.write_downloaded_chunk"},{"file":"src\/snowflake\/connector\/util_text.py","function":null}]}],"references":null}