vinitkumar/json2xml

[Uncaught exception] UnicodeDecodeError when calling to_xml with arbitrary data

Asteriska001 opened this issue · 7 comments

Describe the bug
I found out that theJson2xml(data).to_xml() 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 execption should be triggered

To Reproduce
Steps to reproduce the behavior:
image

Expected behavior
This execption should be expected.

@Asteriska8 Thanks for raising this issue and the explanation, it would be much more helpful if you could please just paste the input data in here so that it is easier to test it. The screenshot while informative doesn't help much in using that in the code.

data = (b'!\0a\8f').decode('utf-8')

@Asteriska8 Fixed it just now. #107

Please check this pull request and possibly run this, and let me know if it looks good to you?

Thanks!
I has validated this fix.

@Asteriska8 Awesome, I will merge and release later this evening.

Thanks to your nice work and the contribution to open-source community!

@Asteriska8 Thanks for your report.

Happy to announce that the fix is released to pypi here:

pip install json2xml==3.14.0

You are welcome to upgrade to this and your issues should be resolved. I will be closing this issue. Please don't hesitate to open a new issue if you find any other problems.