CVE-2024-10188
DoS via unsafe `ast.literal_eval` in litellm allows unauthenticated users to crash server.
- CVSS 7.5
- CWE-400
- Input Validation and Sanitization
- Remote
A vulnerability in BerriAI/litellm, as of commit 26c03c9, allows unauthenticated users to cause a Denial of Service (DoS) by exploiting the use of ast.literal_eval to parse user input. This function is not safe and is prone to DoS attacks, which can crash the litellm Python server.
- CWE
- CWE-400
- CVSS base score
- 7.5
- Published
- 2025-03-20
- OWASP
- A03 Injection
- Orthogonal defect classification
- Algorithm
- Code defect classification
- Incorrect Algorithm
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- litellm
- Fixed by upgrading
- Yes
Solution
Upgrade to version 1.18.2 or later.
Vulnerable code sample
import ast
def process_input(user_input):
"""
Processes user input using ast.literal_eval.
"""
try:
# Vulnerable code: Directly using ast.literal_eval on user input
data = ast.literal_eval(user_input)
return data
except (ValueError, SyntaxError) as e:
return f"Error processing input: {e}"
# Example usage (simulating a vulnerable endpoint)
user_provided_input = input("Enter some data (e.g., a list or dictionary): ")
result = process_input(user_provided_input)
print("Processed data:", result)Patched code sample
import json
from typing import Dict
def safe_load_user_input(user_input: str) -> Dict:
"""
Safely loads user input as a dictionary using JSON.
Args:
user_input: A string containing the user input.
Returns:
A dictionary representing the user input, or an empty dictionary if loading fails.
Raises:
ValueError: If the user input is not valid JSON.
"""
try:
data = json.loads(user_input)
if isinstance(data, dict):
return data
else:
raise ValueError("Input must be a JSON dictionary.")
except json.JSONDecodeError:
raise ValueError("Invalid JSON format.")
except Exception as e:
print(f"An unexpected error occurred: {e}") # Optional logging
return {}
# Example usage:
# user_input = '{"key": "value"}'
# data = safe_load_user_input(user_input)
# print(data)Payload
[([().__class__.__bases__[0].__subclasses__()[40]('', {'__builtins__': None, '__import__': lambda x: None}).__class__.__bases__[0].__subclasses__()[177].__init__.__globals__['__builtins__']['eval']("__import__('os').system('ls -la')")]*999999)
Cite this entry
@misc{vaitp:cve202410188,
title = {{DoS via unsafe `ast.literal_eval` in litellm allows unauthenticated users to crash server.
}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2025},
note = {VAITP Python Vulnerability Dataset, entry CVE-2024-10188},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-10188/}}
}
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 ::
