Skip to content

fix(cache): avoid pickle deserialization in Redis cache - #967

Open
saksim wants to merge 1 commit into
NanmiCoder:mainfrom
saksim:codex/upstream-redis-json
Open

saksim wants to merge 1 commit into
NanmiCoder:mainfrom
saksim:codex/upstream-redis-json

Conversation

@saksim

@saksim saksim commented Sep 9, 2026

Copy link
Copy Markdown

RedisCache currently passes cached bytes to pickle.loads. A party able to modify those values can cause Python objects to be executed when the crawler reads the cache. This PR replaces pickle with JSON while preserving TTL and the existing string/basic-value callers.

Legacy pickle entries and malformed JSON become cache misses; no pickle fallback or unrelated key deletion is performed. docs/redis-cache-format.md describes supported values and the restart/cold-cache implications. Arbitrary Python objects and restoration of tuple types are no longer supported.

Validation: all 8 new regression cases fail before the fix. On this isolated branch based on upstream main d6f7c5b, the complete tests/ suite passes (104 tests, Python 3.11, Windows with PYTHONUTF8=1). Tests use a mocked Redis client and assert that pickle.loads is never invoked. No live credentials or Redis service are required. The same fix also passed Linux/Windows tests and WebUI/documentation builds in fork PR #16.

This PR contains only the Redis fix, regression tests, and format migration note. Related report: saksim#3.

@saksim
saksim requested a review from NanmiCoder as a code owner September 9, 2026 02:53
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

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.

1 participant