Severity:

CRITICAL RISK

(9.8)

Unsafe Deserialization in SGLangs Multimodal Generation

CVE-2026-7304

Analyzed

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Unauthenticated Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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-processor option 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-processor as 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-processor is 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.

Sources

SourceLink
antiproof.aiantiproof.ai/blog/three-rces-in-sglang/
github.comgithub.com/sgl-project/sglang/tree/main/python/sglang

Frequently asked

questions

Yes. When the runtime is exposed over a network and accepts or processes custom logit processor data from remote clients, an attacker can potentially trigger code execution without prior authentication.

Not necessarily. If the interface that accepts custom logit processor data is accessible without strong authentication, exploitation can be unauthenticated. In more locked-down setups, an attacker would first need access to whichever channel controls processor definitions.

The most robust pattern is to avoid deserializing arbitrary Python objects for runtime configuration or extension mechanisms. Replace dill.loads() with safer, data-only formats, restrict extensibility to pre-deployed code modules, and ensure that any remaining dynamic loading operates only on trusted, validated inputs.

Design extension and configuration mechanisms around declarative, schema-validated data rather than serialized executable objects; treat any deserialization API as security-critical, apply threat modeling to new plugin/extension features, and institutionalize static analysis and security review for dangerous primitives such as pickle, dill, or equivalent mechanisms in other languages.

Find out what's already
exploitable in your codebase.