1.4.11.txt 4.7 KB

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