CVE-2024-4343
Python command injection in SagemakerLLM's complete() method allows code exec.
- CVSS 9.8
- CWE-78
- Input Validation and Sanitization
- Remote
A Python command injection vulnerability exists in the `SagemakerLLM` class's `complete()` method within `./private_gpt/components/llm/custom/sagemaker.py` of the imartinez/privategpt application, versions up to and including 0.3.0. The vulnerability arises due to the use of the `eval()` function to parse a string received from a remote AWS SageMaker LLM endpoint into a dictionary. This method of parsing is unsafe as it can execute arbitrary Python code contained within the response. An attacker can exploit this vulnerability by manipulating the response from the AWS SageMaker LLM endpoint to include malicious Python code, leading to potential execution of arbitrary commands on the system hosting the application. The issue is fixed in version 0.6.0.
- CWE
- CWE-78
- CVSS base score
- 9.8
- Published
- 2024-11-14
- OWASP
- A01 Broken Access Control
- 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
- imartinez/pr
- Fixed by upgrading
- Yes
Solution
Upgrade to version 0.6.0 or later.
Vulnerable code sample
class SagemakerLLM:
def complete(self, response):
"""Vulnerable function that demonstrates the security issue."""
result = eval(response)
return resultPatched code sample
import ast
class SagemakerLLM:
def complete(self, response):
"""Secure function that fixes the vulnerability."""
# SECURE: This version prevents command injection
result = ast.literal_eval(response)
return resultPayload
"{'key': 'value', '__import__(\"os\").system(\"echo vulnerable\")'}"
Cite this entry
@misc{vaitp:cve20244343,
title = {{Python command injection in SagemakerLLM's complete() method allows code exec.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2024},
note = {VAITP Python Vulnerability Dataset, entry CVE-2024-4343},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-4343/}}
}
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 ::
