Summary
Weblate versions prior to 5.17 include Git and Mercurial configuration files in project backups without proper filtering, allowing potentially dangerous repository configuration to be preserved and restored.
Under certain conditions, a user who can create projects and obtain or influence these backups may trigger remote code execution when those configuration files are later used by the underlying VCS tooling.
Affected context
The vulnerability arises in Weblate's project backup and restore functionality for instances running versions before 5.17.
It is relevant when:
- Project backups include full Git or Mercurial metadata, including
.git/config,.hg/hgrc, or related configuration files. - The environment where backups are restored or otherwise processed subsequently invokes Git or Mercurial commands that honor those configurations.
- Users with project-creation permissions can generate or influence backups and, in some deployment models, download or move them to other systems.
The issue is bounded to contexts where VCS configuration directives can affect command execution by the hosting environment.
Exploit preconditions
- Attack surface: Weblate's project backup and restore mechanism, plus any external or internal process that consumes the backed-up repositories.
- Required access: Ability to create projects and trigger or obtain backups; in many deployments this implies authenticated access with project-creation privileges.
- Trigger point: Use of the backed-up repositories (or their configuration files) by Git or Mercurial—such as during clone, fetch, push, hooks execution, or other VCS operations that respect repository configuration.
- Why exploitation is possible: Backup export does not filter or sanitize Git/Mercurial configuration files, allowing adversary-controlled configuration to persist and later influence command behavior, which can, under specific setups, be escalated into remote code execution.
Why this happens
The core issue is the inclusion of unfiltered, user-influenced VCS configuration files in project backups.
This maps to CWE-434 (Unrestricted Upload of File with Dangerous Type) and is related to CWE-94 (Code Injection) and CWE-23 (Path Traversal), because:
- Weblate treats repository data as inert content but allows configuration files that can alter how Git or Mercurial execute commands.
- These configuration files are effectively "dangerous types" since they can drive hooks, custom commands, or remotes, potentially leading to command execution when the repository is later used.
- The backup/restore process does not enforce a strict boundary between safe project data and executable or configuration logic that the VCS interprets, creating an implicit code injection vector mediated by VCS tooling.
Potential impact
- Remote code execution in the environment where Git or Mercurial process the restored repository.
- Compromise of the Weblate host or associated CI/CD infrastructure that uses those repositories.
- Unauthorized access to source code or translation content handled by the affected repositories.
- Lateral movement into other services integrated with the VCS or Weblate instance.
- Data tampering or injection into localized resources, leading to integrity and supply-chain concerns.
General mitigation guidance
Effective mitigation focuses on treating VCS configuration as untrusted and separating data from executable or configuration logic:
- Exclude or sanitize VCS configuration files (e.g.,
.git/config,.hg/hgrc, hooks directories) during backup and restore operations, preserving only content necessary for localization. - Implement allowlists for file types and paths that can be included in backups; default to excluding executable, configuration, or hook-related artifacts.
- Run VCS operations in constrained environments with least privilege, limiting the ability of hooks or configuration to spawn arbitrary processes or access sensitive resources.
- Harden the surrounding infrastructure (e.g., CI/CD agents and automation jobs) so they do not implicitly trust repository configuration or hooks, and disable automatic hook execution where feasible.
- Restrict access to project backup functionality and storage locations, ensuring only strictly necessary roles can create, download, or import backups.
How teams detect issues like this
Detection typically combines configuration review, file-level inspection, and process monitoring:
- Use static or offline analysis to inspect project backups for the presence of
.git,.hg, and related configuration or hook files; flag backups that contain unexpected executable or configuration content. - Establish policy-based checks in CI/CD or repository import pipelines that reject or quarantine repositories containing disallowed configuration patterns, hooks, or suspicious VCS directives.
- During code and infrastructure reviews, look for backup/restore paths that copy or archive entire repository directories without filtering; pay attention to any logic that later executes VCS commands on those directories.
- Leverage automated scanning tools that can parse archives and repositories, reporting potentially dangerous file types (hooks, configuration files, scripts) in data paths expected to be content-only.
- Monitor runtime logs and process activity for unusual Git/Mercurial invocations or hook executions triggered during backup import, mirroring, or synchronization workflows.

