Debian Codegraph @

docs/releases/1.5.6.txt

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