Skip to content

ValueError from oauthlib when validating querystrings is raised as 500 instead of 400 HTTP error #954

@duck-nukem

Description

@duck-nukem

Describe the bug
When passing in invalid hex encoding in the querystring (for example %%2A), a ValueError is raised in https://github.com/oauthlib/oauthlib/blob/b69fa53fd836dc559aa7fcd78ce075bcbe361629/oauthlib/common.py#L395 and the Django application will return 500 HTTP error code.

To Reproduce

  1. Have an endpoint that accepts the token in a querystring
  2. Send an invalid querystring (in our example it was an extra % - not converted to %25) just before a hex value.

Examples:
/endpoint/?evae%%7B7%2A191%7Daith=
/endpoint/?beiy%%%%%%%%3moh=

Expected behavior
I think a 400 status would be more appropriate, it's the client that's sending invalid data.

Version
1.5.0

  • I have tested with the latest published release and it's still a problem.
  • I have tested with the master branch and it's still a problem.

Additional context

  1. First I'd like to ask some help in triaging this issue - is it best fixed in django-oauth-toolkit, or would it be better to be fixed in oauthlib?
  2. More than happy to contribute to the issue with a PR

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions