Django Maintainers Issue Urgent Security Releases to Patch Critical "Django4shell" RCES

The maintainers of the widely used Django web framework have rolled out a series of critical security updates, releasing versions 6.1.4, 6.0.11, and 5.2.20 to address a total of seven security vulnerabilities. Among these flaws is a highly dangerous remote code execution vulnerability that has sent shockwaves through the Python web development community.

The most prominent issue in this advisory is tracked as CVE-2026-124827. Carrying a severe CVSS base score of 9.0, the vulnerability has been formally codenamed "Django4shell" by Mohamed K. Fathy, who serves as the head of cybersecurity at Robusta Technology Group. According to the technical breakdown, this critical bug represents an incomplete fix for a previous security advisory, CVE-2026-87890. That earlier advisory itself stemmed from yet another patch for an initial flaw, CVE-2026-15307, which was originally disclosed and addressed by the Django security team back in August 2026.

The historical chain of vulnerabilities centers heavily around GeoDjango, specifically the spatial lookup raster parsing mechanism contained within the "django.contrib.gis" module. The initial flaw, CVE-2026-15307, was classified as a high-severity issue that allowed for server-side file writes, which could eventually be leveraged to achieve remote code execution on affected servers.

Following that discovery, the subsequent flaw—CVE-2026-87890—targeted the exact same module. However, rather than focusing purely on local file manipulation, it enabled server-side request forgery (SSRF). Attackers were able to trigger this behavior by supplying specially crafted Geospatial Data Abstraction Library, or GDAL, Virtual Raster payloads that deliberately referenced external raster sources.

New Django4Shell Vulnerability Enables Django RCE via GeoDjango Form Validation

When addressing the second flaw in October 2026, Django maintainers explained that the issue could be actively exploited by applications that inadvertently passed attacker-controlled bytes directly into a spatial lookup. They acknowledged at the time that the vector had been completely overlooked during the initial remediation of CVE-2026-15307.

To mitigate that specific vector, the maintainers implemented a breaking change requiring raster values provided as bytes to be strictly wrapped in GDALRaster before being utilized in spatial lookups, while byte values representing valid hexadecimal geometries continued to be accepted. The maintainers also issued a broad reminder that all untrusted user input should undergo rigorous validation before being processed by application logic.

Despite those prior efforts, the newly disclosed CVE-2026-124827 demonstrates that the previous security boundaries and protections failed to extend comprehensively to the RasterField assignment path. This critical oversight leaves an opening for malicious actors to successfully obtain arbitrary file write and remote code execution primitives.

Detailing the mechanics of the exploit, Fathy explained via email that attackers are capable of controlling the target file path, the actual file content, and the destination filename entirely through a carefully crafted JSON raster body. This level of control gives malicious actors the power to overwrite core application source code, drop malicious web shells directly into static directories, or quietly corrupt critical configuration files.

Furthermore, Fathy highlighted how an attacker can leverage this capability by writing a custom "sitecustomize.py" file into the worker’s current working directory, which typically resides on Python’s search path. By doing so, the attacker successfully plants a file that the Python interpreter automatically and implicitly imports at startup before any legitimate application code even executes. Upon the next occurrence of a runserver reload, a Gunicorn worker fork, a management console cron job, or any standard subprocess execution, the hidden payload executes automatically with the full privileges of the web server’s operating system user.

New Django4Shell Vulnerability Enables Django RCE via GeoDjango Form Validation

Beyond planting initialization scripts, an attacker can exploit this vulnerability to deploy malicious .pth files directly into site-packages directories. They can also read sensitive system secrets and environment variables, exfiltrate or modify critical data, and pivot laterally into the host machine or the broader internal network. Crucially, this entire attack chain can be executed without requiring any database interaction or even triggering the standard model.save() method.

In their official security advisory, Django maintainers elaborated on the mechanics, noting that assigning a raster data definition to "django.contrib.gis.db.models.RasterField" using a user-controlled name parameter alongside a non-default driver can cause GDAL to write files to arbitrary, attacker-controlled locations. Depending heavily on the specific raster driver in use, this behavior can directly enable remote code execution. Because RasterField naturally falls back to functioning as a CharField form field, the underlying flaw was reachable by default on any models featuring a RasterField registered within the administrative interface, or when using standard ModelForms and writable model serializers.

Fathy noted that successful exploitation of the flaw relies on a set of specific pre-conditions, though a significant portion of them are satisfied by default within a standard, out-of-the-box Django and GeoDjango deployment. Fathy pointed out that the primary requirement is staff-level authentication. However, if a web application actively utilizes RasterField, the remaining operational conditions are almost certainly met by default. Consequently, organizations running GeoDjango with integrated raster data handling, standard administrative access configurations, and a default GDAL build should consider themselves actively exposed until they apply the newly released patches.

Aside from the critical Django4shell vulnerability tracked as CVE-2026-1248

27, the latest maintenance versions also incorporate fixes for several other notable security concerns. These include an SQL injection vulnerability impacting range and in lookups, tracked as CVE-2026-132092; a potential cross-site scripting vulnerability identified as CVE-2026-115868, which affects the truncatechars_html template filter; and a cache poisoning flaw that can be exploited via dot segments placed within request paths, tracked as CVE-2026-125673.