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

[Crash] Unhandled UnicodeDecodeError exception while parsing an arbitrary date lead to DoS #1358

Open
pventuzelo opened this issue Apr 6, 2024 · 0 comments

Comments

@pventuzelo
Copy link

The crash occurs when the parser (via the parse function) tries to decode an arbitrary user input without sanitizing it first. The library then crashes due to an unhandled UnicodeDecodeError error for invalid utf-8 value.

PoC

// PoC.py
from dateutil.parser import parse

parse(b'\x00\xb2')

Crash

Traceback (most recent call last):
  File "poc_UnicodeDecodeError.py", line 3, in <module>
    parse(b'\x00\xb2')
  File "/home/scop/.local/lib/python3.8/site-packages/dateutil/parser/_parser.py", line 1368, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
  File "/home/scop/.local/lib/python3.8/site-packages/dateutil/parser/_parser.py", line 640, in parse
    res, skipped_tokens = self._parse(timestr, **kwargs)
  File "/home/scop/.local/lib/python3.8/site-packages/dateutil/parser/_parser.py", line 719, in _parse
    l = _timelex.split(timestr)         # Splits the timestr into tokens
  File "/home/scop/.local/lib/python3.8/site-packages/dateutil/parser/_parser.py", line 201, in split
    return list(cls(s))
  File "/home/scop/.local/lib/python3.8/site-packages/dateutil/parser/_parser.py", line 64, in __init__
    instream = instream.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb2 in position 1: invalid start byte

Impact

This vulnerability is making Python trigger an exception and crash leading to a denial of service (DoS).
Vulnerability type: CWE-248: Uncaught Exception

(I originally reported this bug through private disclosure via huntr bug bounty platform but it was closed as informative... I don't agree, it's a major library used by a lot of projects and can impact a lot of AI/ML project as well)

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

1 participant