Summary
A critical unsafe deserialization vulnerability in LMDeploy's PyTorch DistServe control plane allows attacker-controlled data received over ZeroMQ to be processed with Python pickle.
When an attacker can reach an affected DistServe API server and influence its peer connection, the server may execute arbitrary code with the privileges of the LMDeploy serving process.
Affected context
The vulnerability occurs in LMDeploy deployments that use the PyTorch backend with PD-disaggregation or DistServe enabled. The affected control-plane flow accepts a peer address through the /distserve/p2p_connect HTTP endpoint and subsequently deserializes messages received from a ZeroMQ PULL socket using recv_pyobj(). Ordinary deployments that do not use this disaggregated-serving path may not expose the same data flow.
Exploit preconditions
- Attack surface: The DistServe HTTP control plane and its associated ZeroMQ communication path
- Required access: Network reachability to an affected DistServe API server; authentication may be absent unless API keys are explicitly configured
- Trigger point: Processing a peer connection request followed by receipt of a serialized object over ZeroMQ
- Why exploitation is possible:
recv_pyobj()uses Python pickle deserialization, which can execute code during object reconstruction, and the receiving peer can be influenced through the control-plane endpoint
Why this happens
The underlying flaw is the use of Python pickle-based object deserialization for messages received from a network-influenced endpoint. Pickle is not a safe data-interchange format because object reconstruction can invoke attacker-controlled behavior. This maps to CWE-502: Deserialization of Untrusted Data, where serialized input is treated as trusted executable object state rather than being restricted to inert, validated data.
Potential impact
- An attacker could execute arbitrary code on the serving node
- The attacker could gain the privileges of the LMDeploy serving process
- Model assets, prompts, credentials, or operational data could be accessed or modified
- The serving environment could be used for lateral movement within trusted networks
- Availability of model-serving workloads could be disrupted
General mitigation guidance
Mitigation generally focuses on removing unsafe object deserialization and reducing exposure of the DistServe control plane.
Defensive patterns include:
- Replacing pickle-based transport with a data-only serialization format that has an explicit schema
- Validating message types, fields, sizes, and allowed values before processing them
- Restricting
/distserve/*endpoints to trusted clients and network segments - Requiring API-key or equivalent authentication for control-plane requests
- Limiting outbound ZeroMQ connections from serving nodes to approved destinations
- Running serving processes with least privilege and isolating model-serving workloads
- Applying network segmentation and deny-by-default firewall policies to HTTP and ZeroMQ control planes
Network restrictions and authentication reduce exposure but do not make pickle deserialization safe.
How teams detect issues like this
Organizations can look for this weakness through:
- Static analysis rules identifying
pickle.loads,recv_pyobj(), and equivalent unsafe deserialization APIs - Code review checks for network-derived addresses used to establish control-plane connections
- Inventory reviews identifying deployments with PyTorch DistServe or PD-disaggregation enabled
- API and network policy checks confirming that
/distserve/*and ZeroMQ listeners are not broadly reachable - Runtime monitoring for unexpected peer connections, unusual ZeroMQ destinations, or child processes spawned by serving workers
- Automated security review tools that flag unsafe deserialization and unauthenticated administrative endpoints

