# CVE-2026-105315: django-haystack more_like_this Template Tag elasticsearch_backend.py _to_python eval injection

> Remote attackers can execute arbitrary code via the more_like_this template tag in django-haystack due to unsafe evaluation of the result_class argument.

- **Severity:** Medium 5.1 (`CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N/E:P`)
- **Exploited in the wild:** Not known
- **Login needed:** An administrator
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** No
- **Published:** 5 Oct 2026
- **Updated:** 5 Oct 2026
- **Also known as:** DEBIAN-CVE-2026-105315, GHSA-5x9v-pqqg-p8jg, GHSA-r3hx-x5rh-p9vv, UBUNTU-CVE-2026-105315

## What is CVE-2026-105315?

CVE-2026-105315 is a medium-severity code injection vulnerability in django-haystack, published on 5 Oct 2026. An attacker needs administrator access to exploit it, with no action from the victim.

### Official description

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.

Weakness: CWE-95 (Improper Neutralization of Directives in Dynamically Evaluated Code), CWE-94 (Improper Control of Generation of Code)

## Which versions are affected by CVE-2026-105315?

2 open source packages ship an affected version, including django-haystack.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `django-haystack` | PyPI | All versions | 3.4.0 |
| `django-haystack` | PyPI | All versions | 3.4.0 |

## How do I fix CVE-2026-105315?

Upgrade django-haystack to 3.4.0 or later.

## Is CVE-2026-105315 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-105315 exists.

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2026-105315 and fix it if it is affected.

What it is: CVE-2026-105315 is a medium-severity code injection vulnerability in django-haystack, published on 5 Oct 2026. An attacker needs administrator access to exploit it, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-105315 exists.

Affected packages and fixed versions:
- django-haystack (PyPI): affected all versions; fixed in 3.4.0
- django-haystack (PyPI): affected all versions; fixed in 3.4.0

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/CVE-2026-105315/ (Markdown: https://insights.sbomify.com/CVE-2026-105315/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2026-105315
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2026-105315
- OSV: https://osv.dev/vulnerability/CVE-2026-105315

---
From sbomify Insights: https://insights.sbomify.com/CVE-2026-105315/
Summaries are generated and may contain mistakes; the official description above is the record.
