T09 · Insecure Skill Coding Practices
- Location
scripts/dispatch.py:234- Finding
Unsafe Pickle Cache Deserialization Enables Arbitrary Code Execution
- Content
View full analysis
= os.path.getmtime(filepath) triples = None names = idx = A = orig_n = dist = None if use_cache: try: with open(cache_path, "rb") as f: names, idx, A, orig_n, dist = pickle.load(f) ``` ### Technical Analysis Python pickle data is executable serialization rather than a passive data format. During `pickle.load()`, specially crafted objects can invoke attacker-selected callables through mechanisms such as `__reduce__`. Code execution therefore occurs while deserializing the cache, before the later distance-matrix validation can provide any protection. The application derives the cache path by appending `.cache` to a user-selected triples-file path. It trusts an existing cache when caching is enabled by default and the cache modification time is equal to or newer than the source file. Modification time is not an authenticity or integrity control. Although `SKILL.md` warns that pickle files are unsafe, the implementation still loads them by default. Documentation does not prevent exploitation when a workflow and its adjacent cache originate from an untrusted archive, repository, shared workspace, or other attacker-writable location. ### Attack Path 1. An attacker creates a legitimate-looking triples file, such as `tasks.md`. 2. The attacker creates an adjacent `tasks.md.cache` containing a malicious pickle payload whose reconstruction routine invokes an attacker-selected Python callable. 3. The attacker sets the cache timestamp to be equal to or newer than `tasks.md`, or otherwise causes that condition to be satisfied. 4. A vic ...[truncated 990 chars]- Remediation
View remediation
