CVE-2022-22984
Command Injection in Snyk packages before specified versions
- CVSS 6.3
- CWE-78
- Input Validation and Sanitization
- Remote
The package snyk before 1.1064.0; the package snyk-mvn-plugin before 2.31.3; the package snyk-gradle-plugin before 3.24.5; the package @snyk/snyk-cocoapods-plugin before 2.5.3; the package snyk-sbt-plugin before 2.16.2; the package snyk-python-plugin before 1.24.2; the package snyk-docker-plugin before 5.6.5; the package @snyk/snyk-hex-plugin before 1.1.6 are vulnerable to Command Injection due to an incomplete fix for [CVE-2022-40764](https://security.snyk.io/vuln/SNYK-JS-SNYK-3037342). A successful exploit allows attackers to run arbitrary commands on the host system where the Snyk CLI is installed by passing in crafted command line flags. In order to exploit this vulnerability, a user would have to execute the snyk test command on untrusted files. In most cases, an attacker positioned to control the command line arguments to the Snyk CLI would already be positioned to execute arbitrary commands. However, this could be abused in specific scenarios, such as continuous integration pipelines, where developers can control the arguments passed to the Snyk CLI to leverage this component as part of a wider attack against an integration/build pipeline. This issue has been addressed in the latest Snyk Docker images available at https://hub.docker.com/r/snyk/snyk as of 2022-11-29. Images downloaded and built prior to that date should be updated. The issue has also been addressed in the Snyk TeamCity CI/CD plugin as of version v20221130.093605.
- CWE
- CWE-78
- CVSS base score
- 6.3
- Published
- 2022-11-30
- 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
- Fixed by upgrading
- Yes
Solution
Update the vulnerable Snyk packages to versions 1.1064.0 or higher, 2.31.3 or higher, 3.24.5 or higher, 2.5.3 or higher, 2.16.2 or higher, 1.24.2 or higher, 5.6.5 or higher, and 1.1.6 or higher.
Vulnerable code sample
import subprocess
def snyk_test(command_args):
"""Vulnerable function that demonstrates the security issue."""
# VULNERABLE: This code is susceptible to command injection
command = ['snyk', 'test'] + command_args
result = subprocess.run(command, capture_output=True, text=True)
return result.stdout
user_input = ['--file', 'untrusted_file.txt; rm -rf /']
output = snyk_test(user_input)
print(output)Patched code sample
import subprocess
def snyk_test(command_args):
"""Secure function that fixes the vulnerability."""
allowed_args = ['--all-projects', '--json', '--file', '--path']
for arg in command_args:
if arg not in allowed_args:
raise ValueError(f"Unsafe argument detected: {arg}")
command = ['snyk', 'test'] + command_args
result = subprocess.run(command, capture_output=True, text=True)
return result.stdout
try:
user_input = ['--file', 'untrusted_file.txt; rm -rf /']
output = snyk_test(user_input)
print(output)
except ValueError as e:
printCite this entry
@misc{vaitp:cve202222984,
title = {{Command Injection in Snyk packages before specified versions}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2022},
note = {VAITP Python Vulnerability Dataset, entry CVE-2022-22984},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2022-22984/}}
}
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 ::
