{"title":"Django 1.5.9 release notes","version":"dev","locale":"en","docname":"releases/1.5.9","url":"/en/dev/releases/1.5.9/","canonical":"https://djangodocs.dev/en/dev/releases/1.5.9/","summary":"Django 1.5.9 fixes several security issues in 1.5.8. In certain situations, URL reversing could generate scheme-relative URLs (URLs starting with two…","html":"<h1>Django 1.5.9 release notes<a class=\"heading-anchor\" href=\"#django-1-5-9-release-notes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p><em>August 20, 2014</em></p>\n<p>Django 1.5.9 fixes several security issues in 1.5.8.</p>\n<section id=\"reverse-could-generate-urls-pointing-to-other-hosts\">\n<h2><code class=\"docutils literal notranslate\">reverse()</code> could generate URLs pointing to other hosts<a class=\"heading-anchor\" href=\"#reverse-could-generate-urls-pointing-to-other-hosts\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>In certain situations, URL reversing could generate scheme-relative URLs  (URLs\nstarting with two slashes), which could unexpectedly redirect a user  to a\ndifferent host. An attacker could exploit this, for example, by redirecting\nusers to a phishing site designed to ask for user’s passwords.</p>\n<p>To remedy this, URL reversing now ensures that no URL starts with two slashes\n(//), replacing the second slash with its URL encoded counterpart (%2F). This\napproach ensures that semantics stay the same, while making the URL relative to\nthe domain and not to the scheme.</p>\n</section>\n<section id=\"file-upload-denial-of-service\">\n<h2>File upload denial-of-service<a class=\"heading-anchor\" href=\"#file-upload-denial-of-service\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Before this release, Django’s file upload handing in its default configuration\nmay degrade to producing a huge number of <code class=\"docutils literal notranslate\">os.stat()</code> system calls when a\nduplicate filename is uploaded. Since <code class=\"docutils literal notranslate\">stat()</code> may invoke IO, this may\nproduce a huge data-dependent slowdown that slowly worsens over time. The net\nresult is that given enough time, a user with the ability to upload files can\ncause poor performance in the upload handler, eventually causing it to become\nvery slow simply by uploading 0-byte files. At this point, even a slow network\nconnection and few HTTP requests would be all that is necessary to make a site\nunavailable.</p>\n<p>We’ve remedied the issue by changing the algorithm for generating file names if\na file with the uploaded name already exists. <a class=\"reference internal\" href=\"/en/dev/ref/files/storage/#django.core.files.storage.Storage.get_available_name\" title=\"django.core.files.storage.Storage.get_available_name\"><code class=\"xref py py-meth docutils literal notranslate\">Storage.get_available_name</code></a> now appends an\nunderscore plus a random 7 character alphanumeric string (e.g. <code class=\"docutils literal notranslate\">&quot;_x3a1gho&quot;</code>),\nrather than iterating through an underscore followed by a number (e.g.\n<code class=\"docutils literal notranslate\">&quot;_1&quot;</code>, <code class=\"docutils literal notranslate\">&quot;_2&quot;</code>, etc.).</p>\n</section>\n<section id=\"remoteusermiddleware-session-hijacking\">\n<h2><code class=\"docutils literal notranslate\">RemoteUserMiddleware</code> session hijacking<a class=\"heading-anchor\" href=\"#remoteusermiddleware-session-hijacking\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>When using the <a class=\"reference internal\" href=\"/en/dev/ref/middleware/#django.contrib.auth.middleware.RemoteUserMiddleware\" title=\"django.contrib.auth.middleware.RemoteUserMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">RemoteUserMiddleware</code></a>\nand the <code class=\"docutils literal notranslate\">RemoteUserBackend</code>, a change to the <code class=\"docutils literal notranslate\">REMOTE_USER</code> header between\nrequests without an intervening logout could result in the prior user’s session\nbeing co-opted by the subsequent user. The middleware now logs the user out on\na failed login attempt.</p>\n</section>\n<section id=\"data-leakage-via-query-string-manipulation-in-contrib-admin\">\n<h2>Data leakage via query string manipulation in <code class=\"docutils literal notranslate\">contrib.admin</code><a class=\"heading-anchor\" href=\"#data-leakage-via-query-string-manipulation-in-contrib-admin\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>In older versions of Django it was possible to reveal any field’s data by\nmodifying the “popup” and “to_field” parameters of the query string on an admin\nchange form page. For example, requesting a URL like\n<code class=\"docutils literal notranslate\">/admin/auth/user/?pop=1&amp;t=password</code> and viewing the page’s HTML allowed\nviewing the password hash of each user. While the admin requires users to have\npermissions to view the change form pages in the first place, this could leak\ndata if you rely on users having access to view only certain fields on a model.</p>\n<p>To address the issue, an exception will now be raised if a <code class=\"docutils literal notranslate\">to_field</code> value\nthat isn’t a related field to a model that has been registered with the admin\nis specified.</p>\n</section>","rootId":"django-1-5-9-release-notes","toc":[{"title":"reverse() could generate URLs pointing to other hosts","anchor":"reverse-could-generate-urls-pointing-to-other-hosts","children":[]},{"title":"File upload denial-of-service","anchor":"file-upload-denial-of-service","children":[]},{"title":"RemoteUserMiddleware session hijacking","anchor":"remoteusermiddleware-session-hijacking","children":[]},{"title":"Data leakage via query string manipulation in contrib.admin","anchor":"data-leakage-via-query-string-manipulation-in-contrib-admin","children":[]}],"breadcrumbs":[{"docname":"releases/index","title":"Release notes","url":"/en/dev/releases/"}],"prev":{"docname":"releases/1.5.10","title":"Django 1.5.10 release notes","url":"/en/dev/releases/1.5.10/"},"next":{"docname":"releases/1.5.8","title":"Django 1.5.8 release notes","url":"/en/dev/releases/1.5.8/"},"formats":{"html":"/en/dev/releases/1.5.9/","markdown":"/en/dev/releases/1.5.9.md","json":"/en/dev/releases/1.5.9.json"},"source":"https://github.com/django/django/blob/main/docs/releases/1.5.9.txt","official":"https://docs.djangoproject.com/en/dev/releases/1.5.9/","inVersions":["dev","6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10","1.9","1.8"],"inLocales":["en"]}