Vulnerabilities in pkg:pypi/haystack-ai

PACKAGE
Advisory Identifier: GHSA-hx9v-6r9f-w677
Advisory Summary

CVE-2024-41950 is a HIGH (CVSS 7.5) remote code execution vulnerability (CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine) affecting Haystack ai libraries in the PyPI ecosystem. The issue involves insecure jinja2 templates rendered in haystack components can lead to rce. Remediation is available by upgrading affected packages to version 2.3.1.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/haystack-ai

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/haystack-ai. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-hx9v-6r9f-w677 CVE-2024-41950 HIGH Insecure Jinja2 templates rendered in Haystack Components can lead to RCE

CVE-2024-41950 at a Glance

CVE Identifier CVE-2024-41950
GHSA Identifier GHSA-hx9v-6r9f-w677
Severity HIGH
CVSS v3.1 Base Score 7.5
CWE Classification CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine
Affected Product Haystack ai
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2024-41950

To remediate this vulnerability, upgrade all affected Haystack ai dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

haystack-ai fixed: 2.3.1
pip install haystack-ai>=2.3.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show haystack-ai

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2024-41950, inspect your installed packages using pip:

pip show haystack-ai

Analyze the terminal output to locate any version of Haystack ai in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.3.1), your application is affected.

Note: The pip show haystack-ai command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine, where the product uses a template engine to insert or process externally-influenced input, but it does not neutralize or incorrectly neutralizes special elements or syntax that can be interpreted as template expressions or other code directives when processed by the engine. In Haystack ai, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact 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. ### Patches The problem has been fixed with PRs deepset-ai/haystack#8095 and deepset-ai/haystack#8096. Both have been released with Haystack `2.3.1`. ### Workarounds Prevent users from running the affected Components, or only let users use preselected templates. ### References The list of impacted Components can be found in the release notes for `2.3.1`. https://github.com/deepset-ai/haystack/releases/tag/v2.3.1

CVE-2024-41950 Affected Haystack ai Versions

1 component(s)
Fixed Versions:
2.3.1
Product / Package Ecosystem Affected Versions Fixed Version
haystack-ai
PyPI
< 2.3.1
2.3.1

References

Frequently Asked Questions

What is CVE-2024-41950?
CVE-2024-41950 is a security vulnerability in Haystack ai involving Insecure Jinja2 templates rendered in Haystack Components can lead to RCE under CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine.
Which Haystack ai versions are affected?
Affected versions include releases prior to 2.3.1 across affected packages: haystack-ai.
What version fixes CVE-2024-41950?
Upgrading to 2.3.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is haystack-ai affected?
Yes, haystack-ai is affected in releases prior to 2.3.1. Upgrade your dependency to 2.3.1 or later.
What is the CVSS score of CVE-2024-41950?
CVE-2024-41950 has a CVSS v3.1 base score of 7.5 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2024-41950?
CVE-2024-41950 is classified under CWE-1336: Improper Neutralization of Special Elements Used in a Template Engine (The product uses a template engine to insert or process externally-influenced input, but it does not neutralize or incorrectly neutralizes special elements or syntax that can be interpreted as template expressions or other code directives when processed by the engine.).
How can I check PyPI dependencies for CVE-2024-41950?
Run the dependency tree command: 'pip show haystack-ai'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-hx9v-6r9f-w677",
  "modified" : "2024-07-31T18:50:41Z",
  "published" : "2024-07-31T18:50:41Z",
  "aliases" : [ "CVE-2024-41950" ],
  "summary" : "Insecure Jinja2 templates rendered in Haystack Components can lead to RCE",
  "details" : "### Impact\n\nHaystack clients that let their users create and run Pipelines from scratch are vulnerable to remote code executions.\n\nCertain Components in Haystack use Jinja2 templates, if anyone can create and render that template on the client machine they run any code.\n\n### Patches\n\nThe problem has been fixed with PRs deepset-ai/haystack#8095 and deepset-ai/haystack#8096.\n\nBoth have been released with Haystack `2.3.1`.\n\n### Workarounds\n\nPrevent users from running the affected Components, or only let users use preselected templates.\n\n### References\n\nThe list of impacted Components can be found in the release notes for `2.3.1`.\nhttps://github.com/deepset-ai/haystack/releases/tag/v2.3.1",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "haystack-ai"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.3.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/deepset-ai/haystack/security/advisories/GHSA-hx9v-6r9f-w677"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-41950"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/deepset-ai/haystack/pull/8095"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/deepset-ai/haystack/pull/8096"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/deepset-ai/haystack/commit/3fed1366c448b02189851bf08166c1f6477a02b0"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/deepset-ai/haystack/commit/6c25a5c73e83aa32c3241ba84a5cbb3ac0e8a89e"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/deepset-ai/haystack"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/deepset-ai/haystack/releases/tag/v2.3.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-1336" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-07-31T18:50:41Z",
    "nvd_published_at" : "2024-07-31T16:15:04Z"
  }
}