Summary
SpeechBrain before 1.1.1 contains an unsafe YAML deserialization flaw in checkpoint metadata processing. An attacker who can place a crafted CKPT.yaml file in a configured checkpoint path may achieve arbitrary code execution during checkpoint candidate discovery, even when that checkpoint is not selected for recovery.
Affected context
The vulnerability occurs in SpeechBrain deployments that use Checkpointer.recover_if_possible() to discover available checkpoints and parse CKPT.yaml metadata with an unsafe PyYAML loader. The risk is present when an attacker can add or modify checkpoint metadata within a path that the application scans, and parsing occurs before the checkpoint is selected for recovery.
Exploit preconditions
- Attack surface: Checkpoint discovery and metadata parsing
- Required access: Ability to place or modify a CKPT.yaml file within the configured checkpoint path
- Trigger point: Candidate enumeration performed by Checkpointer.recover_if_possible()
- Why exploitation is possible: Unsafe deserialization may instantiate attacker-controlled Python objects while scanning metadata, regardless of whether the associated checkpoint is ultimately selected
Why this happens
The underlying bug is the use of a permissive YAML deserialization mechanism for checkpoint metadata that may not be fully trusted. Such loaders can interpret special YAML type information as instructions for constructing Python objects rather than treating the file as ordinary data. This behavior maps to CWE-502: Deserialization of Untrusted Data, because attacker-controlled serialized content can cause unintended code execution during parsing.
Potential impact
- Attackers may execute arbitrary code with the privileges of the SpeechBrain process
- The application environment could be compromised
- Accessible credentials, datasets, or model artifacts may be exposed or altered
- Checkpoint and machine-learning workflows could be manipulated
- A compromised process could support lateral movement when network or filesystem permissions allow it
General mitigation guidance
Mitigation generally centers on removing executable behavior from checkpoint metadata parsing and reducing trust in checkpoint directories.
Common defensive patterns include:
- Using safe, restricted YAML parsers that permit only expected scalar and collection types
- Applying strict schemas and rejecting unknown metadata fields before use
- Treating downloaded, shared, and generated checkpoints as untrusted inputs
- Restricting write access to configured checkpoint paths
- Separating checkpoint processing workloads and running them with least-privilege identities
- Limiting filesystem, network, and credential access available to the SpeechBrain process
- Using integrity verification and controlled artifact repositories for checkpoint files
How teams detect issues like this
Detection approaches may include:
- Static analysis rules identifying permissive PyYAML loaders and generic deserialization calls
- Code review checks for parsing checkpoint or model metadata before schema validation
- Repository policies that prohibit executable YAML object tags in application-managed files
- Monitoring for unexpected CKPT.yaml creation or modification in configured checkpoint directories
- Runtime alerts for unusual child processes, filesystem changes, or outbound connections from SpeechBrain workers
- Automated security review tools that flag unsafe deserialization patterns during development

