#32578: Handle request.get_host() raising DisallowedHost in
CsrfViewMiddleware._origin_verified()
-------------------------------------+-------------------------------------
Reporter: Chris Jerdonek | Owner: nobody
Type: Bug | Status: new
Component: CSRF | Version: dev
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
CsrfViewMiddleware,DisallowedHost |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Mariusz Felisiak):
Replying to [comment:4 Chris Jerdonek]:
> Thanks, Mariusz. However, do you know for sure that's testing the right
code path? `_origin_verified()` only gets called when `if request.method
not in ('GET', 'HEAD', 'OPTIONS', 'TRACE')`, but the test appears to be
`GET`. I could be wrong though since my observation is based on inspection
rather than running the test.
Test crashes because `method` is not set in this case. I updated attached
test to use the `POST` method.
----
Replying to [comment:2 Tim Graham]:
> It might be better to perform host validation elsewhere in Django as
suggested in #27575 so that DisallowedHost doesn't need to be caught
everywhere.
This can be tricky, so I'd fix this case independently and discuss the
options in #27575.
--
Ticket URL: <https://code.djangoproject.com/ticket/32578#comment:5>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.a01f7ae061eb61c5cdd6e25bfbee82c4%40djangoproject.com.