Summary
SGLang contains a critical code-injection vulnerability in the
/update_weights_from_tensor endpoint, where pickle data can be deserialized
without authentication when no authorization keys are configured. A bypass of
the intended SafeUnpickler restrictions may allow an attacker to execute
arbitrary code on the SGLang service host.
Affected context
The vulnerability occurs in SGLang deployments that expose the
/update_weights_from_tensor endpoint and do not configure authentication
keys. Risk is increased when the endpoint is reachable by untrusted clients
and the service processes attacker-controlled serialized weight-update data
before applying effective authorization and deserialization restrictions.
Exploit preconditions
- Attack surface: Network-accessible SGLang weight-update endpoint
- Required access: No authentication when authorization keys are absent
- Trigger point: Processing attacker-controlled data by
/update_weights_from_tensor
- Why exploitation is possible: Pickle deserialization can invoke
dynamically resolved objects, while the SafeUnpickler policy does not
sufficiently restrict all resolution paths
Why this happens
The underlying issue is the use of pickle deserialization on data that may be
controlled by an unauthenticated remote client. Although SGLang applies a
SafeUnpickler policy, permitted resolution of callable built-in objects such
as import and getattr can undermine the intended restrictions when pickle
reduction behavior is processed. This represents CWE-94, Code Injection,
because attacker-influenced serialized data can cause executable behavior
rather than being treated solely as inert data.
Potential impact
- An attacker may execute arbitrary code in the SGLang process context.
- The attacker could access or modify data available to the service account.
- The affected host or container could be used for lateral movement.
- Model artifacts, weights, or workloads could be altered or sabotaged.
- Service availability could be disrupted.
General mitigation guidance
Mitigation generally focuses on eliminating executable deserialization from
network-facing paths and enforcing authentication by default.
Common defensive patterns include:
- Replacing pickle with a data-only serialization format that does not support
arbitrary object construction.
- Applying strict, allowlisted schemas and types to weight-update inputs.
- Enforcing authentication and authorization for every weight-management
operation, including deployments with default or missing configuration.
- Binding administrative endpoints to restricted networks or control planes.
- Running the service with least privilege and isolating model-processing
workloads from sensitive host and cluster resources.
- Treating serialized inputs as untrusted regardless of their apparent origin.
How teams detect issues like this
Detection can include static analysis for pickle loading, custom unpickler
implementations, dynamic import resolution, and callable resolution in
network request handlers. Code review should examine whether administrative
endpoints remain reachable without configured credentials, whether
deserialization occurs before authorization, and whether allowlists can be
bypassed through indirect object resolution. Runtime monitoring can alert on
unexpected access to weight-update endpoints, anomalous child processes, or
outbound connections from inference services. Automated security review tools
and CI policy checks can help identify unsafe deserialization and missing
authentication controls.

