VAITP Dataset

← Back to the dataset

CVE-2026-105315

Remote code exec via improper handling of result_class in Haystack Elasticsearch backend.

  • CVSS 5.1
  • CWE-95
  • Input Validation and Sanitization
  • Remote

A vulnerability has been found in django-haystack up to 3.3.0. Affected is the function _to_python of the file haystack/backends/elasticsearch_backend.py of the component more_like_this Template Tag Handler. Such manipulation of the argument result_class leads to improper neutralization of directives in dynamically evaluated code. The attack can be launched remotely. The exploit has been disclosed to the public and may be used. Upgrading to version 3.4.0 is able to address this issue. The name of the patch is eb05f193c9771a68dcc8cfac6674a0d48a52ee9d. It is suggested to upgrade the affected component.

CVSS base score
5.1
Published
2026-10-05
OWASP
A03 Injection
Orthogonal defect classification
Checking
Code defect classification
Incorrect Check
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
django-haystack
Fixed by upgrading
Yes

Solution

Upgrade django‑haystack to version 3.4.0 (or later) which includes the patch eb05f193c9771a68dcc8cfac6674a0d48a52ee9d.

Vulnerable code sample

from haystack.backends.elasticsearch_backend import ElasticsearchSearchBackend

class ElasticsearchBackend(ElasticsearchSearchBackend):
    def _to_python(self, result, result_class):
        # VULNERABLE: uses eval on untrusted result_class
        klass = eval(result_class)
        return klass(result)

Patched code sample

from haystack.backends.elasticsearch_backend import ElasticsearchSearchBackend
import importlib

class ElasticsearchBackend(ElasticsearchSearchBackend):
    def _to_python(self, result, result_class):
        # FIX: resolve class safely without eval
        module_name, class_name = result_class.rsplit('.', 1)
        module = importlib.import_module(module_name)
        klass = getattr(module, class_name)
        return klass(result)

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

Cite this entry

@misc{vaitp:cve2026105315,
  title        = {{Remote code exec via improper handling of result_class in Haystack Elasticsearch backend.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-105315},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-105315/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.