Summary
A path traversal vulnerability in the Bert-VITS2 Model Handler's _get_all_models function in hiyoriUI.py allows attackers to manipulate filesystem paths when listing or accessing models.
When user-controlled input is used to construct file paths without proper validation, a remote attacker may traverse directories and interact with files outside the intended model directory.
Affected context
This issue affects Bert-VITS2 deployments that expose the Model Handler component, particularly where _get_all_models processes paths derived from user input or external configuration.
The risk is higher when the service runs with broad filesystem permissions, shares the host filesystem, or is deployed in environments where model directories reside alongside sensitive configuration or data files.
Since the project uses continuous delivery with rolling releases, the exact affected commit range is not clearly delineated and operators should treat any deployment up to the reported commit as potentially vulnerable.
Exploit preconditions
- Attack surface: Remote, via HTTP or RPC endpoints (or UI actions) that cause
_get_all_modelsto run with attacker-influenced path parameters. - Required access: Ability to send requests to the Bert-VITS2 service or UI; no special OS-level access is typically required.
- Trigger point: Any code path where
_get_all_modelsconstructs filesystem paths using unvalidated or unsanitized user input (e.g., directory names, model identifiers). - Why exploitation is possible: The function trusts incoming path components and concatenates them into filesystem paths without normalizing, constraining them to an allowed base directory, or rejecting traversal sequences such as
../.
Why this happens
The underlying bug is an instance of CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').
The Model Handler code likely builds file system paths by joining a base directory with user-controlled input while failing to:
- Normalize and canonicalize the resulting path.
- Enforce that the resolved path remains inside an expected root directory (e.g., a dedicated models folder).
- Strip or reject traversal patterns (
.., absolute paths, or path separator injection).
As a result, the file operations performed by _get_all_models (such as listing, reading, or inspecting model files) can be redirected to unintended locations on the server's filesystem.
Potential impact
- Read access to arbitrary files that the service account can access (e.g., configuration files, logs, or secrets stored alongside the application).
- Discovery of file and directory structure, aiding in further attacks or privilege escalation.
- Potential write or overwrite of files, if the underlying logic also supports file creation, updates, or deletion through model management features.
- Indirect compromise of application integrity by manipulating model files, leading to tampered or malicious models being loaded at runtime.
General mitigation guidance
Effective mitigation focuses on strictly controlling how file paths are constructed and validated:
- Constrain all file operations to a single, predefined model root directory, and enforce this invariant in one central utility.
- Normalize and resolve constructed paths (e.g., using standard library functions) and reject any path that, once resolved, falls outside the intended root directory.
- Treat all path-like input as untrusted; only accept whitelisted identifiers (e.g., model IDs) and map them to server-side paths, rather than letting clients supply raw paths.
- Apply least-privilege to the process or container so it only has filesystem access necessary for model operations, reducing the blast radius of any traversal bugs.
- Separate sensitive configuration, secrets, and host-level files from the directories exposed to the model management subsystem.
How teams detect issues like this
Detection can leverage a combination of code-centric and operational approaches:
- Static analysis: Use rules or linters to flag direct concatenation of user input into filesystem paths and missing validation around path normalization and root checks.
- Code review: Look for any use of
_get_all_modelsor similar handlers that accept raw directory names, model paths, or file patterns from request parameters or UI fields, and confirm that canonicalization and base-path enforcement are present. - Runtime monitoring: Enable application and web server logging for suspicious file accesses, particularly requests containing traversal sequences (
../) or unusual absolute paths. - Security testing: Incorporate automated tests or DAST tools that probe model-related endpoints with traversal payloads to detect regressions in CI/CD pipelines.

