Summary
SGLangs' multimodal generation runtime can deserialize untrusted Python objects via dill.loads() when the --enable-custom-logit-processor option is enabled, allowing attacker-controlled data to be treated as executable code.
In deployments where remote users can influence or supply custom logit processor data, this behavior can lead to unauthenticated remote code execution within the runtime environment.
Affected context
This vulnerability manifests in SGLangs multimodal generation runtime instances that:
- Are configured with the
--enable-custom-logit-processoroption enabled - Accept or process custom logit processor definitions, configurations, or state across a network boundary
- Use
dill.loads()to reconstruct Python objects from serialized data without restricting the source or applying validation
Under these conditions, any data reaching the deserializer may be treated as trusted executable objects, expanding a remote attacker's control over the runtime process.
Exploit preconditions
- Attack surface: Network-exposed SGLangs runtime with custom logit processors enabled.
- Required access: Ability to submit or influence serialized logit processor data (e.g., over an API, message queue, or other integration input).
- Trigger point: Invocation of
dill.loads()on attacker-controlled serialized data during logit processor loading or execution. - Why exploitation is possible:
dill.loads()is a general-purpose deserializer that can instantiate arbitrary Python objects and execute associated code during reconstruction, and no validation or sandboxing is applied before or during deserialization.
Why this happens
The core issue is the use of a powerful deserialization mechanism (dill.loads()) on data that is not guaranteed to be trustworthy, while running in a high-privilege, long-lived server process.
This aligns with CWE-502: Deserialization of Untrusted Data, where serialized input is treated as benign state but the deserializer can instantiate arbitrary object graphs whose constructors or special methods may execute attacker-chosen code.
Because custom logit processors are treated as flexible, pluggable Python objects, the implementation implicitly extends full interpreter capabilities to any party who can supply serialized processor definitions, resulting in a direct path to code execution.
Potential impact
- Remote attackers can execute arbitrary Python or OS-level commands within the SGLangs runtime process.
- Complete compromise of the model-serving environment, including access to in-memory secrets, tokens, and sensitive data passing through the runtime.
- Abuse of the host system for further lateral movement within the infrastructure.
- Tampering with inference behavior, including output manipulation, data exfiltration through model responses, and poisoning of downstream systems.
- Service disruption or denial of service by running resource-exhausting code within the runtime.
General mitigation guidance
Since the vulnerability arises from unsafe deserialization, mitigations should focus on eliminating or heavily constraining the use of general-purpose object deserializers for untrusted data.
Defensive patterns include:
- Disable unsafe features by default: Treat
--enable-custom-logit-processoras a high-risk option and avoid enabling it in multi-tenant or internet-exposed deployments unless strictly necessary. - Use safer data formats: Prefer structured, declarative formats (JSON, YAML with safe loaders, or strongly typed configs) for defining logit processors rather than serialized Python objects.
- Introduce explicit allowlists: If extensibility is required, load custom processors from vetted, signed modules or an allowlisted registry instead of arbitrary serialized objects.
- Enforce strong trust boundaries: Only accept custom processor definitions from highly trusted administrative channels, never from general user traffic.
- Run with least privilege: Execute the runtime in a constrained environment (separate account, container, limited filesystem and network access) to reduce the blast radius of potential code execution.
- Apply defense-in-depth controls: Combine network-level restrictions, authentication, and strict API design so that only authorized automation or operators can change model behavior or load extensions.
How teams detect issues like this
Detection should focus on both code-level patterns and runtime behavior indicative of unsafe deserialization.
Possible approaches:
- Static analysis rules: Flag uses of
dill.loads(),pickle.loads(), or similar APIs in request-handling paths or any code that processes externally influenced data. - Targeted code review: During review, treat any deserialization of Python objects as security-sensitive and verify that inputs are strictly trusted, constrained, or replaced with safer formats.
- Configuration audits: Periodically scan deployments to identify instances where
--enable-custom-logit-processoris enabled, and correlate with the exposure level of the associated endpoints. - Runtime monitoring: Instrument logging around custom logit processor loading; alert on unexpected or frequent processor changes, unusual module imports, or anomalous subprocess launches from the runtime.
- Policy enforcement in CI/CD: Use automated tools or custom checks to prevent introduction of new unsafe deserialization patterns and to enforce that high-risk options are disabled in standard deployment templates.

