CVE-2019-14234

9.8 CRITICAL

📋 TL;DR

This SQL injection vulnerability in Django's PostgreSQL JSONField and HStoreField allows attackers to execute arbitrary SQL queries through crafted key or index names. It affects Django applications using these PostgreSQL-specific fields with vulnerable versions, potentially leading to data exposure or manipulation.

💻 Affected Systems

Products:
  • Django
Versions: Django 1.11.x before 1.11.23, 2.1.x before 2.1.11, and 2.2.x before 2.2.4
Operating Systems: All operating systems running Django
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications using django.contrib.postgres.fields.JSONField or django.contrib.postgres.fields.HStoreField with PostgreSQL backend.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete database compromise allowing data exfiltration, modification, or deletion, potentially leading to full system takeover if database privileges permit.

🟠

Likely Case

Unauthorized data access allowing attackers to read sensitive information from database tables accessible to the application.

🟢

If Mitigated

Limited impact with proper input validation and database user privilege restrictions in place.

🌐 Internet-Facing: HIGH - Web applications are directly exposed to crafted HTTP requests that could trigger the vulnerability.
🏢 Internal Only: MEDIUM - Internal applications could still be exploited by authenticated users or through other attack vectors.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: LOW

Exploitation requires ability to pass crafted dictionary to QuerySet.filter() function, typically through user-controllable input in web applications.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Django 1.11.23, 2.1.11, or 2.2.4

Vendor Advisory: https://docs.djangoproject.com/en/dev/releases/security/

Restart Required: Yes

Instructions:

1. Backup your Django project and database. 2. Update Django using pip: 'pip install Django==1.11.23' or appropriate version. 3. Restart your Django application server. 4. Test application functionality.

🔧 Temporary Workarounds

Input Validation Workaround

all

Implement strict input validation for all parameters passed to QuerySet.filter() when using JSONField or HStoreField

🧯 If You Can't Patch

  • Implement WAF rules to block SQL injection patterns in request parameters
  • Restrict database user permissions to minimum required for application functionality

🔍 How to Verify

Check if Vulnerable:

Check Django version with 'python -m django --version' and verify if it falls within affected ranges.

Check Version:

python -m django --version

Verify Fix Applied:

Confirm Django version is 1.11.23, 2.1.11, 2.2.4 or higher using 'python -m django --version'.

📡 Detection & Monitoring

Log Indicators:

  • Unusual database query patterns
  • Multiple failed login attempts followed by successful data extraction
  • Requests with crafted dictionary parameters containing SQL keywords

Network Indicators:

  • Unusual database connection patterns from application servers
  • Large data transfers from database to unexpected destinations

SIEM Query:

source="django.log" AND ("JSONField" OR "HStoreField") AND ("OR 1=1" OR "UNION" OR "SELECT *" OR unusual query patterns)

🔗 References

📤 Share & Export