Skip to content
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

[Uncaught exception] UnicodeDecodeError when calling decode with arbitrary data #108

Closed
pventuzelo opened this issue Oct 1, 2021 · 1 comment

Comments

@pventuzelo
Copy link

Hey,

I was doing some fuzzing and I found out that the idna.decode() method can raise a UnicodeDecodeError leading to a crash of the running program.

This could be problematic if users of the library are dealing with untrusted data since this issue will lead to a DoS. This should be detected and an idna.IDNAError should be triggered as detailed in the Readme Exception section.

Reproduction

import idna

idna.decode(b'\x8d\xd2')

Traceback

python3 replay_crash.py
Traceback (most recent call last):
  File "replay_crash.py", line 3, in <module>
    idna.decode(b'\x8d\xd2')
  File "/home/scop/.local/lib/python3.8/site-packages/idna/core.py", line 387, in decode
    s = s.decode('ascii')
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8d in position 0: ordinal not in range(128)

Happy to help if you have any questions ;)

@kjd
Copy link
Owner

kjd commented Oct 1, 2021

Thanks, will develop a patch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants