crewai - ✅(Solved) Fix Security: Insecure Pickle Deserialization enables Arbitrary Code Execution in cache handling [1 pull requests, 1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
crewAIInc/crewAI#4746Fetched 2026-04-08 00:40:28
View on GitHub
Comments
1
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
closed ×1commented ×1cross-referenced ×1referenced ×1

Error Message

This issue was filed in error and has been withdrawn. We apologize for the noise.

Fix Action

Fixed

PR fix notes

PR #4747: fix: replace insecure pickle deserialization with JSON serialization

Description (problem / solution / changelog)

Summary

Fixes #4746 — replaces all pickle serialization/deserialization with JSON-based alternatives to prevent arbitrary code execution via insecure deserialization (CWE-502).

Changes:

  • file_handler.py: PickleHandler now uses json.dump/json.load instead of pickle. File extension changed from .pkl to .json. Includes a one-time migration path that reads legacy .pkl files and converts them to .json.
  • upload_cache.py: Replaced PickleSerializer with a custom _CachedUploadSerializer (extends JsonSerializer) that handles CachedUpload dataclass round-tripping via a __cached_upload__ marker field.
  • file_store.py: Swapped PickleSerializerJsonSerializer for the in-memory file store cache.
  • agent_card.py: Swapped PickleSerializerJsonSerializer for the @cached decorator on agent card fetching.
  • Updated all related tests and added new security-focused tests.

Review & Testing Checklist for Human

  • Integer key coercion in training data: JSON converts integer dict keys to strings. The tests were updated to use str(iteration), but verify that all production consumers of CrewTrainingHandler.load() (in crew.py, crew_agent_executor.py, agent/core.py) correctly handle string keys instead of integer keys. This is a behavioral change that could break training workflows.
  • file_store.pyJsonSerializer with complex objects: The file store caches FileInput objects. Verify JsonSerializer can handle these; no tests cover this path. If FileInput isn't JSON-serializable, this will break file store set/get operations.
  • agent_card.pyJsonSerializer with AgentCard: The @cached decorator now uses JsonSerializer for AgentCard objects. Verify AgentCard (from a2a.types) is JSON-serializable. If not, the A2A cached agent card fetch will fail.
  • Migration path still uses pickle.load: _migrate_legacy_pkl() calls pickle.load() on existing .pkl files as a one-time migration. An attacker who can write a .pkl to the working directory before the first load could still achieve code execution through this path. Evaluate whether this migration is acceptable or if legacy files should just be discarded.
  • Constants file not updated: TRAINING_DATA_FILE and TRAINED_AGENTS_DATA_FILE in constants.py still say .pkl. The code works (it strips .pkl and appends .json), but the constants should probably be renamed for clarity.

Test Plan

  1. Training handler: Create a crew, run crew.train() multiple times, verify training data persists correctly and integer iteration keys work.
  2. File uploads: Upload a file via crewai-files, verify upload cache correctly stores and retrieves CachedUpload entries.
  3. Agent card fetching: Test A2A agent card caching to confirm AgentCard JSON serialization works.
  4. Legacy migration: Place an old .pkl file (from a prior crewai version) in the working directory, run the code, verify it auto-migrates to .json.

Notes

<!-- CURSOR_SUMMARY -->

[!NOTE] Medium Risk Medium risk because it changes on-disk training/data persistence from .pkl to .json (including coercing iteration keys to strings) and adds a one-time legacy migration path that still invokes pickle.load() on existing files.

Overview Replaces pickle-based persistence/caching with JSON to mitigate insecure deserialization (CWE-502). PickleHandler now reads/writes JSON, switches storage to .json, and adds automatic migration from legacy .pkl files (then deletes the old file).

Upload caching in crewai-files switches from PickleSerializer to a custom JSON serializer (_CachedUploadSerializer) that round-trips CachedUpload safely, with new tests covering JSON output, round-trips, and corrupted data handling.

Training data writes are updated to use string iteration keys for JSON compatibility (in CrewTrainingHandler and both agent executors), and tests are updated accordingly; in-memory caches that require complex object serialization keep PickleSerializer with explicit safety comments.

<sup>Written by Cursor Bugbot for commit c1ae3da1cd99885d81341d3a417cd44e6fb5a29b. This will update automatically on new commits. Configure here.</sup>

<!-- /CURSOR_SUMMARY -->

Changed files

  • lib/crewai-files/src/crewai_files/cache/upload_cache.py (modified, +59/-3)
  • lib/crewai-files/tests/test_upload_cache.py (modified, +105/-1)
  • lib/crewai/src/crewai/a2a/utils/agent_card.py (modified, +3/-0)
  • lib/crewai/src/crewai/agents/crew_agent_executor.py (modified, +7/-4)
  • lib/crewai/src/crewai/experimental/agent_executor.py (modified, +7/-4)
  • lib/crewai/src/crewai/utilities/file_handler.py (modified, +62/-15)
  • lib/crewai/src/crewai/utilities/file_store.py (modified, +3/-0)
  • lib/crewai/src/crewai/utilities/training_handler.py (modified, +1/-1)
  • lib/crewai/tests/utilities/test_file_handler.py (modified, +85/-16)
  • lib/crewai/tests/utilities/test_training_handler.py (modified, +13/-8)
RAW_BUFFERClick to expand / collapse

This issue was filed in error and has been withdrawn. We apologize for the noise.

extent analysis

Fix Plan

The issue has been withdrawn, so the fix is to simply close the issue.

  • No code changes are required.
  • No configuration changes are needed.
  • No infra or dependency fixes are necessary.

Verification

To verify that the fix worked, simply:

  • Check that the issue is closed.
  • Confirm that no further action is required.

Extra Tips

  • Always review issues carefully before taking action to avoid unnecessary work.
  • If an issue is withdrawn, it's essential to close it promptly to maintain a clean and up-to-date issue tracker.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

crewai - ✅(Solved) Fix Security: Insecure Pickle Deserialization enables Arbitrary Code Execution in cache handling [1 pull requests, 1 comments, 1 participants]