#27470: CSRF context processor never sets NOTPROVIDED
-----------------------------------------+------------------------
               Reporter:  Nick Sandford  |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  CSRF           |        Version:  1.10
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  1
                  UI/UX:  0              |
-----------------------------------------+------------------------
 The CSRF context processor expects `get_token` to return None when
 CSRF_COOKIE is not in `request.META`. When this happens, it sets
 `context['csrf_token']` to a sentinel value of NOTPROVIDED instead of
 generating a new token.

 This is a regression from 1.8.

 1.8:
 
https://github.com/django/django/blob/stable/1.8.x/django/middleware/csrf.py#L51
 1.10:
 
https://github.com/django/django/blob/stable/1.10.x/django/middleware/csrf.py#L94

 This is a problem if the 404 handler is called from a URL that doesn't
 exist. Since a view wasn't found, the CSRF middleware was never run and
 any existing token won't be set on `request.META`. The new token will be
 set by `get_token` and returned to the user, replacing the existing token.
 If, say, a javascript bug or a different tab is causing the 404 handler to
 be run after a page with a form is loaded, that form will no longer be
 submittable.

 Do we fix this, or remove the check for `None` in the context processor?

--
Ticket URL: <https://code.djangoproject.com/ticket/27470>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.44b96618a104415acca91df5ab079d3b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to