{"title":"Django 1.5.3 release notes","version":"dev","locale":"en","docname":"releases/1.5.3","url":"/en/dev/releases/1.5.3/","canonical":"https://djangodocs.dev/en/dev/releases/1.5.3/","summary":"This is Django 1.5.3, the third release in the Django 1.5 series. It addresses one security issue and also contains an opt-in feature to enhance the…","html":"<h1>Django 1.5.3 release notes<a class=\"heading-anchor\" href=\"#django-1-5-3-release-notes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p><em>September 10, 2013</em></p>\n<p>This is Django 1.5.3, the third release in the Django 1.5 series. It addresses\none security issue and also contains an opt-in feature to enhance the security\nof <a class=\"reference internal\" href=\"/en/dev/topics/http/sessions/#module-django.contrib.sessions\" title=\"django.contrib.sessions: Provides session management for Django projects.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.sessions</code></a>.</p>\n<section id=\"directory-traversal-vulnerability-in-ssi-template-tag\">\n<h2>Directory traversal vulnerability in <code class=\"docutils literal notranslate\">ssi</code> template tag<a class=\"heading-anchor\" href=\"#directory-traversal-vulnerability-in-ssi-template-tag\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>In previous versions of Django it was possible to bypass the\n<code class=\"docutils literal notranslate\">ALLOWED_INCLUDE_ROOTS</code> setting used for security with the <code class=\"docutils literal notranslate\">ssi</code>\ntemplate tag by specifying a relative path that starts with one of the allowed\nroots. For example, if <code class=\"docutils literal notranslate\">ALLOWED_INCLUDE_ROOTS = (&quot;/var/www&quot;,)</code> the following\nwould be possible:</p>\n<div class=\"code-block\" data-language=\"html+django\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Django template</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Django template code\"><code><span class=\"cp\">{%</span> <span class=\"k\">ssi</span> <span class=\"s2\">&quot;/var/www/../../etc/passwd&quot;</span> <span class=\"cp\">%}</span>\n</code></pre></div>\n<p>In practice this is not a very common problem, as it would require the template\nauthor to put the <code class=\"docutils literal notranslate\">ssi</code> file in a user-controlled variable, but it’s possible\nin principle.</p>\n</section>\n<section id=\"mitigating-a-remote-code-execution-vulnerability-in-django-contrib-sessions\">\n<h2>Mitigating a remote-code execution vulnerability in <a class=\"reference internal\" href=\"/en/dev/topics/http/sessions/#module-django.contrib.sessions\" title=\"django.contrib.sessions: Provides session management for Django projects.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.sessions</code></a><a class=\"heading-anchor\" href=\"#mitigating-a-remote-code-execution-vulnerability-in-django-contrib-sessions\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p><a class=\"reference internal\" href=\"/en/dev/topics/http/sessions/#module-django.contrib.sessions\" title=\"django.contrib.sessions: Provides session management for Django projects.\"><code class=\"xref py py-mod docutils literal notranslate\">django.contrib.sessions</code></a> currently uses <a class=\"reference external\" href=\"https://docs.python.org/3/library/pickle.html#module-pickle\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">pickle</code></a> to serialize\nsession data before storing it in the backend. If you’re using the <a class=\"reference internal\" href=\"/en/dev/topics/http/sessions/#cookie-session-backend\"><span class=\"std std-ref\">signed\ncookie session backend</span></a> and <a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-SECRET_KEY\"><code class=\"xref std std-setting docutils literal notranslate\">SECRET_KEY</code></a> is\nknown by an attacker (there isn’t an inherent vulnerability in Django that\nwould cause it to leak), the attacker could insert a string into their session\nwhich, when unpickled, executes arbitrary code on the server. The technique for\ndoing so is simple and easily available on the internet. Although the cookie\nsession storage signs the cookie-stored data to prevent tampering, a\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-SECRET_KEY\"><code class=\"xref std std-setting docutils literal notranslate\">SECRET_KEY</code></a> leak immediately escalates to a remote code execution\nvulnerability.</p>\n<p>This attack can be mitigated by serializing session data using JSON rather\nthan <a class=\"reference external\" href=\"https://docs.python.org/3/library/pickle.html#module-pickle\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">pickle</code></a>. To facilitate this, Django 1.5.3 introduces a new setting,\n<a class=\"reference internal\" href=\"/en/dev/ref/settings/#std-setting-SESSION_SERIALIZER\"><code class=\"xref std std-setting docutils literal notranslate\">SESSION_SERIALIZER</code></a>, to customize the session serialization format.\nFor backwards compatibility, this setting defaults to using <a class=\"reference external\" href=\"https://docs.python.org/3/library/pickle.html#module-pickle\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">pickle</code></a>.\nWhile JSON serialization does not support all Python objects like <a class=\"reference external\" href=\"https://docs.python.org/3/library/pickle.html#module-pickle\" title=\"(in Python v3.14)\"><code class=\"xref py py-mod docutils literal notranslate\">pickle</code></a>\ndoes, we highly recommend switching to JSON-serialized values. Also,\nas JSON requires string keys, you will likely run into problems if you are\nusing non-string keys in <code class=\"docutils literal notranslate\">request.session</code>. See the\n<a class=\"reference internal\" href=\"/en/dev/topics/http/sessions/#session-serialization\"><span class=\"std std-ref\">Session serialization</span></a> documentation for more details.</p>\n</section>","rootId":"django-1-5-3-release-notes","toc":[{"title":"Directory traversal vulnerability in ssi template tag","anchor":"directory-traversal-vulnerability-in-ssi-template-tag","children":[]},{"title":"Mitigating a remote-code execution vulnerability in django.contrib.sessions","anchor":"mitigating-a-remote-code-execution-vulnerability-in-django-contrib-sessions","children":[]}],"breadcrumbs":[{"docname":"releases/index","title":"Release notes","url":"/en/dev/releases/"}],"prev":{"docname":"releases/1.5.4","title":"Django 1.5.4 release notes","url":"/en/dev/releases/1.5.4/"},"next":{"docname":"releases/1.5.2","title":"Django 1.5.2 release notes","url":"/en/dev/releases/1.5.2/"},"formats":{"html":"/en/dev/releases/1.5.3/","markdown":"/en/dev/releases/1.5.3.md","json":"/en/dev/releases/1.5.3.json"},"source":"https://github.com/django/django/blob/main/docs/releases/1.5.3.txt","official":"https://docs.djangoproject.com/en/dev/releases/1.5.3/","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"]}