# Django4Shell (CVE-2026-124827): GeoDjango RasterField Arbitrary File Write Enabling Remote Code Execution

> CVE-2026-124827 ("Django4Shell") is a server-side arbitrary file-write flaw in GeoDjango's RasterField (PostGIS only). A staff-level user can supply crafted raster JSON with a user-controlled name and a non-default GDAL driver to make GDAL write attacker-controlled content to an attacker-chosen path, which can lead to remote code execution. It is an incomplete fix for CVE-2026-87890 and is fixed in Django 6.1.4, 6.0.11 and 5.2.20.

- **Author:** Threadlinqs Team
- **Published:** 2026-12-02T18:20:14Z
- **Last updated:** 2026-12-02T18:20:14Z
- **Canonical:** https://intel.threadlinqs.com/threat/TL-2026-7303
- **Card image:** https://intel.threadlinqs.com/og/threat/TL-2026-7303.png
- **ID:** TL-2026-7303
- **Severity:** CRITICAL (CVSS 9)
- **Category:** VULNERABILITY
- **Status:** ACTIVE
- **Detections:** 9 (1 shown free below) · **IOCs:** 10
- **CVEs:** CVE-2026-124827, CVE-2026-87890, CVE-2026-15307, CVE-2026-1207

## Description

CVE-2026-124827 was disclosed in the Django security release of 2026-12-02 (post titled "Server-side file-write via RasterField assignment", credited to reporter Mohammed Fathy) and branded "Django4Shell" by Orca Security. Assigning a raster data definition to a RasterField with a user-controlled name and a non-default GDAL driver can cause GDAL to write a file to an attacker-controlled location. Depending on the driver, this can lead to remote code execution. RasterField is implemented only on the PostGIS backend; geometry fields are not affected.

Reachability: in common configurations RasterField falls back to the CharField form field, so the flaw is reachable wherever RasterField is exposed through the Django admin, ModelForms, or writable model serializers. Orca reports that exploitation needs staff-level authentication, that the attacker controls target path, file content and filename, and that it does not require database interaction or a call to model.save(). Orca names the EHdr GDAL driver as near-universal in GeoDjango deployments. Orca states a proof of concept is publicly available through the researcher's disclosure; no in-the-wild exploitation is reported in the sources reviewed.

Post-write RCE paths described by Orca: writing sitecustomize.py in the working directory (executed at interpreter startup on the next reload or fork), dropping .pth files into site-packages, overwriting application source code, planting web shells in static directories, and corrupting configuration files.

This is the third fix for the same attack surface: CVE-2026-15307 (GeoDjango spatial lookups parsed the right-hand-side value as a raster via GDALRaster, patched August 2026) was incompletely fixed by CVE-2026-87890 (October 2026), which was in turn incompletely fixed by CVE-2026-124827. An earlier, distinct RasterField issue, CVE-2026-1207 (SQL injection via band index in RasterField lookups), was fixed in February 2026.

Severity note: Orca rates the issue 9.0 Critical; the Django project rates it high. No CVSS vector or CWE was published in the sources reviewed, so neither is recorded here. The same Django release also fixes CVE-2026-132092 (SQL injection in range/in lookups, High), CVE-2026-115868 (XSS in truncatechars_html), CVE-2026-125673 (cache poisoning via dot segments), CVE-2026-119642 and CVE-2026-127929 (admin information leaks) and CVE-2026-132809 (heap buffer overflow in OGRGeometry.wkb). The NVD page for this CVE could not be retrieved and independent search engines did not index the CVE ID at research time, so the Django project post and Orca article are the only primary sources.

## MITRE ATT&CK

- T1190 Exploit Public-Facing Application
- T1078 Valid Accounts
- T1059.006 Command and Scripting Interpreter: Python
- T1505.003 Server Software Component: Web Shell
- T1546.018 Event Triggered Execution: Python Startup Hooks
- T1546.018 Event Triggered Execution: Python Startup Hooks
- T1565.001 Data Manipulation: Stored Data Manipulation

