{"id":1123,"cve":"CVE-2024-27444","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2024-27444\/","cwe":"CWE-749","cwe_number":749,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/749","cvss_score":9.8,"published":"2024-02-26","owasp":"A01 Broken Access Control","odc":"Function","cdc":"Incorrect Functionality","category":"Input Validation and Sanitization","subcategory":"Insecure Parsing or Deserialization","scope":"Remote","impact":"Arbitrary Code Execution","summary":"LangChain < 0.1.8 allows code execution via attribute bypass of CVE-2023-44467.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2024-27444\/","description":"langchain_experimental (aka LangChain Experimental) in LangChain before 0.1.8 allows an attacker to bypass the CVE-2023-44467 fix and execute arbitrary code via the __import__, __subclasses__, __builtins__, __globals__, __getattribute__, __bases__, __mro__, or __base__ attribute in Python code. These are not prohibited by pal_chain\/base.py.","solution":"Upgrade to LangChain version 0.1.8 or later.","affected_component":"LangChain","fixed_by_upgrading":true,"vulnerable_code":"def execute_code(code):\n    \"\"\"Vulnerable function that demonstrates the security issue.\"\"\"\n    exec(code)\n\ncode = \"__import__('os').system('echo Vulnerable!')\"\n\nexecute_code(code)","patched_code":"def check_code(code):\n    \"\"\"Secure function that fixes the vulnerability.\"\"\"\n    blacklist = ['__import__', 'os', 'sys', 'subprocess', 'eval', 'exec', 'open', 'input', 'compile', 'globals', 'locals']\n    return not any(black_item in code for black_item in blacklist)\n\ndef execute_code(code):\n    \"\"\"Secure function that fixes the vulnerability.\"\"\"\n    if check_code(code):\n        exec(code)\n    else:\n        print(\"Error: Unsafe code detected!\")\n\ncode = \"__import__('os').system('echo Vulnerable!')\"\nexecute_code(code)\n","payload_needed":true,"payload":"```python\n\"__import__('os').system('echo Exploited!')\"\n```","payload_status":"available","published_fix":[{"repository":"langchain-ai\/langchain","commit_url":"https:\/\/github.com\/langchain-ai\/langchain\/commit\/de9a6cdf163ed00adaf2e559203ed0a9ca2f1de7","commit_subject":"experimental[patch]: Enhance protection against arbitrary code execution in PALChain (#17091)","units":[{"file":"libs\/experimental\/langchain_experimental\/pal_chain\/base.py","function":null},{"file":"libs\/experimental\/langchain_experimental\/pal_chain\/base.py","function":"PALChain.validate_code"}]}],"references":null}