← Index berkoc · research
Critical published

Unauthenticated Remote Code Execution in LMDeploy DistServe via Pickle Deserialization

The PyTorch DistServe control plane in LMDeploy deserialized ZeroMQ messages with recv_pyobj (pickle). An unauthenticated attacker reachable at POST /distserve/p2p_connect could point the server at a hostile ZeroMQ endpoint and execute code during deserialization.

Vendor
InternLM/lmdeploy · pypi
CVE
CVE-2025-66455
GHSA
GHSA-2vh9-42vm-xmv2
CWE
CWE-502
CVSS
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H (9.8)
Disclosed
Patched
0.16.0

Background

LMDeploy is a serving and quantisation toolkit for large language models, maintained by InternLM. One of its deployment modes is PD-disaggregation, marketed under the name DistServe, which splits the prefill and decode phases of inference across separate engine processes so they can be scaled independently. Those processes coordinate over a control plane, and the control plane is where this issue sits.

The finding is credited to several reporters; this page documents the vulnerability as published in the coordinated advisory GHSA-2vh9-42vm-xmv2 and assigned CVE-2025-66455. It is recorded here as a reporter credit, not as sole discovery.

The vulnerability

The DistServe control plane exchanged messages over a ZeroMQ PULL socket and read them with PyZMQ's recv_pyobj(). That convenience method is implemented on top of Python's pickle module, and unpickling is not a data operation, it is code execution: reconstructing a pickled object runs whatever __reduce__ logic the payload carries, before any application-level validation can look at the data.

The peer address that the receiver connected to was not fixed by the operator. It was supplied by the caller through an HTTP endpoint:

  • Entry point: POST /distserve/p2p_connect in lmdeploy/serve/openai/endpoints/distserve.py
  • Attacker-controlled value: DistServeConnectionRequest.remote_engine_endpoint_info.zmq_address
  • Vulnerable receiver: EngineP2PConnection.handle_zmq_recv() in lmdeploy/pytorch/disagg/conn/engine_conn.py
  • Unsafe operation: recv_pyobj(), i.e. pickle deserialization

API-key authentication in LMDeploy is off unless the operator turns it on. A DistServe deployment left in its default configuration therefore accepted the connection request from anyone who could reach the API server.

The data flow

  1. A caller submits a DistServe P2P connection request carrying a ZeroMQ address.
  2. The LMDeploy engine connects its ZeroMQ PULL socket to that address.
  3. handle_zmq_recv() reads incoming messages with recv_pyobj().
  4. A malicious peer sends a crafted pickle object.
  5. Python code runs during deserialization, before LMDeploy can perform any type or field check.

The last step is the reason a type check placed after recv_pyobj() does not help: the payload has already executed by the time the returned object is available to inspect. The fix has to move the trust boundary, not guard behind it.

Impact

Successful exploitation gives arbitrary code execution as the LMDeploy serving process. In a model-serving context that process typically has reach into model weights, live prompts, credentials, attached storage, cluster-internal network services and GPU resources, and it can be modified or terminated by the attacker. Because the affected path requires PD-disaggregation to be enabled, ordinary single-process deployments do not expose this data flow.

Fix

Resolved in LMDeploy 0.16.0. The class of defect, CWE-502, is fixed the way every pickle-over-the-network sink has to be fixed: by not deserialising untrusted input with pickle. Operators who cannot upgrade immediately should ensure API-key authentication is enabled and that the DistServe control plane is not reachable from untrusted networks, but those are mitigations around the endpoint, not a substitute for removing the pickle sink.