## Free detection (Splunk SPL, Microsoft KQL, Sigma)

**Django4Shell CVE-2026-124827 - Django/WSGI Worker Writes Python Startup Hook (sitecustomize.py / .pth)** (`TL-2026-7303-SPL-001`)

Detects a Django/WSGI/ASGI application process (python, gunicorn, uwsgi, daphne, uvicorn, hypercorn) creating sitecustomize.py, usercustomize.py or a site-packages .pth file. This is the documented post-write RCE path for the GeoDjango RasterField arbitrary file write (CVE-2026-124827, Django4Shell, GDAL EHdr driver), where the written file executes at the next interpreter start or fork. A web application worker has no legitimate reason to create these files. Telemetry assumption: Sysmon for Linux file-create events (EventID 11).

- **Languages:** Splunk SPL, Microsoft KQL, Sigma
- **ATT&CK:** T1190, T1546.018
- **Data sources:** sysmon_for_linux (index=linux sourcetype=sysmon:linux EventID=11), DeviceFileEvents (Microsoft Defender for Endpoint on Linux)
- **Severity:** critical
- **Confidence:** high

### Splunk SPL

````spl
index=linux sourcetype="sysmon:linux" EventID=11 earliest=-24h
```Django4Shell CVE-2026-124827 - app worker dropping a Python startup hook (T1546.018)```
| where match(Image, "/(python[0-9.]*|gunicorn|uwsgi|daphne|uvicorn|hypercorn)$")
| where match(TargetFilename, "(?i)/(sitecustomize|usercustomize)[.]py$") OR match(TargetFilename, "(?i)/(site|dist)-packages/[^/]+[.]pth$")
| stats count min(_time) as first_seen max(_time) as last_seen values(TargetFilename) as files values(User) as users by Computer Image
| eval first_seen=strftime(first_seen, "%F %T"), last_seen=strftime(last_seen, "%F %T")
| table Computer Image users files count first_seen last_seen
````

### Microsoft KQL

```kql
DeviceFileEvents
| where Timestamp > ago(24h)
| where ActionType in ('FileCreated', 'FileModified', 'FileRenamed')
| where InitiatingProcessCommandLine has_any ('gunicorn', 'uwsgi', 'daphne', 'uvicorn', 'hypercorn')
| where FileName in~ ('sitecustomize.py', 'usercustomize.py') or (FileName endswith '.pth' and (FolderPath contains 'site-packages' or FolderPath contains 'dist-packages'))
| project Timestamp, DeviceName, ActionType, FolderPath, FileName, InitiatingProcessAccountName, InitiatingProcessFileName, InitiatingProcessCommandLine, SHA256
| order by Timestamp desc
```

### Sigma

```yaml
title: Django4Shell - Application Worker Writes Python Startup Hook
id: 3f2a9c1e-7b64-4d1a-9e0b-5a1c2d3e4f01
status: experimental
description: Detects a Django/WSGI/ASGI worker process creating sitecustomize.py, usercustomize.py or a site-packages .pth file, the documented post-write RCE path for CVE-2026-124827 (Django4Shell, GeoDjango RasterField arbitrary file write).
references:
  - https://www.djangoproject.com/weblog/2026/dec/02/security-releases/
  - https://orca.security/resources/research/django4shell-cve-2026-124827-critical-geodjango-rasterfield-flaw-enables-remote-code-execution/
author: Threadlinqs Team
date: 2026-12-02
tags:
  - attack.initial-access
  - attack.t1190
  - attack.persistence
  - attack.privilege-escalation
  - attack.t1546.018
  - cve.2026.124827
logsource:
  product: linux
  category: file_event
detection:
  selection_proc:
    Image|re: '/(python[0-9.]*|gunicorn|uwsgi|daphne|uvicorn|hypercorn)$'
  selection_startup:
    TargetFilename|re: '(?i)/(sitecustomize|usercustomize)[.]py$'
  selection_pth:
    TargetFilename|re: '(?i)/(site|dist)-packages/[^/]+[.]pth$'
  condition: selection_proc and (selection_startup or selection_pth)
falsepositives:
  - Deployment or package installation run through a python interpreter under the same account as the web worker
  - Management commands that install packages from within the application environment
level: critical

```

