Summary
LMDeploy's RPC server deserializes incoming messages with Python pickle without sufficient sanitization. If an attacker can reach the RPC endpoint and send a crafted message, they may execute arbitrary code in the server process.
Affected context
The vulnerability occurs in LMDeploy deployments that enable the RPC server and expose its message-handling functionality to an untrusted or insufficiently isolated network. It affects the response-processing path when incoming RPC data is passed directly to pickle deserialization without authentication, validation, or an equivalent trust boundary.
Exploit preconditions
- Attack surface: LMDeploy's network-accessible RPC server
- Required access: Ability to connect to the RPC endpoint and submit messages; authentication requirements depend on deployment configuration
- Trigger point: Processing of an incoming message in the RPC request-and-response workflow
- Why exploitation is possible: Python pickle deserialization can invoke attacker-influenced object behavior rather than merely reconstructing inert data
Why this happens
The underlying bug is the use of pickle.loads() on received network data without establishing that the data originated from a trusted source or conforms to a safe data format. Python pickle is capable of reconstructing objects with executable behavior, so treating untrusted serialized bytes as application data creates an unsafe deserialization condition mapped to CWE-502.
Potential impact
- An attacker may execute arbitrary code in the LMDeploy server process
- The attacker could access model files, credentials, or other process-accessible data
- The service may be disrupted, altered, or used to launch further attacks
- A compromised host or container could enable lateral movement depending on runtime privileges and network access
General mitigation guidance
Mitigation generally focuses on removing executable deserialization from network-facing RPC paths and reducing exposure of the service.
Common defensive patterns include:
- Replacing pickle-based transport with a non-executable, schema-constrained format
- Authenticating and authorizing RPC clients before accepting messages
- Restricting RPC listener exposure through network policies, firewalls, and private service boundaries
- Validating message types, sizes, and fields before application processing
- Running the server with least-privilege accounts and isolated runtime permissions
- Treating serialized data from external or cross-trust-boundary sources as untrusted by default
How teams detect issues like this
Detection can combine source analysis, runtime monitoring, and deployment policy enforcement:
- Use static analysis rules to flag
pickle.loads,pickle.load, and related deserialization APIs on network-derived data - Review RPC handlers for missing authentication, authorization, schema validation, or trust-boundary checks
- Monitor unexpected RPC clients, anomalous request volumes, and process behavior such as child-process creation
- Enforce policies that prohibit executable serialization formats in externally reachable service interfaces
- Use automated code-review and software-composition tools to identify unsafe deserialization patterns and exposed service configurations

