The vulnerability stems from direct use of Python's native exec() and eval() functions in the PandasQueryEngine's output processing. The pre-patch code in pandas_query_engine.py contained three critical calls:
- exec(ast.unparse(module), {}, local_vars)
- eval(module_end_str, {"np": np}, local_vars)
- eval(module_end_str, {"np": np}, local_vars)
These functions executed user-controlled code from query inputs without proper sandboxing. The commit 9f3e50a replaced them with safe_exec() and safe_eval() from exec_utils.py, which implement import/builtin restrictions. The CWE-74 and CWE-94 classifications confirm this was an injection vulnerability where untrusted input reached code execution contexts.