Django4Shell puts GeoDjango apps at risk of RCE
Django4Shell is a critical GeoDjango vulnerability that can let an authenticated attacker write arbitrary files and potentially achieve remote code execution, or RCE, meaning the ability to make a server run attacker-chosen commands. The Django maintainers fixed it in versions 6.1.4, 6.0.11 and 5.2.20. The flaw is tracked as CVE-2026-124827 and has a CVSS severity score of 9.0, where CVSS is a standard system for rating the seriousness of security vulnerabilities.
The vulnerability affects GeoDjango, Django's geographic and mapping functionality, in the django.contrib.gis module. It is an incomplete correction for CVE-2026-87890, which was itself an incomplete patch for CVE-2026-15307, a high-severity issue addressed in August 2026. The earlier flaw involved the way GeoDjango parsed raster data during spatial lookups and could allow files to be written on the server.
CVE-2026-87890 targeted the same module and allowed server-side request forgery, or SSRF. This is a technique that makes a server send requests chosen by an attacker. Crafted GDAL Virtual Raster payloads could use it to refer to an external raster source. In October 2026 release notes, Django maintainers said the issue could affect applications that passed attacker-controlled bytes directly into a spatial lookup. They changed the mitigation so raster values supplied as bytes must be wrapped in GDALRaster before spatial lookups are performed. Valid hexadecimal geometry values remain accepted, but the change is backward incompatible. Django also advises validating all untrusted input before using it.
The new Django4Shell issue remains because those protections did not cover the RasterField assignment path. RasterField is the Django model field used for raster data, such as geospatial images or grids. According to the Django advisory, assigning a raster definition with a user-controlled name and a non-default driver can cause GDAL, the Geospatial Data Abstraction Library, to write a file to a location selected by the attacker. Depending on the raster driver, that file-writing ability can become remote code execution.
The attacker can control the destination path, file contents and filename through a crafted JSON raster body, according to the vulnerability description. Possible outcomes include overwriting application source code, placing web shells in static directories, or damaging configuration files. A web shell is a file that gives an attacker a way to send commands to a web server. The attack does not require database interaction, and it does not depend on a model.save() call being made.
One particularly serious execution path involves a file named sitecustomize.py. When placed in the worker's current directory, which is typically on Python's search path, Python can import it automatically when the interpreter starts, before application code runs. The payload could then execute during a runserver reload, a Gunicorn worker fork, a manage.py cron job or a subprocess launch, using the permissions of the web server's operating-system account. The same flaw could also be used to place .pth files in site-packages, access secrets and environment variables, steal or change data, and move from the application into the host or connected network.
Successful exploitation depends on four conditions. The application must use django.contrib.gis with a RasterField model, a setup found with moderate prevalence in government, mapping, geographic information systems, agricultural and environmental platforms. The RasterField must be exposed through a ModelForm, a form generated from a model, or Django's default administration interface. Django automatically creates admin forms for registered models unless administrators exclude or customise them, making this condition very common.
The application also needs GDAL with the EHdr driver, a format driver that is included in standard GDAL builds across apt, yum, Homebrew and conda without special compilation options. Finally, the attacker needs a writable destination. The worker's current working directory, usually the project root, is writable by definition in the described setup and is commonly on Python's search path. The source analysis says three of these four conditions are generally met by default in a standard Django or GeoDjango deployment. The main additional requirement is staff-level authentication. Organisations using raster data with standard admin access and a default GDAL build should treat the application as exposed until it is patched.
The patched Django releases address three other named vulnerabilities as well. CVE-2026-132092 is an SQL injection issue in range and in lookups. SQL injection is a way to interfere with database commands by submitting specially crafted input. CVE-2026-115868 is a possible cross-site scripting flaw in the truncatechars_html template filter. Cross-site scripting, or XSS, can cause a website to run unwanted code in a visitor's browser. CVE-2026-125673 is a cache-poisoning flaw involving dot segments in request paths, which can cause incorrect content to be stored and served from a cache.
Django administrators should update supported applications to 6.1.4, 6.0.11 or 5.2.20, then review whether RasterField is exposed through admin pages, ModelForms or writable model serializers. They should also check who has staff-level access, validate raster input, and inspect writable application directories for unexpected files such as sitecustomize.py or .pth files. For organisations managing this kind of application environment, AEU-I provides security-first IT, infrastructure and consulting.