CVE-2022-23915
Vulnerable Weblate versions (0 to 4.11.1) allow authenticated users to execute remote code via argument injection in Git or Mercurial repositories
- CVSS 8.8
- CWE-88 Improper Neutralization of Argument Delimiters in a Command ('Argument Injection')
- Input Validation and Sanitization
- Remote
The package weblate from 0 and before 4.11.1 are vulnerable to Remote Code Execution (RCE) via argument injection when using git or mercurial repositories. Authenticated users, can change the behavior of the application in an unintended way, leading to command execution.
- CVSS base score
- 8.8
- Published
- 2022-03-04
- OWASP
- A03 Injection
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- Weblate
- Fixed by upgrading
- Yes
Solution
Update weblate to version 4.11.1 or higher.
Vulnerable code sample
import subprocess
def clone_repository(repo_url):
# Directly using the repo_url in the command without validation
command = f"git clone {repo_url}"
subprocess.run(command, shell=True)
# Example usage
clone_repository("https://example.com/repo.git; rm -rf /") # Potentially malicious inputPatched code sample
import subprocess
import shlex
def safe_clone_repository(repo_url):
# Validate the repository URL to prevent command injection
if not is_valid_repo_url(repo_url):
raise ValueError("Invalid repository URL")
# Use shlex to safely split the command
command = f"git clone {repo_url}"
subprocess.run(shlex.split(command), check=True)
def is_valid_repo_url(url):
# Implement strict validation for the repository URL
# For example, allow only specific formats or whitelisted domains
return url.startswith("https://") or url.startswith("git@")
# Example usage
try:
safe_clone_repository("https://example.com/repo.git")
except Exception as e:
print(f"Error: {e}")Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- vcs: Improve mercurial parameters handling (WeblateOrg/weblate)
weblate/vcs/mercurial.py · HgRepository.configure_branch,weblate/vcs/mercurial.py · HgRepository.push,weblate/vcs/mercurial.py · HgRepository.update_remote,weblate/vcs/mercurial.py · HgRepository._clone - vcs: Improve git parameters handling (WeblateOrg/weblate)
weblate/vcs/git.py · GitRepository.get_remote_branch,weblate/vcs/git.py · GitRepository._clone,weblate/vcs/git.py · SubversionRepository.get_remote_args
Cite this entry
@misc{vaitp:cve202223915,
title = {{Vulnerable Weblate versions (0 to 4.11.1) allow authenticated users to execute remote code via argument injection in Git or Mercurial repositories}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2022},
note = {VAITP Python Vulnerability Dataset, entry CVE-2022-23915},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2022-23915/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
