GHSA-r3hx-x5rh-p9vv: django-haystack: Remote Code Execution via `eval()` in Elasticsearch Result Deserialization
A remote code execution (RCE) vulnerability exists in django-haystack's Elasticsearch backend due to unsafe use of eval() on attacker-controlled data during result deserialization. When a SearchField uses an index_fieldname alias different from the logical field name, the backend fails to remap the alias, causing it to call eval() on raw Elasticsearch field values. An attacker able to control indexed content and trigger a search returning that content can execute arbitrary code in the Django application process. This affects django-haystack versions prior to 3.4.0.
AI Analysis
Technical Summary
The Elasticsearch backend in django-haystack calls Python's eval() function on raw field values returned from Elasticsearch when a SearchField is declared with an index_fieldname alias differing from the logical field name. Because Elasticsearch stores documents under the alias key but the backend looks up fields by logical name, the lookup fails and the value is passed to _to_python(), which unconditionally calls eval() on it. This allows an attacker who can control indexed content and trigger a search returning that content to execute arbitrary code in the Django application process. The Solr backend correctly remaps aliases before lookup, but the Elasticsearch backend lacks this remapping, causing the vulnerability. The vulnerability affects django-haystack versions before 3.4.0.
Potential Impact
Successful exploitation allows an attacker who can inject data into Elasticsearch and trigger a search returning that data to execute arbitrary Python code within the Django application process. This can lead to full compromise of the application environment, data theft, or further attacks. The vulnerability is rated high severity (CVSS 4.0 vector indicates high impact on confidentiality, integrity, and availability).
Mitigation Recommendations
No official patch or fix is currently documented. Patch status is not yet confirmed — check the vendor advisory for current remediation guidance. Until a fix is available, avoid using index_fieldname aliases different from logical field names in SearchFields with the Elasticsearch backend, or restrict user input that can be indexed to prevent injection of malicious payloads. Monitor vendor channels for updates and apply patches promptly once released.
GHSA-r3hx-x5rh-p9vv: django-haystack: Remote Code Execution via `eval()` in Elasticsearch Result Deserialization
Description
A remote code execution (RCE) vulnerability exists in django-haystack's Elasticsearch backend due to unsafe use of eval() on attacker-controlled data during result deserialization. When a SearchField uses an index_fieldname alias different from the logical field name, the backend fails to remap the alias, causing it to call eval() on raw Elasticsearch field values. An attacker able to control indexed content and trigger a search returning that content can execute arbitrary code in the Django application process. This affects django-haystack versions prior to 3.4.0.
CVSS v4.0
Affected software
Run on your own infrastructure? Check whether these packages are installed with threat-finder — our free open-source scanner.
Weaknesses
AI-Powered Analysis
Machine-generated threat intelligence
Technical Analysis
The Elasticsearch backend in django-haystack calls Python's eval() function on raw field values returned from Elasticsearch when a SearchField is declared with an index_fieldname alias differing from the logical field name. Because Elasticsearch stores documents under the alias key but the backend looks up fields by logical name, the lookup fails and the value is passed to _to_python(), which unconditionally calls eval() on it. This allows an attacker who can control indexed content and trigger a search returning that content to execute arbitrary code in the Django application process. The Solr backend correctly remaps aliases before lookup, but the Elasticsearch backend lacks this remapping, causing the vulnerability. The vulnerability affects django-haystack versions before 3.4.0.
Potential Impact
Successful exploitation allows an attacker who can inject data into Elasticsearch and trigger a search returning that data to execute arbitrary Python code within the Django application process. This can lead to full compromise of the application environment, data theft, or further attacks. The vulnerability is rated high severity (CVSS 4.0 vector indicates high impact on confidentiality, integrity, and availability).
Mitigation Recommendations
No official patch or fix is currently documented. Patch status is not yet confirmed — check the vendor advisory for current remediation guidance. Until a fix is available, avoid using index_fieldname aliases different from logical field names in SearchFields with the Elasticsearch backend, or restrict user input that can be indexed to prevent injection of malicious payloads. Monitor vendor channels for updates and apply patches promptly once released.
Technical Details
- Gcve Source
- db.gcve.eu
- Osv Id
- GHSA-r3hx-x5rh-p9vv
- Osv Schema Version
- 1.4.0
- Aliases
- []
- Ecosystems
- ["PyPI"]
- Database Specific Severity
- HIGH
- Cvss Version
- 4.0
Threat ID: 6a58b40568715ace43d6707e
Added to database: 07/16/2026, 10:35:49 UTC
Last enriched: 07/16/2026, 10:49:19 UTC
Last updated: 07/16/2026, 11:48:10 UTC
Views: 3
Community Reviews
0 reviewsCrowdsource mitigation strategies, share intel context, and vote on the most helpful responses. Sign in to add your voice and help keep defenders ahead.
Want to contribute mitigation steps or threat intel context? Sign in or create an account to join the community discussion.
Actions
Updates to AI analysis require Pro Console access. Upgrade inside Console → Billing.
Need more coverage?
Upgrade to Pro Console for AI refresh and higher limits.
For incident response and remediation, OffSeq services can help resolve threats faster.
Latest Threats
Check if your credentials are on the dark web
Instant breach scanning across billions of leaked records. Free tier available.