Re: [Django] #28699: Document middleware ordering requirements following CSRF change in Django 1.11.6

2019-09-03 Thread Django
#28699: Document middleware ordering requirements following CSRF change in 
Django
1.11.6
---+
 Reporter:  stephanm   |Owner:  Rodrigo
 Type:  Bug|   Status:  assigned
Component:  Documentation  |  Version:  1.11
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Accepted
Has patch:  1  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  1
Easy pickings:  0  |UI/UX:  0
---+

Comment (by Carlton Gibson):

 Right, some time later...

 I think that prior to c4c128d67c7dc2830631c6859a204c9d259f1fb1 (for
 #28488) there was actually a security issue in the way
 `CsrfViewMiddleware` worked.
 It would call `_get_token()` in `process_view()`, resetting the CSRF token
 to the one submitted in the request, even though `rotate_token()` had
 previously been
 called during `login()` by the `RemoteUserMiddleware`.

 This is equivalent to the `CsrfViewMiddleware` second case discussed
 above. It allows the Login + CSRF check in the single request but is not
 safe.
 As such, that the behaviour changed slightly cannot be considered a
 regression. (It should never have worked.)

 **Possibly** `RemoteUserMiddleware` could be adjusted to defer rotating
 the CSRF token (until say `process_response()`), but anything in that
 ball-park is highly sensitive, and probably not worth the price of
 admission.

 For this ticket I think documenting that remote user auth will require two
 requests — one to login, on to submit further data passing CSRF — is the
 best we can do.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.cb7640a5f539d7b1a8cb33cd1ba1830e%40djangoproject.com.


Re: [Django] #28699: Document middleware ordering requirements following CSRF change in Django 1.11.6

2018-12-06 Thread Django
#28699: Document middleware ordering requirements following CSRF change in 
Django
1.11.6
---+
 Reporter:  stephanm   |Owner:  Rodrigo
 Type:  Bug|   Status:  assigned
Component:  Documentation  |  Version:  1.11
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Accepted
Has patch:  1  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  1
Easy pickings:  0  |UI/UX:  0
---+
Changes (by Carlton Gibson):

 * needs_better_patch:  0 => 1


Comment:

 Okay. Thank you for following up Florian. I will dig dipper given your
 confirmation of my first reading.

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.16e6e94e28de3003d8dc4029bc61d443%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28699: Document middleware ordering requirements following CSRF change in Django 1.11.6

2018-12-06 Thread Django
#28699: Document middleware ordering requirements following CSRF change in 
Django
1.11.6
---+
 Reporter:  stephanm   |Owner:  Rodrigo
 Type:  Bug|   Status:  assigned
Component:  Documentation  |  Version:  1.11
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Accepted
Has patch:  1  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+

Comment (by Florian Apolloner):

 Replying to [comment:16 Carlton Gibson]:
 > Unless I missed something, this is **negating the `rotate_token()`
 call**. Is that correct, or have I misread it? Given the docstring in
 `rotate_token()` isn't this a no-no? If so, we can't recommend this.

 Yes, this seems correct

 > On the other hand, if `CsrfViewMiddleware` is first then the
 `rotate_token()` call will replace whatever `CSRF_COOKIE` was previously
 set, and so the actual CSRF check in `process_view()` will necessarily
 fail. (As we must be seeing here.)

 Also correct. I wonder if my patch in #28488 actually made the situation
 worse (speaks for the complexity of the middleware :/)

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.b2f6490fb2cddaf50b2bc8b7cbbe0e4b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28699: Document middleware ordering requirements following CSRF change in Django 1.11.6

2018-12-05 Thread Django
#28699: Document middleware ordering requirements following CSRF change in 
Django
1.11.6
---+
 Reporter:  stephanm   |Owner:  Rodrigo
 Type:  Bug|   Status:  assigned
Component:  Documentation  |  Version:  1.11
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Accepted
Has patch:  1  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+
Changes (by Carlton Gibson):

 * cc: Carlton Gibson (added)


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.34b09db5915d4e04fbd7bebf43f71028%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28699: Document middleware ordering requirements following CSRF change in Django 1.11.6

2018-12-05 Thread Django
#28699: Document middleware ordering requirements following CSRF change in 
Django
1.11.6
---+
 Reporter:  stephanm   |Owner:  Rodrigo
 Type:  Bug|   Status:  assigned
Component:  Documentation  |  Version:  1.11
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Accepted
Has patch:  1  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+

Comment (by Carlton Gibson):

 The PR here looks fine, re the discussion, but I'm missing a crucial part
 in my understanding here: I can't see how you're meant to make a
 successful CSRF check in the **same request** as a `REMOTE_USER` login...

 As I read it, if `RemoteUserMiddleware` is first then:

 * `RemoteUserMiddleware.process_request()` calls `auth.login()` which
 calls `rotate_token()`:

 {{{
 def rotate_token(request):
 """
 Change the CSRF token in use for a request - should be done on login
 for security purposes.
 """
 request.META.update({
 "CSRF_COOKIE_USED": True,
 "CSRF_COOKIE": _get_new_csrf_token(),
 })
 request.csrf_cookie_needs_reset = True
 }}}

 * But then `CsrfViewMiddleware.process_request()` calls `_get_token()`
 which fetches the **old** `CSRF_COOKIE`, from either the session or the
 cookie, and
 
[https://github.com/django/django/blob/4d60261b2a77460b4c127c3d832518b95e11a0ac/django/middleware/csrf.py#L201
 resets it on `request.META`].

 Unless I missed something, this is **negating the `rotate_token()` call**.
 Is that correct, or have I misread it? Given the docstring in
 `rotate_token()` isn't this a no-no?

 On the other hand, if `CsrfViewMiddleware` is first then the
 `rotate_token()` call will replace whatever `CSRF_COOKIE` was previously
 set, and so the actual CSRF check in `process_view()` will necessarily
 fail. (As we must be seeing here.)

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.2fdd9610d9be1de1862b67046eec3640%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28699: Document middleware ordering requirements following CSRF change in Django 1.11.6

2018-12-04 Thread Django
#28699: Document middleware ordering requirements following CSRF change in 
Django
1.11.6
---+
 Reporter:  stephanm   |Owner:  Rodrigo
 Type:  Bug|   Status:  assigned
Component:  Documentation  |  Version:  1.11
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Accepted
Has patch:  1  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+
Changes (by Rodrigo):

 * owner:  nobody => Rodrigo
 * status:  new => assigned
 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/10722 PR]

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.4fcb83b0d5deeb3a199db384ac9e4fbb%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #28699: Document middleware ordering requirements following CSRF change in Django 1.11.6 (was: Problem with CSRF in Django 1.11.6)

2017-12-01 Thread Django
#28699: Document middleware ordering requirements following CSRF change in 
Django
1.11.6
---+
 Reporter:  stephanm   |Owner:  nobody
 Type:  Bug|   Status:  new
Component:  Documentation  |  Version:  1.11
 Severity:  Normal |   Resolution:
 Keywords: | Triage Stage:  Accepted
Has patch:  0  |  Needs documentation:  0
  Needs tests:  0  |  Patch needs improvement:  0
Easy pickings:  0  |UI/UX:  0
---+
Changes (by Tim Graham):

 * component:  CSRF => Documentation
 * severity:  Release blocker => Normal


-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.7c4e6e303d895a9599ae295d4ab6a798%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.