{"id":1138,"cve":"CVE-2024-45858","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2024-45858\/","cwe":"CWE-95","cwe_number":95,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/95","cvss_score":7.8,"published":"2024-09-18","owasp":"A01 Broken Access Control","odc":"Checking","cdc":"Incorrect Check","category":"Input Validation and Sanitization","subcategory":"Insecure Parsing or Deserialization","scope":"Remote","impact":"Arbitrary Code Execution","summary":"Arbitrary code execution via malicious XML file in Guardrails framework.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2024-45858\/","description":"An arbitrary code execution vulnerability exists in versions 0.2.9 up to 0.5.10 of the Guardrails AI Guardrails framework because of the way it validates XML files. If a victim user loads a maliciously crafted XML file containing Python code, the code will be passed to an eval function, causing it to execute on the user's machine.","solution":"Upgrade to version 0.5.11 or later.","affected_component":"Guardrails","fixed_by_upgrading":true,"vulnerable_code":"import xml.etree.ElementTree as ET\n\ndef load_xml_and_execute(xml_string):\n    root = ET.fromstring(xml_string)\n    \n    code_to_execute = root.find('code').text\n    eval(code_to_execute)\n\nxml = \"\"\"<root>\n    <code>print('This is an arbitrary code execution!')<\/code>\n<\/root>\"\"\"\n\nload_xml_and_execute(xml)","patched_code":"import xml.etree.ElementTree as ET\n\ndef execute_action(action):\n    actions = {\n        \"greet\": lambda: print(\"Hello, safe world!\"),\n        \"farewell\": lambda: print(\"Goodbye, safe world!\")\n    }\n    \n    if action in actions:\n        actions[action]()\n    else:\n        print(\"Invalid action.\")\n\ndef load_xml_and_execute(xml_string):\n    root = ET.fromstring(xml_string)\n    code_to_execute = root.find('action').text\n    execute_action(code_to_execute)\n\nxml = \"\"\"<root>\n    <code>print('This is an arbitrary code execution!')<\/code>\n<\/root>\"\"\"\n\nload_xml_and_execute(xml)\n","payload_needed":true,"payload":"```xml\n<root>\n    <code>os.system('whoami')<\/code>\n<\/root>\n```","payload_status":"available","published_fix":[{"repository":"guardrails-ai\/guardrails","commit_url":"https:\/\/github.com\/guardrails-ai\/guardrails\/commit\/14955e6251fd72d12f9b3be729795a00a5e00241","commit_subject":"safe eval","units":[{"file":"guardrails\/utils\/validator_utils.py","function":null},{"file":"guardrails\/utils\/validator_utils.py","function":"parse_rail_arguments"}]}],"references":null}