Summary
CosyVoice's make_parquet_list.py data processing tool unsafely deserializes PyTorch .pt files using torch.load() without the weights_only=True security parameter, allowing arbitrary object loading through pickle.
If an attacker can introduce malicious .pt files into a processed data directory, running the tool can execute attacker-controlled code on the victim's machine.
Affected context
This vulnerability appears in environments where CosyVoice's make_parquet_list.py script is used to process directories of PyTorch .pt files containing utterance embeddings, speaker embeddings, or speech tokens.
The risk materializes when .pt files come from partially or fully untrusted sources (e.g., shared datasets, external contributors, or automated ingestion pipelines) and are processed without prior validation or isolation.
Systems such as experiment pipelines, training workflows, or batch preprocessing jobs that routinely run this script over large, mixed-trust datasets are particularly exposed.
Exploit preconditions
- Attack surface: Local execution of the make_parquet_list.py tool on a system where CosyVoice is installed.
- Required access: Ability to place or modify .pt files inside a directory that will be processed by the script (e.g., write access to a dataset folder).
- Trigger point: Invocation of make_parquet_list.py on the attacker-controlled directory, causing torch.load() to deserialize the malicious .pt files.
- Why exploitation is possible: torch.load() uses Python's pickle under the hood and, without weights_only=True or a restricted deserialization policy, it will reconstruct arbitrary Python objects that can execute code during unpickling.
Why this happens
The core issue is the use of a general-purpose deserialization mechanism for data that may not be fully trusted, a classic unsafe deserialization pattern described by CWE-502.
In this case, make_parquet_list.py calls torch.load() on .pt files without enabling protections like weights_only=True or enforcing a constrained format, effectively delegating trust to the pickle protocol.
Pickle is capable of reconstructing arbitrary Python objects, some of which can trigger code execution when they are deserialized.
This design treats external model/data artifacts as inherently trusted executable state instead of plain, inert data structures, allowing attacker-supplied .pt files to carry and execute malicious payloads during processing.
Potential impact
- Execution of arbitrary Python or OS-level commands under the privileges of the user running the script
- Compromise of developer or researcher workstations used for data preprocessing and experimentation
- Theft or modification of sensitive data accessible to the compromised environment (e.g., training data, credentials, SSH keys)
- Tampering with ML pipelines, including poisoning datasets or altering downstream training artifacts
- Use of compromised systems as a foothold for lateral movement within internal networks
General mitigation guidance
Effective mitigation focuses on reducing trust in serialized artifacts and constraining deserialization behavior:
- Prefer safe loading modes for PyTorch artifacts, such as using torch.load() with weights_only=True when only tensor weights or embeddings are needed.
- Design serialization formats around simple, structured data (e.g., tensors, arrays, JSON-compatible objects) rather than arbitrary Python objects.
- Introduce a clear trust boundary for dataset and model files, treating external or shared .pt files as untrusted by default.
- Run preprocessing and data ingestion scripts under least-privilege user accounts, ideally inside containers or isolated environments to minimize blast radius.
- Add validation steps that enforce expected shapes, dtypes, and keys for deserialized structures before they are used in the pipeline.
- Document secure usage patterns for contributors and users, emphasizing that serialized binaries should not be treated as safe just because they are "model" or "embedding" files.
How teams detect issues like this
Detection generally combines code-centric review with pipeline-level monitoring:
- Static analysis and code review:
- Search for torch.load() and similar APIs (e.g., pickle.load, joblib.load) and flag call sites that deserialize externally supplied files.
- Verify whether security-focused parameters (such as weights_only=True) or equivalent guards are in place when loading .pt files.
- Look for data-processing scripts that automatically traverse directories and load files without validating origin or content type.
- Policy and tooling:
- Enforce secure deserialization guidelines through coding standards and pre-merge checks in CI pipelines.
- Use automated review tools or linters configured to highlight unsafe deserialization patterns.
- Maintain an inventory of scripts and services that ingest model or embedding artifacts, prioritizing them for manual security review.
- Runtime monitoring:
- In sensitive environments, consider running data-processing jobs in monitored sandboxes where unexpected system calls or network activity from such tools are flagged.

