Severity:

HIGH RISK

(7.8)

Unsafe Pickle Deserialization (CWE-502) in SGLang Script

CVE-2026-3989

Analyzed

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution

Severity:

HIGH RISK

(7.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

SGLang's replay_request_dump.py uses pickle.load() without adequately validating or safely constraining the input. If an attacker can provide a malicious .pkl file to the script, deserialization may execute attacker- controlled code on the device running it.

Affected context

The vulnerability occurs in environments where SGLang's replay_request_dump.py processes pickle files from an untrusted or insufficiently controlled source. Risk increases when the script runs with meaningful operating-system permissions or handles files transferred from users, shared storage, automated pipelines, or external systems.

Exploit preconditions

  • Attack surface: The replay_request_dump.py script's pickle-file input path
  • Required access: Ability to place, replace, or otherwise cause the script to process a malicious .pkl file
  • Trigger point: Execution of pickle.load() while replay data is loaded
  • Why exploitation is possible: Python pickle deserialization can invoke behavior encoded in the serialized object, and the input is not adequately validated before loading

Why this happens

The root cause is the use of Python pickle deserialization for data that may cross a trust boundary without sufficient safety controls. Pickle is not a data-only interchange format; loading an attacker-controlled stream can reconstruct objects with execution-capable behavior. This maps to CWE-502, Unsafe Deserialization, because untrusted serialized data is processed as trusted object state.

Potential impact

  • An attacker may execute arbitrary code with the privileges of the SGLang process
  • The affected device could be compromised or used for further access
  • Local data, model artifacts, or credentials could be exposed or altered
  • A compromised worker may be used for persistence, lateral movement, or resource abuse

General mitigation guidance

Mitigation generally focuses on eliminating unsafe deserialization of

attacker-controlled data and reducing trust in replay files.

Common defensive patterns include:

  • Prefer data-only formats with safe parsers and explicit schemas over pickle
  • Treat replay files as untrusted input and validate structure, types, size, and provenance
  • Separate parsing from execution and reject unexpected object types before processing
  • Run replay tooling with least privilege, filesystem restrictions, and limited network access
  • Use isolated environments for analysis of files that cannot be independently trusted
  • Restrict file creation and replacement permissions in shared directories and pipelines

How teams detect issues like this

Organizations can look for:

  • Static-analysis findings involving pickle.load(), pickle.loads(), or equivalent deserialization APIs
  • Code-review signals showing pickle data crossing user, network, upload, or shared-storage trust boundaries
  • Repository policies that prohibit unsafe deserialization of untrusted files
  • Runtime monitoring for unexpected child processes, file changes, or network activity from replay tooling
  • Automated security review tools configured to flag unsafe deserialization patterns and missing input validation

Sources

SourceLink
github.comgithub.com/sgl-project/sglang/blob/main/scripts/playground/replay_request_dump.py
github.comgithub.com/sgl-project/sglang/pull/20904
github.comgithub.com/sgl-project/sglang/releases/tag/v0.5.10
orca.securityorca.security/resources/blog/sglang-llm-framework-rce-vulnerabilities/

Frequently asked

questions

It is not necessarily network-reachable by itself. Exploitability depends on

whether an attacker can place or influence a pickle file that the script will

process, including through a remote upload, shared location, or automated

pipeline.

The attacker needs the ability to supply, replace, or cause processing of a

malicious .pkl file. The resulting code runs with the permissions of the

process executing the script.

Avoid loading untrusted pickle data. Use a data-only serialization format with

strict schema and type validation, and isolate any unavoidable legacy parsing

from sensitive systems.

Define clear trust boundaries for serialized files, enforce secure parser

policies in code review and CI, restrict file permissions, and run replay

utilities with minimal privileges and network access.

Find out what's already
exploitable in your codebase.