{"title":"Django 5.2.2 release notes","version":"dev","locale":"en","docname":"releases/5.2.2","url":"/en/dev/releases/5.2.2/","canonical":"https://djangodocs.dev/en/dev/releases/5.2.2/","summary":"Django 5.2.2 fixes a security issue with severity “low” and several bugs in 5.2.1.","html":"<h1>Django 5.2.2 release notes<a class=\"heading-anchor\" href=\"#django-5-2-2-release-notes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p><em>June 4, 2025</em></p>\n<p>Django 5.2.2 fixes a security issue with severity “low” and several bugs in\n5.2.1.</p>\n<section id=\"cve-2025-48432-potential-log-injection-via-unescaped-request-path\">\n<h2>CVE-2025-48432: Potential log injection via unescaped request path<a class=\"heading-anchor\" href=\"#cve-2025-48432-potential-log-injection-via-unescaped-request-path\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Internal HTTP response logging used <code class=\"docutils literal notranslate\">request.path</code> directly, allowing control\ncharacters (e.g. newlines or ANSI escape sequences) to be written unescaped\ninto logs. This could enable log injection or forgery, letting attackers\nmanipulate log appearance or structure, especially in logs processed by\nexternal systems or viewed in terminals.</p>\n<p>Although this does not directly impact Django’s security model, it poses risks\nwhen logs are consumed or interpreted by other tools. To fix this, the internal\n<code class=\"docutils literal notranslate\">django.utils.log.log_response()</code> function now escapes all positional\nformatting arguments using a safe encoding.</p>\n</section>\n<section id=\"bugfixes\">\n<h2>Bugfixes<a class=\"heading-anchor\" href=\"#bugfixes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<ul class=\"simple\">\n<li><p>Fixed a crash when using <code class=\"docutils literal notranslate\">select_related</code> against a <code class=\"docutils literal notranslate\">ForeignObject</code>\noriginating from a model with a <code class=\"docutils literal notranslate\">CompositePrimaryKey</code> (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36373\">#36373</a>).</p></li>\n<li><p>Fixed a bug in Django 5.2 where subqueries using <code class=\"docutils literal notranslate\">&quot;pk&quot;</code> to reference models\nwith a <code class=\"docutils literal notranslate\">CompositePrimaryKey</code> failed to raise <code class=\"docutils literal notranslate\">ValueError</code> when too many\nor too few columns were selected (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36392\">#36392</a>).</p></li>\n<li><p>Fixed a regression in Django 5.2 that caused a crash when no arguments were\npassed into <code class=\"docutils literal notranslate\">QuerySet.union()</code> (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36388\">#36388</a>).</p></li>\n<li><p>Fixed a regression in Django 5.2 where subclasses of <code class=\"docutils literal notranslate\">RemoteUserMiddleware</code>\nthat had overridden <code class=\"docutils literal notranslate\">process_request()</code> were no longer supported\n(<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36390\">#36390</a>).</p></li>\n<li><p>Fixed a regression in Django 5.2 that caused a crash when using <code class=\"docutils literal notranslate\">OuterRef</code>\nin the <code class=\"docutils literal notranslate\">filter</code> argument of an <code class=\"docutils literal notranslate\">Aggregate</code> expression (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36404\">#36404</a>).</p></li>\n<li><p>Fixed a regression in Django 5.2 that caused a crash when using <code class=\"docutils literal notranslate\">OuterRef</code>\nin PostgreSQL aggregate functions <code class=\"docutils literal notranslate\">ArrayAgg</code>, <code class=\"docutils literal notranslate\">StringAgg</code>, and\n<code class=\"docutils literal notranslate\">JSONBAgg</code> (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36405\">#36405</a>).</p></li>\n<li><p>Fixed a regression in Django 5.2 where admin’s <code class=\"docutils literal notranslate\">filter_horizontal</code> buttons\nlacked <code class=\"docutils literal notranslate\">type=&quot;button&quot;</code>, causing them to intercept form submission when\npressing the Enter key (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36423\">#36423</a>).</p></li>\n<li><p>Fixed a bug in Django 5.2 where calling <code class=\"docutils literal notranslate\">QuerySet.in_bulk()</code> with an\n<code class=\"docutils literal notranslate\">id_list</code> argument on models with a <code class=\"docutils literal notranslate\">CompositePrimaryKey</code> failed to\nobserve database parameter limits (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36416\">#36416</a>).</p></li>\n<li><p>Fixed a bug in Django 5.2 where <a class=\"reference internal\" href=\"/en/dev/ref/request-response/#django.http.HttpRequest.get_preferred_type\" title=\"django.http.HttpRequest.get_preferred_type\"><code class=\"xref py py-meth docutils literal notranslate\">HttpRequest.get_preferred_type()</code></a> did not account for media type\nparameters in <code class=\"docutils literal notranslate\">Accept</code> headers, reducing specificity in content negotiation\n(<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36411\">#36411</a>).</p></li>\n<li><p>Fixed a regression in Django 5.2 that caused a crash when using\n<code class=\"docutils literal notranslate\">QuerySet.prefetch_related()</code> to prefetch a foreign key with a <code class=\"docutils literal notranslate\">Prefetch</code>\nqueryset for a subclass of the foreign target (<a class=\"extlink-ticket reference external\" href=\"https://code.djangoproject.com/ticket/36432\">#36432</a>).</p></li>\n</ul>\n</section>","rootId":"django-5-2-2-release-notes","toc":[{"title":"CVE-2025-48432: Potential log injection via unescaped request path","anchor":"cve-2025-48432-potential-log-injection-via-unescaped-request-path","children":[]},{"title":"Bugfixes","anchor":"bugfixes","children":[]}],"breadcrumbs":[{"docname":"releases/index","title":"Release notes","url":"/en/dev/releases/"}],"prev":{"docname":"releases/5.2.3","title":"Django 5.2.3 release notes","url":"/en/dev/releases/5.2.3/"},"next":{"docname":"releases/5.2.1","title":"Django 5.2.1 release notes","url":"/en/dev/releases/5.2.1/"},"formats":{"html":"/en/dev/releases/5.2.2/","markdown":"/en/dev/releases/5.2.2.md","json":"/en/dev/releases/5.2.2.json"},"source":"https://github.com/django/django/blob/main/docs/releases/5.2.2.txt","official":"https://docs.djangoproject.com/en/dev/releases/5.2.2/","inVersions":["dev","6.1","6.0","5.2"],"inLocales":["en"]}