Skip to main content
Vulnerability Database/CVE-2026-105315

CVE-2026-105315: Django-Haystack RCE Vulnerability

CVE-2026-105315 is a remote code execution flaw in django-haystack affecting versions up to 3.3.0. Attackers can exploit improper code evaluation in the more_like_this template tag handler. This article covers technical details, affected versions, exploit information, and upgrade recommendations.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-105315 Overview

CVE-2026-105315 is a code injection vulnerability in django-haystack versions up to 3.3.0. The flaw resides in the _to_python function of haystack/backends/elasticsearch_backend.py, which handles results for the more_like_this template tag. Manipulation of the result_class argument leads to improper neutralization of directives in dynamically evaluated code [CWE-94]. The vulnerability is network-exploitable but requires high privileges, limiting its practical impact. The maintainers released version 3.4.0 containing patch eb05f193c9771a68dcc8cfac6674a0d48a52ee9d to address the issue.

Critical Impact

Authenticated remote attackers can inject directives into dynamically evaluated code paths within the Elasticsearch backend, potentially leading to arbitrary code execution in the Django application context.

Affected Products

  • django-haystack versions up to and including 3.3.0
  • Deployments using the Elasticsearch 1.x backend (haystack/backends/elasticsearch_backend.py)
  • Applications using the more_like_this template tag handler

Discovery Timeline

  • 2026-10-05 - CVE-2026-105315 published to NVD
  • 2026-10-06 - Last updated in NVD database

Technical Details for CVE-2026-105315

Vulnerability Analysis

The vulnerability affects the _to_python helper inside the Elasticsearch 1.x backend of django-haystack. This function is responsible for converting serialized values returned from the search backend into Python types for application consumption. The conversion path performs dynamic evaluation of data that an attacker can influence via the result_class argument of the more_like_this template tag.

Because the function does not neutralize directives before evaluation, crafted input can introduce Python expressions that execute inside the host process. The attack is remote but gated by the requirement for high-privilege authentication, which narrows the exploitation surface to users who already have significant application access.

Root Cause

The root cause is improper neutralization of directives in dynamically evaluated code [CWE-94]. The pre-patch _to_python implementation relied on evaluation primitives that interpret strings as executable Python rather than parsing them as literals. The upstream fix introduces ast into the module, indicating the patch replaces unsafe evaluation with ast.literal_eval, which only accepts a restricted set of literal structures.

Attack Vector

An authenticated attacker with sufficient privileges to influence the result_class parameter passed to the more_like_this template tag can supply a value that reaches the vulnerable _to_python path. When the backend processes the Elasticsearch response, the embedded directives are evaluated, executing attacker-controlled logic within the Django process.

python
+import ast
 import re
 import warnings
 from datetime import datetime, timedelta

Source: GitHub Commit eb05f19

The patch adds the ast module import, enabling the maintainers to replace unsafe evaluation calls with ast.literal_eval throughout the backend module. Review the complete diff in the GitHub Security Advisory GHSA-r3hx-x5rh-p9vv for the full scope of changes.

Stop Remote Code Execution Before It Runs

Singularity™ Endpoint detects and blocks exploit attempts at machine speed, including zero-days and novel attack techniques.

Stop Exploit Attempts

Detection Methods for CVE-2026-105315

Indicators of Compromise

  • Unexpected Python processes or subprocesses spawned by the Django/WSGI/ASGI worker handling search requests.
  • Anomalous outbound network connections originating from the Django application host following more_like_this tag usage.
  • Error traces in application logs referencing _to_python or elasticsearch_backend.py with syntax or evaluation exceptions.

Detection Strategies

  • Inventory installed Python packages across environments and flag any django-haystack installation at or below version 3.3.0.
  • Monitor HTTP request logs for unusual values supplied to parameters that map to the result_class argument of the more_like_this template tag.
  • Enable Python audit hooks (sys.addaudithook) in production to log exec and compile events originating from the Elasticsearch backend module.

Monitoring Recommendations

  • Alert on new child processes spawned by the web application user account.
  • Track egress traffic from application servers to non-approved destinations after search operations.
  • Capture and retain full application stack traces when exceptions originate from haystack.backends.elasticsearch_backend.

How to Mitigate CVE-2026-105315

Immediate Actions Required

  • Upgrade django-haystack to version 3.4.0 or later in all environments using the Elasticsearch backend.
  • Audit application code and templates for use of the more_like_this template tag and review how result_class is populated.
  • Restrict high-privilege application accounts and rotate credentials for any account that could reach the vulnerable code path.

Patch Information

The fix is included in GitHub Release v3.4.0 via commit eb05f193c9771a68dcc8cfac6674a0d48a52ee9d. The patch introduces ast.literal_eval in place of unsafe dynamic evaluation inside haystack/backends/elasticsearch_backend.py. Full remediation guidance is available in GitHub Security Advisory GHSA-r3hx-x5rh-p9vv.

Workarounds

  • If upgrading immediately is not possible, disable or remove usage of the more_like_this template tag until the patch is applied.
  • Constrain the set of values that can be passed as result_class through strict server-side allow-listing.
  • Reduce the number of accounts holding privileges sufficient to reach the vulnerable template tag path.
bash
# Upgrade django-haystack to the patched release
pip install --upgrade "django-haystack>=3.4.0"

# Verify installed version
python -c "import haystack; print(haystack.__version__)"

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.