1.4.11.txt 4.8 KB

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