CVE-2024-5826: vanna vulnerable to remote code execution caused by prompt injection
Vanna 0.6.2 and earlier runs LLM-generated code with `exec` and no sandbox when `vanna.ask` is called. A prompt injection can make the model write code that the backend then executes, giving remote code execution on the server. The advisory lists no patched version and no workaround.
Published Jun 27, 2024 · Updated Jun 28, 2024 · Analysis Nov 1, 2026
What an attacker can do
vanna.ask asks the model for output and, in src/vanna/base/base.py, passes generated code to exec. Nothing isolates that code. An attacker who controls part of the question, or any text the model reads, can steer the model into producing Python of their choosing. Vanna then runs it inside the application process.
The advisory's vector requires no privileges and no user interaction over the network, so any person who can submit questions to an app built on Vanna is a possible attacker. The result is code execution as the backend user. That exposes database credentials Vanna holds, API keys, local files and the network the server sits on. The advisory calls it potentially full control of the server. This is a design flaw (unsandboxed execution of model output), not a single bad parameter, so filtering a few strings is not a fix.
Who is affected
Affected: vanna <= 0.6.2, in applications that call vanna.ask with input from users you do not trust. Apps that never expose the question to outsiders carry less risk, though indirect prompt injection through data the model reads remains possible.
pip show vannaAlso search your code for vn.ask( and any web route that forwards user text to it.
vanna
- Ecosystem
- PyPI
- Affected
- <= 0.6.2
- Fixed in
- No patched version yet
- Check
pip show vanna
How to fix it
The advisory lists no patched version of vanna and mentions no workaround. Mitigations below are our suggestions, not vendor guidance:
- Do not give untrusted users access to
vanna.ask. - Run the Vanna backend in a container or sandbox with no secrets beyond what it needs, a read-only database role and restricted egress.
- Prefer a path that returns generated SQL for review instead of executing generated code.
Re-check the advisory for a fixed release.
How to tell if you were hit
Review application logs for questions that contain instructions to the model ("ignore previous", code-like text, import os, subprocess, __import__). Look at the process tree of the Vanna backend for child shells or unexpected interpreters. Check outbound connections from the server that are not to your database or LLM provider.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
In the latest version of vanna-ai/vanna, the vanna.ask function is vulnerable to remote code execution due to prompt injection. The root cause is the lack of a sandbox when executing LLM-generated code, allowing an attacker to manipulate the code executed by the exec function in src/vanna/base/base.py. This vulnerability can be exploited by an attacker to achieve remote code execution on the app backend server, potentially gaining full control of the server.
Questions
- Does CVE-2024-5826 need an account?
The advisory's vector requires no privileges. It only needs a way to submit input to a Vanna app that calls
vanna.ask.- Is there a Vanna version that fixes it?
No. The advisory shows no patched version, and the affected range is
<= 0.6.2.- Why is this called prompt injection?
The attacker does not send code directly. They craft text that makes the model generate harmful code, which
execthen runs without a sandbox.
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
