CVE-2026-105315
django-haystack more_like_this Template Tag elasticsearch_backend.py _to_python eval injection
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.
Attack profile
How easy it is to exploit
- Attack vector
- Network
- Complexity
- Low
- Privileges needed
- High
- User interaction
- None
What an attacker can affect
- Confidentiality
- Low
- Integrity
- Low
- Availability
- Low
Exploit likelihood
What each source reports
CVE List Score used
5.1
django-haystack more_like_this Template Tag elasticsearch_backend.py _to_python eval injection
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.
- Record
CVE-2026-105315- CVSS 4.0
- 5.1 Medium
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 - CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:L/E:P/RL:O/RC:C - CVSS 3.0
- 4.7 Medium
CVSS:3.0/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:L/E:P/RL:O/RC:C - CVSS 2.0
- 5.8
AV:N/AC:L/Au:M/C:P/I:P/A:P/E:POC/RL:OF/RC:C - Weakness
- CWE-95, CWE-94
- Updated
- 2026-11-02
EUVDEUVD-2026-92429
5.1
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.
- Record
EUVD-2026-92429- CVSS 4.0
- 5.1 Medium
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 - Updated
- 2026-11-02
GitHub AdvisoriesGHSA-5x9v-pqqg-p8jg
2.0
A vulnerability has been found in django-haystack up to 3.3.0. Affected is the function...
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.
- Record
GHSA-5x9v-pqqg-p8jg- CVSS 4.0
- 2.0 Low
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/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X - CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:L - Weakness
- CWE-94
- Updated
- 2026-11-02
GitHub AdvisoriesGHSA-r3hx-x5rh-p9vv
8.7
django-haystack: Remote Code Execution via `eval()` in Elasticsearch Result Deserialization
Remote Code Execution via eval() in Elasticsearch Result Deserialization
Summary
The Elasticsearch backend in django-haystack calls eval() on raw field values returned from Elasticsearch when a SearchField is declared with an index_fieldname alias that differs from the logical field name. During result processing, the backend looks up fields by logical name but Elasticsearch stores them under the alias key; the lookup fails and the value falls through to _to_python() → eval(). An attacker who can control content that is indexed into Elasticsearch—and can trigger or wait for a search that returns it—achieves arbitrary code execution in the Django application process. CVSS 3.1 Base Score: 8.5 (High).
Details
Sink — haystack/backends/elasticsearch_backend.py:865:
converted_value = eval(value)
_to_python() (line ~850) attempts to parse a string value by calling eval() before performing any type-safety check. If the value is an attacker-controlled Python expression such as __import__('os').system(...), the expression is executed unconditionally.
Root cause — haystack/backends/elasticsearch_backend.py:727–737:
for key, value in source.items():
string_key = str(key)
if string_key in index.fields and hasattr(index.fields[string_key], "convert"):
additional_fields[string_key] = index.fields[string_key].convert(value)
else:
additional_fields[string_key] = self._to_python(value)
index.fields is keyed by the logical field name (e.g. "name"), but Elasticsearch stores the document under the index_fieldname alias (e.g. "name_s"). Because "name_s" not in index.fields, the branch falls through to self._to_python(value).
Data flow (source → sink):
haystack/indexes.py:226—self.prepared_data[field.index_fieldname] = field.prepare(obj)stores data under the alias.haystack/backends/elasticsearch_backend.py:218— prepared data copied intofinal_data.haystack/backends/elasticsearch_backend.py:236—bulk(...)writes the document to Elasticsearch under the alias key.haystack/backends/elasticsearch_backend.py:574— search reads attacker-influenced_sourceback from Elasticsearch.haystack/backends/elasticsearch_backend.py:720—_process_results()takesraw_result["_source"].haystack/backends/elasticsearch_backend.py:730— lookupstring_key in index.fieldsfails for alias keys.haystack/backends/elasticsearch_backend.py:737— unmatched value passed to_to_python(value).haystack/backends/elasticsearch_backend.py:865— sink:converted_value = eval(value).
Missing fix: The Solr backend correctly remaps aliases at haystack/backends/solr_backend.py:535–539 using index.field_map before performing the index.fields lookup. The Elasticsearch backend has no equivalent remapping.
Preconditions:
- The application uses the Elasticsearch backend.
- At least one
SearchFieldin aSearchIndexis declared withindex_fieldnameset to a value different from the logical attribute name. - The attacker can write content that is indexed (e.g. via a form, API, or any user-controlled field included in the index).
- The attacker can trigger or wait for a search that returns the malicious document.
PoC
Environment setup (Docker):
# Build the proof-of-concept image
docker build -t vuln001-poc \
-f /path/to/vuln-001/Dockerfile \
/path/to/reports/pypiAi_436_django-haystack__django-haystack/
# Run the PoC — exits 0 on confirmed RCE
docker run --rm vuln001-poc
Dockerfile (vuln-001/Dockerfile):
FROM python:3.11-slim
WORKDIR /app
RUN pip install --no-cache-dir setuptools setuptools_scm wheel
COPY repo/ /app/repo/
RUN pip install --no-cache-dir "Django>=4.2" "elasticsearch>=5,<8"
RUN SETUPTOOLS_SCM_PRETEND_VERSION=0.0.dev0 pip install --no-cache-dir -e /app/repo/
COPY vuln-001/poc.py…
- Record
GHSA-r3hx-x5rh-p9vv- CVSS 4.0
- 8.7 High
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N - Weakness
- CWE-95
- Updated
- 2026-11-02
NVD
2.0
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.
- Record
CVE-2026-105315- CVSS 4.0
- 2.0 Low
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/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X - CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:L - CVSS 2.0
- 5.8 Medium
AV:N/AC:L/Au:M/C:P/I:P/A:P - Weakness
- CWE-94, CWE-95
- Updated
- 2026-11-02
OSV
2.0
django-haystack more_like_this Template Tag elasticsearch_backend.py _to_python eval injection
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.
- Record
CVE-2026-105315- CVSS 4.0
- 2.0 Low
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 - Weakness
- CWE-94, CWE-95
- Updated
- 2026-11-02
OSVDEBIAN-CVE-2026-105315
2.0
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.
- Record
DEBIAN-CVE-2026-105315- CVSS 4.0
- 2.0 Low
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/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X - Updated
- 2026-11-02
OSVGHSA-r3hx-x5rh-p9vv
8.7
django-haystack: Remote Code Execution via `eval()` in Elasticsearch Result Deserialization
Remote Code Execution via eval() in Elasticsearch Result Deserialization
Summary
The Elasticsearch backend in django-haystack calls eval() on raw field values returned from Elasticsearch when a SearchField is declared with an index_fieldname alias that differs from the logical field name. During result processing, the backend looks up fields by logical name but Elasticsearch stores them under the alias key; the lookup fails and the value falls through to _to_python() → eval(). An attacker who can control content that is indexed into Elasticsearch—and can trigger or wait for a search that returns it—achieves arbitrary code execution in the Django application process. CVSS 3.1 Base Score: 8.5 (High).
Details
Sink — haystack/backends/elasticsearch_backend.py:865:
converted_value = eval(value)
_to_python() (line ~850) attempts to parse a string value by calling eval() before performing any type-safety check. If the value is an attacker-controlled Python expression such as __import__('os').system(...), the expression is executed unconditionally.
Root cause — haystack/backends/elasticsearch_backend.py:727–737:
for key, value in source.items():
string_key = str(key)
if string_key in index.fields and hasattr(index.fields[string_key], "convert"):
additional_fields[string_key] = index.fields[string_key].convert(value)
else:
additional_fields[string_key] = self._to_python(value)
index.fields is keyed by the logical field name (e.g. "name"), but Elasticsearch stores the document under the index_fieldname alias (e.g. "name_s"). Because "name_s" not in index.fields, the branch falls through to self._to_python(value).
Data flow (source → sink):
haystack/indexes.py:226—self.prepared_data[field.index_fieldname] = field.prepare(obj)stores data under the alias.haystack/backends/elasticsearch_backend.py:218— prepared data copied intofinal_data.haystack/backends/elasticsearch_backend.py:236—bulk(...)writes the document to Elasticsearch under the alias key.haystack/backends/elasticsearch_backend.py:574— search reads attacker-influenced_sourceback from Elasticsearch.haystack/backends/elasticsearch_backend.py:720—_process_results()takesraw_result["_source"].haystack/backends/elasticsearch_backend.py:730— lookupstring_key in index.fieldsfails for alias keys.haystack/backends/elasticsearch_backend.py:737— unmatched value passed to_to_python(value).haystack/backends/elasticsearch_backend.py:865— sink:converted_value = eval(value).
Missing fix: The Solr backend correctly remaps aliases at haystack/backends/solr_backend.py:535–539 using index.field_map before performing the index.fields lookup. The Elasticsearch backend has no equivalent remapping.
Preconditions:
- The application uses the Elasticsearch backend.
- At least one
SearchFieldin aSearchIndexis declared withindex_fieldnameset to a value different from the logical attribute name. - The attacker can write content that is indexed (e.g. via a form, API, or any user-controlled field included in the index).
- The attacker can trigger or wait for a search that returns the malicious document.
PoC
Environment setup (Docker):
# Build the proof-of-concept image
docker build -t vuln001-poc \
-f /path/to/vuln-001/Dockerfile \
/path/to/reports/pypiAi_436_django-haystack__django-haystack/
# Run the PoC — exits 0 on confirmed RCE
docker run --rm vuln001-poc
Dockerfile (vuln-001/Dockerfile):
FROM python:3.11-slim
WORKDIR /app
RUN pip install --no-cache-dir setuptools setuptools_scm wheel
COPY repo/ /app/repo/
RUN pip install --no-cache-dir "Django>=4.2" "elasticsearch>=5,<8"
RUN SETUPTOOLS_SCM_PRETEND_VERSION=0.0.dev0 pip install --no-cache-dir -e /app/repo/
COPY vuln-001/poc.py…
- Record
GHSA-r3hx-x5rh-p9vv- CVSS 4.0
- 8.7 High
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N - Weakness
- CWE-95
- Updated
- 2026-11-02
OSVUBUNTU-CVE-2026-105315
2.0
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.
- Record
UBUNTU-CVE-2026-105315- CVSS 4.0
- 2.0 Low
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 - CVSS 3.1
- 4.7 Medium
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:L - Updated
- 2026-11-02
Affected packages
| Package | Affected | Fixed |
|---|---|---|
django-haystackPyPI |
before 3.4.0 | 3.4.0 |
django-haystackDebian:12 |
All versions, plus listed versions 3.2.1-13.3.0-13.3.0-2 |
None known |
django-haystackDebian:13 |
All versions, plus listed versions 3.3.0-2 |
None known |
django-haystackDebian:14 |
All versions, plus listed versions 3.3.0-2 |
None known |
django-haystackPyPI |
before 3.4.0, plus listed versions 1.0.0-final1.0.0-rc11.0.0b1.0.1-final1.0.2-final Show 42 moreShow less1.1.01.2.01.2.11.2.21.2.31.2.41.2.51.2.61.2.72.0.02.1.02.2.02.2.12.3.02.3.12.3.22.4.02.4.0rc12.4.0rc22.4.12.5.02.5.12.5.dev02.5.dev12.5.dev22.6.02.6.12.7.02.7.dev02.7.dev12.8.02.8.13.03.0b13.0b23.1.03.1.13.2.03.2.13.2.dev03.3.03.3b2 |
3.4.0 |
django-haystackUbuntu:16.04:LTS |
All versions, plus listed versions 2.4.0-22.4.1-1 |
None known |
django-haystackUbuntu:18.04:LTS |
All versions, plus listed versions 2.6.1-12.7.0-12.8.0-1 |
None known |
django-haystackUbuntu:20.04:LTS |
All versions, plus listed versions 2.8.1-3 |
None known |
django-haystackUbuntu:22.04:LTS |
All versions, plus listed versions 3.0-13.1.1-1 |
None known |
django-haystackUbuntu:24.04:LTS |
All versions, plus listed versions 3.2.1-1 |
None known |
django-haystackUbuntu:26.10 |
All versions, plus listed versions 3.3.0-2build1 |
None known |
django-haystackUbuntu:26.04:LTS |
All versions, plus listed versions 3.3.0-23.3.0-2build1 |
None known |
History
| Recorded | Changed | Sources |
|---|---|---|
| first indexed | CVE List, EUVD, GitHub Advisories, NVD, OSV |
Dates are when Every CVE recorded each change. Upstream dates may differ.
In short
CVE-2026-105315 is a medium vulnerability (CVSS 5.1) in django-haystack, published July 15, 2026. No source lists public exploit code. EPSS puts the chance of exploitation in the next 30 days at 0.25%, the 17th percentile. Fixed in django-haystack 3.4.0.
References
vuldb.com/vuln/413523
vuldb.com/vuln/413523/cti
vuldb.com/cve/CVE-2026-105315
vuldb.com/submit/978642
github.com/django-haystack/django-haystack/security/advisories/GHSA-r3hx-x5rh-p9vv
github.com/django-haystack/django-haystack/commit/eb05f193c9771a68dcc8cfac6674a0d48a52ee9d
Show 9 moreShow less
github.com/django-haystack/django-haystack/releases/tag/v3.4.0
github.com/django-haystack/django-haystack
nvd.nist.gov/vuln/detail/CVE-2026-105315
github.com/advisories/GHSA-5x9v-pqqg-p8jg
github.com/advisories/GHSA-r3hx-x5rh-p9vv
github.com/CVEProject/cvelistV5/tree/main/cves/2026/105xxx/CVE-2026-105315.json
security-tracker.debian.org/tracker/CVE-2026-105315
ubuntu.com/security/CVE-2026-105315
cve.org/CVERecord?id=CVE-2026-105315
Left out here: the rest of 2 source descriptions. The JSON record has them.