CVE-2023-39661: PandasAI vulnerable to arbitrary code execution
PandasAI (`pandasai`) 0.8.1 and earlier lets a remote attacker run arbitrary code by bypassing the `_is_jailbreak` check. A crafted prompt makes the LLM return code that the filter does not block. No patched version is listed, and the report was closed as not planned.
Published Aug 15, 2023 · Updated Nov 16, 2026 · Analysis Nov 11, 2026
What an attacker can do
PandasAI asks an LLM to write Python for a user's question, then runs it. _is_jailbreak is the guard: it parses the generated code and rejects dangerous builtins by checking child.id in DANGEROUS_BUILTINS on ast.Name nodes. That is a name-based filter. The reporter modified an earlier proof of concept so that the blocked builtin name is replaced with an empty string literal. The filter no longer sees a dangerous name, yet the code still reaches the same functionality through attribute access, and it runs.
The reporter did not confirm the exact root cause. The report states that the earlier fix for issue 399 only filtered __builtins__.
The attacker needs to supply the prompt. That is true for any application that exposes PandasAI to users, for example a chat interface over a dataset, or one that processes text from third parties. The attacker gets code execution with the rights of the application, which means access to its files, environment variables, API keys and network. No credentials are needed beyond the ability to ask a question.
Who is affected
pandasai on PyPI up to and including 0.8.1. Check:
pip show pandasaiAny application that passes untrusted user input into PandasAI is exposed, whether it uses the library directly or behind a web front end.
pandasai
- Ecosystem
- PyPI
- Affected
- <= 0.8.1
- Fixed in
- No patched version yet
- Check
pip show pandasai
How to fix it
No patched version is listed for the affected 0.x line. The report, issue 410, was marked stale and then closed as not planned on June 1, 2024. It shows no linked fix. Do not expose PandasAI 0.8.1 or earlier to untrusted input.
If you must use it, run it in a sandbox: a container or VM with no secrets, no network and a low-privilege user. Check newer major versions of the library separately, as their execution design differs and this advisory does not assess them.
How to tell if you were hit
Review stored prompts and generated code for strings, attribute chains or encoded expressions that reach __builtins__, os, subprocess or eval. Look at the host for unexpected child processes from the Python worker, outbound network connections and changed files after user questions were answered.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
An issue in pandas-ai v.0.8.1 and before allows a remote attacker to execute arbitrary code via the _is_jailbreak function.
Questions
- Is there a fix for CVE-2023-39661?
No patched version is listed. The upstream issue was closed as not planned.
- How does the bypass work?
The reporter replaced a blocked builtin name with an empty string literal. The name-based filter no longer matched, yet the code still reached the same functionality via attribute access.
- Does the attacker need access to the server?
No. They need to be able to send a prompt to an application that uses PandasAI.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
