Skip to content

fix: replace pickle with json in RedisCache to prevent deserialization attacks#170

Open
spidershield-contrib wants to merge 1 commit into
featureform:mainfrom
spidershield-contrib:fix/replace-pickle-with-json
Open

fix: replace pickle with json in RedisCache to prevent deserialization attacks#170
spidershield-contrib wants to merge 1 commit into
featureform:mainfrom
spidershield-contrib:fix/replace-pickle-with-json

Conversation

@spidershield-contrib

Copy link
Copy Markdown

Summary

  • Replace pickle.loads()/pickle.dumps() with json.loads()/json.dumps() in RedisCache
  • Eliminates arbitrary code execution risk from compromised Redis data

Fixes #169

Problem

pickle.loads() on data from Redis can execute arbitrary code if an attacker gains write access to the Redis instance (CWE-502). This is a well-known deserialization vulnerability.

Solution

Since MCP tool enrichment cache values are JSON-serializable (strings, dicts, lists), json is a safe drop-in replacement that preserves functionality while eliminating the code execution risk.

Changes

File Change
src/enrichmcp/cache/__init__.py import pickleimport json, pickle.loads/dumpsjson.loads/dumps

Testing

  • JSON handles all standard Python types used in MCP tool results (str, dict, list, int, float, bool, None)
  • Invalid cached data now raises json.JSONDecodeError instead of potentially executing code

…n attacks

pickle.loads() on data from Redis can execute arbitrary code if an
attacker gains write access to the Redis instance. Since MCP tool
enrichment results are JSON-serializable, json is a safe drop-in
replacement.

CWE-502: Deserialization of Untrusted Data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: pickle deserialization in RedisCache allows code execution

1 participant