**Known false positives:**

- pip or deployment tooling executed as the same service account as the web worker
- Legitimate package that ships a .pth file installed by an application-level update job

**Tuning notes:** Adjust index, sourcetype and the EventID field name (EventID vs EventCode) to match your Sysmon for Linux ingestion. Exclude the deploy account or CI hosts that legitimately run pip under a python image. If workers run under a distinct service user, add a User filter to tighten. Treat any hit as high priority, then check Django version against 6.1.4 / 6.0.11 / 5.2.20 and review recent admin POSTs.

### 8 more detection rules (Splunk SPL, Microsoft KQL, Sigma), unlock with TL Creds

- Django4Shell CVE-2026-124827 - Django Worker Writes Application Source or Config ([indicator], .py, .env) (locked: unlock with TL Creds)
- Django4Shell CVE-2026-124827 - Django Worker Spawns Shell, Downloader or Recon Tooling (locked: unlock with TL Creds)
- Django4Shell CVE-2026-124827 - Django Worker Outbound Connection to Public IP on Non-Web Port (locked: unlock with TL Creds)
- Django4Shell CVE-2026-124827 - Django Worker Writes Script Content Into Static Directory (Web Shell) (locked: unlock with TL Creds)
- Django4Shell CVE-2026-124827 - Web Shell Access Pattern in Django Static Directory (locked: unlock with TL Creds)
- Django4Shell CVE-2026-124827 - Python One-Liner Reverse Shell (socket + pty/dup2/shell) (locked: unlock with TL Creds)
- Django4Shell CVE-2026-124827 - Rare [indicator] / site-packages .pth Creation Outside Package Managers (locked: unlock with TL Creds)
- Django4Shell CVE-2026-124827 - RasterField Exploit Payload (Non-Default GDAL Driver + Raster Name) in Form or API Request Body (locked: unlock with TL Creds)

Sign up free to unlock the detection rules: https://threadlinqs.com/?modal=signup

## Sources

- [Django4Shell (CVE-2026-124827): Critical GeoDjango RasterField Flaw Enables Remote Code Execution](https://orca.security/resources/research/django4shell-cve-2026-124827-critical-geodjango-rasterfield-flaw-enables-remote-code-execution/)
- [Django security releases (Dec 2, 2026): Server-side file-write via RasterField assignment](https://www.djangoproject.com/weblog/2026/dec/02/security-releases/)
- [NVD - CVE-2026-15307 (predecessor: GeoDjango spatial lookups)](https://nvd.nist.gov/vuln/detail/CVE-2026-15307)
- [Rapid7 - CVE-2026-15307](https://www.rapid7.com/db/vulnerabilities/cve-2026-15307/)
- [Ubuntu Security - CVE-2026-15307](https://ubuntu.com/security/CVE-2026-15307)
- [Red Hat Bugzilla 2513908 - CVE-2026-15307 python-django4.2: RCE via GeoDjango spatial lookups](https://bugzilla.redhat.com/show_bug.cgi?id=2513908)
- [OSV - CVE-2026-1207 (earlier RasterField SQL injection)](https://osv.dev/CVE-2026-1207)

## Full data

The other 8 detection rules (Splunk SPL / Microsoft KQL / Sigma) unlock with TL Creds; a free account includes daily creds: https://threadlinqs.com/?modal=signup
Indicator values unlock with TL Creds, at a lower price on Red and Purple; AI agents can query rules and IOCs through the Threadlinqs MCP server (Purple and Gold in full, 2 calls a day on a free account): https://intel.threadlinqs.com/mcp

Canonical: https://intel.threadlinqs.com/threat/TL-2026-7303
