[ai] fix(security): serialize Mojo shared-memory payloads as JSON, not pickle - #1832
Draft
github-actions[bot] wants to merge 1 commit into
Draft
[ai] fix(security): serialize Mojo shared-memory payloads as JSON, not pickle#1832github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
Replace pickle.dumps in MojoTransportLayer._shared_memory_send with a JSON payload built from the existing UnifiedMessage/A2AMessage/MCPContext to_dict() methods. A receiver that unpickles data read from a cross-process shared-memory segment can be forced into arbitrary code execution by a malicious or compromised writer; JSON has no executable payload. Adds a regression test asserting the module no longer imports pickle and that the shared-memory write is valid JSON. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Canonical issue
Closes #913. Supersedes stale draft PR #1596 (same intent, but that branch carries ~8,800 unrelated lines of pre-rewrite
maindrift and was never verified in CI — the author's own PR description notes "the session ended before tests could be run").Problem
src/agents/unified/mcp_a2a_mojo_integration.pyusedpickle.dumps(message)to serializeUnifiedMessageinto a cross-process shared-memory segment (MojoTransportLayer._shared_memory_send). A receiver that laterpickle.loads-decodes bytes read from shared memory can be forced into arbitrary code execution by a malicious or compromised writer on the other end of that IPC channel — the same RCE pattern already remediated for the Redis cache path elsewhere in this repo (seeintelligent_cache.py, "pickle removed for security").Fix
pickleimport._shared_memory_sendnow builds a plain JSON payload from the existingto_dict()methods already implemented onUnifiedMessage'sA2AMessageandMCPContextmembers (plus the transport-strategy enum value and scalar fields), thenjson.dumps(...).encode("utf-8")._zero_copy_send,_pipe_send,_handle_passing_send).Verification
PYTHONPATH=src python -m pytest tests/unit/test_security_fixes.py -v --no-cov→ 21 passed (19 pre-existing + 2 new).PYTHONPATH=src python -m pytest tests/unit/ -k "mcp_a2a or mojo or a2a or security_fixes" --no-cov -q→ 50 passed, 8184 deselected.python -m py_compile src/agents/unified/mcp_a2a_mojo_integration.py tests/unit/test_security_fixes.py→ OK.UnifiedMessageand called_shared_memory_senddirectly — result payload is validjson.loads-parseable UTF-8 with no pickle opcodes, confirmed by the new regression testTestMojoSharedMemoryPickleFix::test_shared_memory_send_serializes_as_json.ruff checkon the touched region shows no new findings (remaining lint hits in the same file are pre-existingE402s unrelated to this change).New test coverage
Added
TestMojoSharedMemoryPickleFixtotests/unit/test_security_fixes.py:import pickle/pickle.dumps/pickle.loads.UnifiedMessagethrough_shared_memory_sendand asserts the shared-memory bytes are valid JSON containing the expected fields, then cleans up the shared-memory block.Repo-context notes
This run of the
pr-iteration-loopselected this checkpoint under priority 2 (open PRs unresolved >7 days) after verifying that the workflow-run candidates supplied inpr-iteration-loop-context.json(Security Scan / PR Governance / API cost PostgreSQL / CI failures oncursor/videopack-paste-url-fee2andcursor/public-video-pack-emit-fb40) were all tied to branches already merged/closed via PR #1609 on 2026-09-02, with zero reproducible failures remaining on currentmain(gh run list --branch mainshows 100% success in the trailing window). Full triage evidence, the staleness chart, and the pattern recommendation are recorded in the workflow's cache-memory for future runs.Recommended automation pattern for this class of work: Continuous AI — a bounded, LLM-verifiable code fix discovered by triaging existing CI/PR/issue signal through standard platform tooling (
gh,pytest,ruff), not a real-time multiplayer task (Chopin), a simple fixed-goal loop with no repo-signal triage (Autoloop), or bespoke natural-language GitHub Actions authoring (Agentic Workflows).Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com