CVE-2024-42835
RCE vulnerability in langflow v1.0.12 via PythonCodeTool component.
- CVSS 9.8
- CWE-94
- Input Validation and Sanitization
- Remote
langflow v1.0.12 was discovered to contain a remote code execution (RCE) vulnerability via the PythonCodeTool component.
- CWE
- CWE-94
- CVSS base score
- 9.8
- Published
- 2024-10-31
- 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
- PythonCodeTo
- Fixed by upgrading
- Yes
Solution
Upgrade to langflow v1.0.13 or later.
Vulnerable code sample
class PythonCodeTool:
def execute_code(self, code):
"""Vulnerable function that demonstrates the security issue."""
try:
exec(code)
except Exception as e:
print(f"Error executing code: {e}")
tool = PythonCodeTool()
tool.execute_code("import os; os.system('ls')")Patched code sample
class PythonCodeTool:
BLACKLIST = ['os', 'sys', 'subprocess', 'eval', 'exec', 'open', '__']
def execute_code(self, code):
"""Secure function that fixes the vulnerability."""
# SECURE: This version prevents command injection
for keyword in self.BLACKLIST:
if keyword in code:
print(f"Blocked execution of code containing restricted keyword: {keyword}")
return
try:
exec(code)
except Exception as e:
print(f"Error executing code: {e}")
tool = PythonCodeTool()
tool.execute_code("import os; os.system('ls')")Payload
import os; os.system('whoami')
Cite this entry
@misc{vaitp:cve202442835,
title = {{RCE vulnerability in langflow v1.0.12 via PythonCodeTool component.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2024},
note = {VAITP Python Vulnerability Dataset, entry CVE-2024-42835},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-42835/}}
}
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 ::
