Summary
ModelScope uses PyYAML's unsafe loader to parse model configuration files, allowing specially crafted YAML to instantiate arbitrary Python objects.
When a user loads a model repository containing a poisoned configuration file, the embedded objects may execute code with the user's process privileges.
Affected context
The vulnerability occurs in ModelScope workflows that load model repositories and parse configuration files with PyYAML's unsafe yaml.Loader. Risk is higher when users obtain models from untrusted or insufficiently reviewed repositories and the configuration is processed automatically during model loading.
Exploit preconditions
- Attack surface: Model repository configuration parsing
- Required access: The attacker must be able to publish or modify a model repository or configuration consumed by a target
- Trigger point: Model configuration loading by a user's ModelScope process
- Why exploitation is possible: Unsafe YAML object-construction tags can cause attacker-controlled Python objects to be instantiated during parsing
Why this happens
The underlying bug is the use of a general-purpose YAML loader that permits Python object construction from untrusted input. Deserialization therefore interprets attacker-controlled configuration content as executable object definitions rather than as inert data. This behavior maps to CWE-502: Deserialization of Untrusted Data.
Potential impact
- An attacker may execute arbitrary code in the ModelScope process
- Malicious code could access local files, credentials, or environment variables
- The affected user account or development environment could be compromised
- Model artifacts or downstream data could be modified or poisoned
- Compromise could enable further access to connected services, depending on permissions
General mitigation guidance
Mitigation generally focuses on removing executable behavior from model configuration parsing and reducing trust in repository content.
Common defensive patterns include:
- Use safe or restricted YAML loaders that support only the required data types
- Apply strict schemas and reject unexpected tags or object constructors
- Treat model repositories and configuration files as untrusted inputs
- Review and verify repository provenance before loading models
- Run model-processing workflows with least-privilege accounts and isolated environments
- Limit access to secrets, sensitive files, and network resources from model-loading processes
How teams detect issues like this
Organizations can look for this class of issue through:
- Static analysis rules identifying
yaml.loadcalls with unsafe or unrestricted loaders - Code review checks for YAML parsing of repository-controlled files
- Dependency and policy scans that flag unsafe deserialization APIs
- Runtime monitoring for unexpected child processes, file access, or outbound connections during model loading
- Repository controls that require provenance, review, and integrity validation for model configuration files
Automated code review tools can help identify unsafe parser usage before deployment.

