1.5.6.txt 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. ==========================
  2. Django 1.5.6 release notes
  3. ==========================
  4. *April 21, 2014*
  5. Django 1.5.6 fixes several bugs in 1.5.5, including three security
  6. issues.
  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 -- ``reverse()`` -- which performs
  14. this process in the opposite direction. The ``reverse()`` function takes
  15. information about a view and returns a URL which would invoke that view. Use
  16. of ``reverse()`` is encouraged for application developers, as the output of
  17. ``reverse()`` is always based on the current URL patterns, meaning developers
  18. do not need to change other code when making changes to URLs.
  19. One argument signature for ``reverse()`` is to pass a dotted Python
  20. path to the desired view. In this situation, Django will import the
  21. module indicated by that dotted path as part of generating the
  22. resulting URL. If such a module has import-time side effects, those
  23. side effects will occur.
  24. Thus it is possible for an attacker to cause unexpected code
  25. execution, given the following conditions:
  26. 1. One or more views are present which construct a URL based on user
  27. input (commonly, a "next" parameter in a querystring indicating
  28. where to redirect upon successful completion of an action).
  29. 2. One or more modules are known to an attacker to exist on the
  30. server's Python import path, which perform code execution with side
  31. effects on importing.
  32. To remedy this, ``reverse()`` will now only accept and import dotted
  33. paths based on the view-containing modules listed in the project's :doc:`URL
  34. pattern configuration </topics/http/urls>`, so as to ensure that only modules
  35. the developer intended to be imported in this fashion can or will be imported.
  36. Caching of anonymous pages could reveal CSRF token
  37. ==================================================
  38. Django includes both a :doc:`caching framework </topics/cache>` and a system
  39. for :doc:`preventing cross-site request forgery (CSRF) attacks
  40. </ref/csrf/>`. The CSRF-protection system is based on a random nonce
  41. sent to the client in a cookie which must be sent by the client on future
  42. requests and, in forms, a hidden value which must be submitted back with the
  43. form.
  44. The caching framework includes an option to cache responses to
  45. anonymous (i.e., unauthenticated) clients.
  46. When the first anonymous request to a given page is by a client which
  47. did not have a CSRF cookie, the cache framework will also cache the
  48. CSRF cookie and serve the same nonce to other anonymous clients who
  49. do not have a CSRF cookie. This can allow an attacker to obtain a
  50. valid CSRF cookie value and perform attacks which bypass the check for
  51. the cookie.
  52. To remedy this, the caching framework will no longer cache such
  53. responses. The heuristic for this will be:
  54. 1. If the incoming request did not submit any cookies, and
  55. 2. If the response did send one or more cookies, and
  56. 3. If the ``Vary: Cookie`` header is set on the response, then the
  57. response will not be cached.
  58. MySQL typecasting
  59. =================
  60. The MySQL database is known to "typecast" on certain queries; for
  61. example, when querying a table which contains string values, but using
  62. a query which filters based on an integer value, MySQL will first
  63. silently coerce the strings to integers and return a result based on that.
  64. If a query is performed without first converting values to the
  65. appropriate type, this can produce unexpected results, similar to what
  66. would occur if the query itself had been manipulated.
  67. Django's model field classes are aware of their own types and most
  68. such classes perform explicit conversion of query arguments to the
  69. correct database-level type before querying. However, three model
  70. field classes did not correctly convert their arguments:
  71. * :class:`~django.db.models.FilePathField`
  72. * :class:`~django.db.models.GenericIPAddressField`
  73. * ``IPAddressField``
  74. These three fields have been updated to convert their arguments to the
  75. correct types before querying.
  76. Additionally, developers of custom model fields are now warned via
  77. documentation to ensure their custom field classes will perform
  78. appropriate type conversions, and users of the :meth:`raw()
  79. <django.db.models.query.QuerySet.raw>` and :meth:`extra()
  80. <django.db.models.query.QuerySet.extra>` query methods -- which allow the
  81. developer to supply raw SQL or SQL fragments -- will be advised to ensure they
  82. perform appropriate manual type conversions prior to executing queries.
  83. Bugfixes
  84. ========
  85. * Fixed :class:`~django.contrib.auth.backends.ModelBackend` raising
  86. ``UnboundLocalError`` if :func:`~django.contrib.auth.get_user_model`
  87. raised an error (#21439).
  88. Additionally, Django's vendored version of six, ``django.utils.six``,
  89. has been upgraded to the latest release (1.6.1).