{"id":1832,"cve":"CVE-2026-42234","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2026-42234\/","cwe":"CWE-94","cwe_number":94,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/94","cvss_score":7.1,"published":"2026-05-04","owasp":"A03 Injection","odc":"Checking","cdc":"Incorrect Check","category":"Input Validation and Sanitization","subcategory":"Command Injection","scope":"Remote","impact":"Arbitrary Code Execution","summary":"n8n: Python Code Node sandbox escape allows arbitrary code execution.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2026-42234\/","description":"n8n is an open source workflow automation platform. Prior to versions 1.123.32, 2.17.4, and 2.18.1, an authenticated user with permission to create or modify workflows containing a Python Code Node could escape the sandbox and achieve arbitrary code execution on the task runner container. This issue only affects instances where the Python Task Runner is enabled. This issue has been patched in versions 1.123.32, 2.17.4, and 2.18.1.","solution":"Upgrade n8n to version 1.123.32, 2.17.4, 2.18.1, or later.","affected_component":"n8n","fixed_by_upgrading":false,"vulnerable_code":"[c for c in ().__class__.__base__.__subclasses__() if c.__name__ == 'catch_warnings'][0]()._module.__builtins__['__import__']('os').system('id > \/tmp\/pwned')","patched_code":"def execute_sanitized_python_code(user_code: str):\n    \"\"\"\n    Executes user-provided Python code in a restricted environment to prevent\n    sandbox escapes, representing a conceptual fix for a vulnerability like\n    the one described.\n    \"\"\"\n    # Define a whitelist of safe built-in functions.\n    # Dangerous functions like `open`, `__import__`, `eval`, and `exec` are excluded.\n    safe_builtins = {\n        \"print\": print,\n        \"len\": len,\n        \"str\": str,\n        \"int\": int,\n        \"float\": float,\n        \"list\": list,\n        \"dict\": dict,\n        \"set\": set,\n        \"tuple\": tuple,\n        \"range\": range,\n        \"abs\": abs,\n        \"round\": round,\n        \"sum\": sum,\n        \"min\": min,\n        \"max\": max,\n        \"sorted\": sorted,\n    }\n\n    # The environment for the user code. The `__builtins__` key is crucial.\n    # By explicitly setting it, we replace the default, unrestricted built-ins\n    # with our curated safe dictionary.\n    restricted_environment = {\n        \"__builtins__\": safe_builtins,\n    }\n\n    # Execute the user's code within the heavily restricted environment.\n    # Any attempt to use a function not in `safe_builtins` (e.g., __import__)\n    # will raise a NameError, preventing the sandbox escape.\n    try:\n        exec(user_code, restricted_environment, restricted_environment)\n    except Exception as e:\n        # In a real application, this error would be logged and reported.\n        print(f\"Code execution failed: {e}\")","payload_needed":true,"payload":null,"payload_status":"model_refused","published_fix":[],"references":null}