{"id":373,"cve":"CVE-2022-21797","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2022-21797","cwe":"CWE-94","cwe_number":94,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/94","cvss_score":9.8,"published":"2022-09-26","owasp":"A06 Vulnerable and Outdated Components","odc":"Function","cdc":"Incorrect Functionality","category":"Input Validation and Sanitization","subcategory":"Command Injection","scope":"Remote","impact":"Arbitrary Code Execution","summary":"Joblib < 1.2.0, pre_dispatch flag, Arbitrary Code Execution via eval","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2022-21797\/","description":"The package joblib from 0 and before 1.2.0 are vulnerable to Arbitrary Code Execution via the pre_dispatch flag in Parallel() class due to the eval() statement.","solution":"Update joblib to version 1.2.0 or higher.","affected_component":"joblib","fixed_by_upgrading":true,"vulnerable_code":"from joblib import Parallel, delayed\n\n# Vulnerable usage of Parallel with eval() in pre_dispatch\ndef vulnerable_function(x):\n    return x * x\n\n# Using pre_dispatch in a way that could lead to arbitrary code execution\nresults = Parallel(n_jobs=2, pre_dispatch='2*n_jobs')(delayed(vulnerable_function)(i) for i in range(10))\nprint(results)","patched_code":"from joblib import Parallel, delayed\n\n# Safe usage of Parallel without eval()\ndef safe_function(x):\n    return x * x\n\n# Using the pre_dispatch flag without eval()\nresults = Parallel(n_jobs=2, pre_dispatch='2*n_jobs')(delayed(safe_function)(i) for i in range(10))\nprint(results)","payload_needed":false,"payload":null,"payload_status":"none","published_fix":[{"repository":"joblib\/joblib","commit_url":"https:\/\/github.com\/joblib\/joblib\/commit\/6638b9e9711ad1ebbf6dd95aa7cee0dca9897b42","commit_subject":"FIX actually fix the eval security issue","units":[{"file":"joblib\/parallel.py","function":null},{"file":"joblib\/parallel.py","function":"Parallel.__call__"}]},{"repository":"joblib\/joblib","commit_url":"https:\/\/github.com\/joblib\/joblib\/commit\/b90f10efeb670a2cc877fb88ebb3f2019189e059","commit_subject":"FIX make sure pre_dispatch cannot do arbitrary code execution (#1321)","units":[{"file":"joblib\/parallel.py","function":null},{"file":"joblib\/parallel.py","function":"Parallel.__call__"}]}],"references":null}