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.pyscript's pickle-file input path - Required access: Ability to place, replace, or otherwise cause the script to process a malicious
.pklfile - 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

