CVE-2024-41950 Insecure Jinja2 templates rendered in Haystack Components can lead to RCE

High 7.5 Published Updated

Attackers can execute arbitrary code by injecting malicious Jinja2 templates into Haystack pipelines, requiring an upgrade to the latest version.

Exploited in the wild
Not known
Login needed
Any signed-in user
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2024-41950?

CVE-2024-41950 is a high-severity code injection vulnerability in deepset-ai haystack, published on 31 Jul 2024. Any signed-in user can exploit it over the network, with no action from the victim.

Official description

Haystack is an end-to-end LLM framework that allows you to build applications powered by LLMs, Transformer models, vector search and more. Haystack clients that let their users create and run Pipelines from scratch are vulnerable to remote code executions. Certain Components in Haystack use Jinja2 templates, if anyone can create and render that template on the client machine they run any code. The vulnerability has been fixed with Haystack `2.3.1`.

Weakness: CWE-1336

Which versions are affected by CVE-2024-41950?

3 open source packages ship an affected version, including haystack-ai.

PackageAffectedFixed in
haystack-ai PyPIAll versions2.3.1
haystack-ai PyPIAll versions2.3.1
haystack-ai PyPIAll versions2.3.1

How do I fix CVE-2024-41950?

Upgrade haystack-ai to 2.3.1 or later.

Upgrade, and never evaluate templates, expressions or code built from user input. More about Code injection.

Is CVE-2024-41950 being exploited?

There is no known exploitation of CVE-2024-41950 in the wild and no public exploit code.

Sources

Also known as GHSA-hx9v-6r9f-w677, PYSEC-2026-1447.

Is CVE-2024-41950 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free