CVE-2022-26184
Poetry v1.1.9 and below on Windows: Untrusted search path vulnerability, allows unexpected behavior in directories with malicious content
- CVSS 9.8
- CWE-426 Untrusted Search Path
- Input Validation and Sanitization
- Local
Poetry v1.1.9 and below was discovered to contain an untrusted search path which causes the application to behave in unexpected ways when users execute Poetry commands in a directory containing malicious content. This vulnerability occurs when the application is ran on Windows OS.
- CVSS base score
- 9.8
- Published
- 2022-03-21
- OWASP
- A05 Security Misconfiguration
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Path Traversal
- Accessibility scope
- Local
- Impact
- Arbitrary Code Execution
- Fixed by upgrading
- Yes
Solution
Update Poetry to version 1.1.10 or higher.
Vulnerable code sample
import os
import importlib
def example_import(module_name):
__import__(module_name)
if __name__ == "__main__":
module_to_import = input("Enter the module name to import: ")
example_import(module_to_import)Patched code sample
import os
import sys
def example_import(module_name):
current_dir = os.getcwd()
trusted_dirs = [os.path.expanduser("~/.local/lib/python3.x/site-packages"),
os.path.dirname(os.path.abspath(__file__))]
if current_dir not in trusted_dirs:
raise RuntimeError("Untrusted directory: {}".format(current_dir))
__import__(module_name)
if __name__ == "__main__":
try:
example_import("some_module")
except RuntimeError as e:
print(e)
sys.exit(1)Cite this entry
@misc{vaitp:cve202226184,
title = {{Poetry v1.1.9 and below on Windows: Untrusted search path vulnerability, allows unexpected behavior in directories with malicious content}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2022},
note = {VAITP Python Vulnerability Dataset, entry CVE-2022-26184},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2022-26184/}}
}
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 ::
