-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Invalid Unicode byte in Authorization token raises an DjangoUnicodeDecodeError #2928
Comments
Does this happen if the extra bytes are encoded ahead of time? And is that character allowed in the |
@kevin-brown even though we should gracefully return the issue. |
@osantana do you have a test case for this issue or was it discovered on a running server ? |
I've a testcase but it's an application that we're developing/deploying privately for a company, so, we did not have a public API to provide. But I can reproduce this issue and send you more information about it. The stacktrace provided is the full stacktrace and we don't use any custom Authentication method. # settings.py
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
'apps.core.permissions.ModelPermission',
),
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
),
'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend',)
} |
@osantana I gave it a try to reproduce the issue but so far I've not been able to do it within a testcase. |
If we can't replicate this, there's no way we'll be able to progress the issue. |
Sorry, I forgot to mention a very important thing: this project runs with Python 3.4 (and this exception raises only in Py3). Besides that I've forked DRF-tutorial project and created a test to reproduce this issue: https://github.com/osantana/rest-framework-tutorial/blob/master/snippets/tests.py You can just clone this repository, install requirements and run |
@osantana will give it a try tonight and reopen if I can reproduce it. Thanks for the details. |
News about this issue? |
@osantana at the moment no. I unsuccessfully tried to reproduce it. |
Even with the tests that I created for rest-framework-tutorial? Have you tried with Python 3.4? This is a Py3-related issue... |
Sorry, I missed that part and didn't have the to test against your test case yet. |
@osantana here's the result on my box:
|
What OS are you using and what are your locals ? |
I'm using Ubuntu 14.04 and locale(?) is set with en_US.UTF-8 but I've other language packs installed and generated. Edited: I'm using 14.04! :) |
But I can try to reproduce this issue on other environment... (I've a Mac OS X 10.10 to make tests) |
@osantana I'm not saying this issue doesn't exist or is void. I'm simply pointing out that it doesn't look like a simple py3 related issue - at least not an obvious one at all. |
Ok, I understand this... What I'm trying to do is to know if you managed to reproduce the issue or if I need provide more information to help you :) It's don't even know if it's a "big issue" but I believe that people can use it to generate a DoS attack in affected APIs... |
@osantana At this point I think there might be more involved that needs to be looked at. If you can replicate the test within the DRF repository and create a (failing) pull request, that might be better than trying to reproduce it outside of the repository. |
I don't know if it's the right fix but I submitted the PR #3006 with test and fix. |
When we sent an invalid/unicode byte in token authentication we got a
500 Internal Server Error
(DjangoUnicodeDecodeError
) instead of a401 Unauthorized
:Raises the following traceback:
The text was updated successfully, but these errors were encountered: