{"id":1293,"cve":"CVE-2024-10188","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2024-10188\/","cwe":"CWE-400","cwe_number":400,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/400","cvss_score":7.5,"published":"2025-03-20","owasp":"A03 Injection","odc":"Algorithm","cdc":"Incorrect Algorithm","category":"Input Validation and Sanitization","subcategory":"Insecure Parsing or Deserialization","scope":"Remote","impact":"Denial of Service (DoS)","summary":"DoS via unsafe `ast.literal_eval` in litellm allows unauthenticated users to crash server.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2024-10188\/","description":"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.","solution":"Upgrade to version 1.18.2 or later.","affected_component":"litellm","fixed_by_upgrading":true,"vulnerable_code":"import ast\n\ndef process_input(user_input):\n  \"\"\"\n  Processes user input using ast.literal_eval.\n  \"\"\"\n  try:\n    # Vulnerable code: Directly using ast.literal_eval on user input\n    data = ast.literal_eval(user_input)\n    return data\n  except (ValueError, SyntaxError) as e:\n    return f\"Error processing input: {e}\"\n\n# Example usage (simulating a vulnerable endpoint)\nuser_provided_input = input(\"Enter some data (e.g., a list or dictionary): \")\nresult = process_input(user_provided_input)\nprint(\"Processed data:\", result)","patched_code":"import json\nfrom typing import Dict\n\ndef safe_load_user_input(user_input: str) -> Dict:\n    \"\"\"\n    Safely loads user input as a dictionary using JSON.\n\n    Args:\n        user_input: A string containing the user input.\n\n    Returns:\n        A dictionary representing the user input, or an empty dictionary if loading fails.\n\n    Raises:\n        ValueError: If the user input is not valid JSON.\n    \"\"\"\n    try:\n        data = json.loads(user_input)\n        if isinstance(data, dict):\n            return data\n        else:\n            raise ValueError(\"Input must be a JSON dictionary.\")\n    except json.JSONDecodeError:\n        raise ValueError(\"Invalid JSON format.\")\n    except Exception as e:\n        print(f\"An unexpected error occurred: {e}\")  # Optional logging\n        return {}\n\n\n# Example usage:\n# user_input = '{\"key\": \"value\"}'\n# data = safe_load_user_input(user_input)\n# print(data)\n","payload_needed":true,"payload":"```python\n[([().__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)\n```","payload_status":"available","published_fix":[{"repository":"berriai\/litellm","commit_url":"https:\/\/github.com\/berriai\/litellm\/commit\/21156ff5d0d84a7dd93f951ca033275c77e4f73c","commit_subject":"LiteLLM Minor Fixes & Improvements (11\/27\/2024) (#6943)","units":[{"file":"litellm\/llms\/bedrock\/chat\/converse_transformation.py","function":"AmazonConverseConfig._supported_cross_region_inference_region"},{"file":"litellm\/proxy\/auth\/user_api_key_auth.py","function":null},{"file":"litellm\/proxy\/common_utils\/http_parsing_utils.py","function":null},{"file":"litellm\/proxy\/common_utils\/http_parsing_utils.py","function":"_read_request_body"},{"file":"litellm\/proxy\/proxy_server.py","function":null},{"file":"litellm\/proxy\/proxy_server.py","function":"websocket_endpoint"}]}],"references":null}