CVE-2024-53526
Command Execution in composio>=0.5.40 via handle_tool_calls.
- CVSS 6.4
- CWE-77
- Input Validation and Sanitization
- Remote
composio >=0.5.40 is vulnerable to Command Execution in composio_openai, composio_claude, and composio_julep via the handle_tool_calls function.
- CWE
- CWE-77
- CVSS base score
- 6.4
- Published
- 2025-01-08
- OWASP
- A03 Injection
- Orthogonal defect classification
- Algorithm
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- composio
- Fixed by upgrading
- Yes
Solution
Upgrade to composio >= 0.5.45
Vulnerable code sample
import subprocess
import json
def handle_tool_calls(tool_calls):
"""Vulnerable function that demonstrates the security issue."""
for tool_call in tool_calls:
function_name = tool_call.get("function", {}).get("name")
arguments = tool_call.get("function", {}).get("arguments")
if function_name == "run_shell_command":
if arguments:
try:
arguments_dict = json.loads(arguments)
command = arguments_dict.get("command")
if command:
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
return_code = process.returncode
return {
"stdout": stdout.decode("utf-8"),
"stderr": stderr.decode("utf-8"),
"return_code": return_code
}
except json.JSONDecodeError:
return "Invalid JSON arguments"
return "No tool calls"
if __name__ == '__main__':
tool_call_example = [
{
"id": "1",
"function": {
"name": "run_shell_command",
"arguments": '{"command": "ls -la && whoami"}'
}
}
]
result = handle_tool_calls(tool_call_example)
print(result)Patched code sample
import json
import subprocess
import shlex
def handle_tool_calls(tool_call):
"""Secure function that fixes the vulnerability."""
if tool_call["function"]["name"] == "execute_command":
arguments = tool_call["function"]["arguments"]
try:
parsed_arguments = json.loads(arguments)
command = parsed_arguments.get("command", "")
if not command:
return "Error: Command cannot be empty"
escaped_command = shlex.split(command)
result = subprocess.run(escaped_command, capture_output=True, text=True, check=False)
return result.stdout if result.returncode == 0 else result.stderr
except json.JSONDecodeError:
return "Error: Invalid JSON format in arguments"
except Exception as e:
return f"Error: {str(e)}"
else:
return "Unknown function name"
if __name__ == '__main__':
tool_call_example = [
{
"id": "1",
"function": {
"name": "run_shell_command",
"arguments": '{"command": "ls -la && whoami"}'
}
}
]
result = handle_tool_calls(tool_call_example)
print(result)Payload
{"tool_calls": [{"function": {"name": "any_name", "arguments": '{"command": "whoami"}'}}]}
Cite this entry
@misc{vaitp:cve202453526,
title = {{Command Execution in composio>=0.5.40 via handle_tool_calls.
}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2025},
note = {VAITP Python Vulnerability Dataset, entry CVE-2024-53526},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-53526/}}
}
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 ::
