==========================Django 1.5.6 release notes==========================*April 21, 2014*Django 1.5.6 fixes several bugs in 1.5.5, including three securityissues.Unexpected code execution using ``reverse()``=============================================Django's URL handling is based on a mapping of regex patterns(representing the URLs) to callable views, and Django's own processingconsists of matching a requested URL against those patterns todetermine the appropriate view to invoke.Django also provides a convenience function -- ``reverse()`` -- which performsthis process in the opposite direction. The ``reverse()`` function takesinformation about a view and returns a URL which would invoke that view. Useof ``reverse()`` is encouraged for application developers, as the output of``reverse()`` is always based on the current URL patterns, meaning developersdo not need to change other code when making changes to URLs.One argument signature for ``reverse()`` is to pass a dotted Pythonpath to the desired view. In this situation, Django will import themodule indicated by that dotted path as part of generating theresulting URL. If such a module has import-time side effects, thoseside effects will occur.Thus it is possible for an attacker to cause unexpected codeexecution, given the following conditions:1. One or more views are present which construct a URL based on userinput (commonly, a "next" parameter in a querystring indicatingwhere to redirect upon successful completion of an action).2. One or more modules are known to an attacker to exist on theserver's Python import path, which perform code execution with sideeffects on importing.To remedy this, ``reverse()`` will now only accept and import dottedpaths based on the view-containing modules listed in the project's :doc:`URLpattern configuration </topics/http/urls>`, so as to ensure that only modulesthe developer intended to be imported in this fashion can or will be imported.Caching of anonymous pages could reveal CSRF token==================================================Django includes both a :doc:`caching framework </topics/cache>` and a systemfor :doc:`preventing cross-site request forgery (CSRF) attacks</ref/csrf/>`. The CSRF-protection system is based on a random noncesent to the client in a cookie which must be sent by the client on futurerequests and, in forms, a hidden value which must be submitted back with theform.The caching framework includes an option to cache responses toanonymous (i.e., unauthenticated) clients.When the first anonymous request to a given page is by a client whichdid not have a CSRF cookie, the cache framework will also cache theCSRF cookie and serve the same nonce to other anonymous clients whodo not have a CSRF cookie. This can allow an attacker to obtain avalid CSRF cookie value and perform attacks which bypass the check forthe cookie.To remedy this, the caching framework will no longer cache suchresponses. The heuristic for this will be:1. If the incoming request did not submit any cookies, and2. If the response did send one or more cookies, and3. If the ``Vary: Cookie`` header is set on the response, then theresponse will not be cached.MySQL typecasting=================The MySQL database is known to "typecast" on certain queries; forexample, when querying a table which contains string values, but usinga query which filters based on an integer value, MySQL will firstsilently coerce the strings to integers and return a result based on that.If a query is performed without first converting values to theappropriate type, this can produce unexpected results, similar to whatwould occur if the query itself had been manipulated.Django's model field classes are aware of their own types and mostsuch classes perform explicit conversion of query arguments to thecorrect database-level type before querying. However, three modelfield classes did not correctly convert their arguments:* :class:`~django.db.models.FilePathField`* :class:`~django.db.models.GenericIPAddressField`* ``IPAddressField``These three fields have been updated to convert their arguments to thecorrect types before querying.Additionally, developers of custom model fields are now warned viadocumentation to ensure their custom field classes will performappropriate type conversions, and users of the :meth:`raw()<django.db.models.query.QuerySet.raw>` and :meth:`extra()<django.db.models.query.QuerySet.extra>` query methods -- which allow thedeveloper to supply raw SQL or SQL fragments -- will be advised to ensure theyperform appropriate manual type conversions prior to executing queries.Bugfixes========* Fixed :class:`~django.contrib.auth.backends.ModelBackend` raising``UnboundLocalError`` if :func:`~django.contrib.auth.get_user_model`raised an error (#21439).Additionally, Django's vendored version of six, ``django.utils.six``,has been upgraded to the latest release (1.6.1).