1.6.3.txt 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. ==========================
  2. Django 1.6.3 release notes
  3. ==========================
  4. *April 21, 2014*
  5. Django 1.6.3 fixes several bugs in 1.6.2, including three security issues,
  6. and makes one backwards-incompatible change:
  7. Unexpected code execution using ``reverse()``
  8. =============================================
  9. Django's URL handling is based on a mapping of regex patterns
  10. (representing the URLs) to callable views, and Django's own processing
  11. consists of matching a requested URL against those patterns to
  12. determine the appropriate view to invoke.
  13. Django also provides a convenience function --
  14. :func:`~django.core.urlresolvers.reverse` -- which performs this process
  15. in the opposite direction. The ``reverse()`` function takes
  16. information about a view and returns a URL which would invoke that
  17. view. Use of ``reverse()`` is encouraged for application developers,
  18. as the output of ``reverse()`` is always based on the current URL
  19. patterns, meaning developers do not need to change other code when
  20. making changes to URLs.
  21. One argument signature for ``reverse()`` is to pass a dotted Python
  22. path to the desired view. In this situation, Django will import the
  23. module indicated by that dotted path as part of generating the
  24. resulting URL. If such a module has import-time side effects, those
  25. side effects will occur.
  26. Thus it is possible for an attacker to cause unexpected code
  27. execution, given the following conditions:
  28. 1. One or more views are present which construct a URL based on user
  29. input (commonly, a "next" parameter in a querystring indicating
  30. where to redirect upon successful completion of an action).
  31. 2. One or more modules are known to an attacker to exist on the
  32. server's Python import path, which perform code execution with side
  33. effects on importing.
  34. To remedy this, ``reverse()`` will now only accept and import dotted
  35. paths based on the view-containing modules listed in the project's :doc:`URL
  36. pattern configuration </topics/http/urls>`, so as to ensure that only modules
  37. the developer intended to be imported in this fashion can or will be imported.
  38. Caching of anonymous pages could reveal CSRF token
  39. ==================================================
  40. Django includes both a :doc:`caching framework </topics/cache>` and a system
  41. for :doc:`preventing cross-site request forgery (CSRF) attacks
  42. </ref/csrf/>`. The CSRF-protection system is based on a random nonce
  43. sent to the client in a cookie which must be sent by the client on future
  44. requests and, in forms, a hidden value which must be submitted back with the
  45. form.
  46. The caching framework includes an option to cache responses to
  47. anonymous (i.e., unauthenticated) clients.
  48. When the first anonymous request to a given page is by a client which
  49. did not have a CSRF cookie, the cache framework will also cache the
  50. CSRF cookie and serve the same nonce to other anonymous clients who
  51. do not have a CSRF cookie. This can allow an attacker to obtain a
  52. valid CSRF cookie value and perform attacks which bypass the check for
  53. the cookie.
  54. To remedy this, the caching framework will no longer cache such
  55. responses. The heuristic for this will be:
  56. 1. If the incoming request did not submit any cookies, and
  57. 2. If the response did send one or more cookies, and
  58. 3. If the ``Vary: Cookie`` header is set on the response, then the
  59. response will not be cached.
  60. MySQL typecasting
  61. =================
  62. The MySQL database is known to "typecast" on certain queries; for
  63. example, when querying a table which contains string values, but using
  64. a query which filters based on an integer value, MySQL will first
  65. silently coerce the strings to integers and return a result based on that.
  66. If a query is performed without first converting values to the
  67. appropriate type, this can produce unexpected results, similar to what
  68. would occur if the query itself had been manipulated.
  69. Django's model field classes are aware of their own types and most
  70. such classes perform explicit conversion of query arguments to the
  71. correct database-level type before querying. However, three model
  72. field classes did not correctly convert their arguments:
  73. * :class:`~django.db.models.FilePathField`
  74. * :class:`~django.db.models.GenericIPAddressField`
  75. * :class:`~django.db.models.IPAddressField`
  76. These three fields have been updated to convert their arguments to the
  77. correct types before querying.
  78. Additionally, developers of custom model fields are now warned via
  79. documentation to ensure their custom field classes will perform
  80. appropriate type conversions, and users of the :meth:`raw()
  81. <django.db.models.query.QuerySet.raw>` and :meth:`extra()
  82. <django.db.models.query.QuerySet.extra>` query methods -- which allow the
  83. developer to supply raw SQL or SQL fragments -- will be advised to ensure they
  84. perform appropriate manual type conversions prior to executing queries.
  85. ``select_for_update()`` requires a transaction
  86. ==============================================
  87. Historically, queries that use
  88. :meth:`~django.db.models.query.QuerySet.select_for_update()` could be
  89. executed in autocommit mode, outside of a transaction. Before Django
  90. 1.6, Django's automatic transactions mode allowed this to be used to
  91. lock records until the next write operation. Django 1.6 introduced
  92. database-level autocommit; since then, execution in such a context
  93. voids the effect of ``select_for_update()``. It is, therefore, assumed
  94. now to be an error and raises an exception.
  95. This change was made because such errors can be caused by including an
  96. app which expects global transactions (e.g. :setting:`ATOMIC_REQUESTS
  97. <DATABASE-ATOMIC_REQUESTS>` set to ``True``), or Django's old autocommit
  98. behavior, in a project which runs without them; and further, such
  99. errors may manifest as data-corruption bugs.
  100. This change may cause test failures if you use ``select_for_update()``
  101. in a test class which is a subclass of
  102. :class:`~django.test.TransactionTestCase` rather than
  103. :class:`~django.test.TestCase`.
  104. Other bugfixes and changes
  105. ==========================
  106. * Content retrieved from the GeoIP library is now properly decoded from its
  107. default ``iso-8859-1`` encoding
  108. (`#21996 <http://code.djangoproject.com/ticket/21996>`_).
  109. * Fixed ``AttributeError`` when using
  110. :meth:`~django.db.models.query.QuerySet.bulk_create` with ``ForeignObject``
  111. (`#21566 <http://code.djangoproject.com/ticket/21566>`_).
  112. * Fixed crash of ``QuerySet``\s that use ``F() + timedelta()`` when their query
  113. was compiled more once
  114. (`#21643 <http://code.djangoproject.com/ticket/21643>`_).
  115. * Prevented custom ``widget`` class attribute of
  116. :class:`~django.forms.IntegerField` subclasses from being overwritten by the
  117. code in their ``__init__`` method
  118. (`#22245 <http://code.djangoproject.com/ticket/22245>`_).
  119. * Improved :func:`~django.utils.html.strip_tags` accuracy (but it still cannot
  120. guarantee an HTML-safe result, as stated in the documentation).
  121. * Fixed a regression in the :mod:`django.contrib.gis` SQL compiler for
  122. non-concrete fields (`#22250 <http://code.djangoproject.com/ticket/22250>`_).
  123. * Fixed :attr:`ModelAdmin.preserve_filters
  124. <django.contrib.admin.ModelAdmin.preserve_filters>` when running a site with
  125. a URL prefix (`#21795 <http://code.djangoproject.com/ticket/21795>`_).
  126. * Fixed a crash in the ``find_command`` management utility when the ``PATH``
  127. environment variable wasn't set
  128. (`#22256 <http://code.djangoproject.com/ticket/22256>`_).
  129. * Fixed :djadmin:`changepassword` on Windows
  130. (`#22364 <https://code.djangoproject.com/ticket/22364>`_).
  131. * Avoided shadowing deadlock exceptions on MySQL
  132. (`#22291 <https://code.djangoproject.com/ticket/22291>`_).
  133. * Wrapped database exceptions in ``_set_autocommit``
  134. (`#22321 <https://code.djangoproject.com/ticket/22321>`_).
  135. * Fixed atomicity when closing a database connection or when the database server
  136. disconnects (`#21239 <https://code.djangoproject.com/ticket/21239>`_ and
  137. `#21202 <https://code.djangoproject.com/ticket/21202>`_)
  138. * Fixed regression in ``prefetch_related`` that caused the related objects
  139. query to include an unnecessary join
  140. (`#21760 <https://code.djangoproject.com/ticket/21760>`_).
  141. Additionally, Django's vendored version of six, :mod:`django.utils.six` has been
  142. upgraded to the latest release (1.6.1).