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

bpo-42103: Improve validation of Plist files. #22882

Merged

Conversation

serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Oct 22, 2020

Prevent some possible DoS attacks via providing invalid Plist files
with extremally large number of objects or collection sizes.

https://bugs.python.org/issue42103

Prevent some possible DoS attacks via providing invalid Plist files
with extremally large number of objects or collection sizes.
Copy link
Contributor

@ronaldoussoren ronaldoussoren left a comment

LGTM

@serhiy-storchaka serhiy-storchaka marked this pull request as ready for review Oct 23, 2020
@serhiy-storchaka
Copy link
Member Author

@serhiy-storchaka serhiy-storchaka commented Oct 23, 2020

Please make review of new changes.

  • Added NEWS entries.
  • Added more tests.
  • Raise InvalidFileException for too large bytes and string size instead of returning garbage.
  • Raise InvalidFileException instead of ValueError for specific invalid datetime (NaN).
  • Raise InvalidFileException instead of TypeError for non-hashable dict keys.

Not all errors in Plist file are checked, loading broken Plist file can produce a garbage. But if an error is detected you get InvalidFileException instead of ValueError, IndexError, etc. Of course you can still get MemoryError (if read too large file) or RecursionError.

@serhiy-storchaka
Copy link
Member Author

@serhiy-storchaka serhiy-storchaka commented Nov 2, 2020

@ronaldoussoren, please take a look again.

Copy link
Contributor

@ronaldoussoren ronaldoussoren left a comment

LGTM.

@serhiy-storchaka serhiy-storchaka merged commit 34637a0 into python:master Nov 2, 2020
10 checks passed
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Nov 2, 2020

Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7, 3.8, 3.9.
🐍🍒🤖

@serhiy-storchaka serhiy-storchaka deleted the plistlib-dos-too-large-size branch Nov 2, 2020
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Nov 2, 2020

GH-23115 is a backport of this pull request to the 3.9 branch.

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Nov 2, 2020

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.8 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 34637a0ce21e7261b952fbd9d006474cc29b681f 3.8

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Nov 2, 2020
* Prevent some possible DoS attacks via providing invalid Plist files
  with extremely large number of objects or collection sizes.
* Raise InvalidFileException for too large bytes and string size instead of returning garbage.
* Raise InvalidFileException instead of ValueError for specific invalid datetime (NaN).
* Raise InvalidFileException instead of TypeError for non-hashable dict keys.
* Add more tests for invalid Plist files.
(cherry picked from commit 34637a0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Nov 2, 2020

Sorry @serhiy-storchaka, I had trouble checking out the 3.7 backport branch.
Please backport using cherry_picker on command line.
cherry_picker 34637a0ce21e7261b952fbd9d006474cc29b681f 3.7

@miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Nov 2, 2020

Sorry, @serhiy-storchaka, I could not cleanly backport this to 3.6 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 34637a0ce21e7261b952fbd9d006474cc29b681f 3.6

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Nov 2, 2020

GH-23116 is a backport of this pull request to the 3.8 branch.

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Nov 2, 2020
* Prevent some possible DoS attacks via providing invalid Plist files
  with extremely large number of objects or collection sizes.
* Raise InvalidFileException for too large bytes and string size instead of returning garbage.
* Raise InvalidFileException instead of ValueError for specific invalid datetime (NaN).
* Raise InvalidFileException instead of TypeError for non-hashable dict keys.
* Add more tests for invalid Plist files..
(cherry picked from commit 34637a0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Nov 2, 2020
* Prevent some possible DoS attacks via providing invalid Plist files
  with extremely large number of objects or collection sizes.
* Raise InvalidFileException for too large bytes and string size instead of returning garbage.
* Raise InvalidFileException instead of ValueError for specific invalid datetime (NaN).
* Raise InvalidFileException instead of TypeError for non-hashable dict keys.
* Add more tests for invalid Plist files..
(cherry picked from commit 34637a0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Nov 2, 2020

GH-23117 is a backport of this pull request to the 3.7 branch.

miss-islington added a commit that referenced this issue Nov 2, 2020
* Prevent some possible DoS attacks via providing invalid Plist files
  with extremely large number of objects or collection sizes.
* Raise InvalidFileException for too large bytes and string size instead of returning garbage.
* Raise InvalidFileException instead of ValueError for specific invalid datetime (NaN).
* Raise InvalidFileException instead of TypeError for non-hashable dict keys.
* Add more tests for invalid Plist files.
(cherry picked from commit 34637a0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Nov 2, 2020

GH-23118 is a backport of this pull request to the 3.6 branch.

serhiy-storchaka added a commit to serhiy-storchaka/cpython that referenced this issue Nov 2, 2020
* Prevent some possible DoS attacks via providing invalid Plist files
  with extremely large number of objects or collection sizes.
* Raise InvalidFileException for too large bytes and string size instead of returning garbage.
* Raise InvalidFileException instead of ValueError for specific invalid datetime (NaN).
* Raise InvalidFileException instead of TypeError for non-hashable dict keys.
* Add more tests for invalid Plist files..
(cherry picked from commit 34637a0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
serhiy-storchaka added a commit that referenced this issue Nov 3, 2020
)

* Prevent some possible DoS attacks via providing invalid Plist files
  with extremely large number of objects or collection sizes.
* Raise InvalidFileException for too large bytes and string size instead of returning garbage.
* Raise InvalidFileException instead of ValueError for specific invalid datetime (NaN).
* Raise InvalidFileException instead of TypeError for non-hashable dict keys.
* Add more tests for invalid Plist files.

(cherry picked from commit 34637a0)
ned-deily pushed a commit that referenced this issue Nov 10, 2020
* Prevent some possible DoS attacks via providing invalid Plist files
  with extremely large number of objects or collection sizes.
* Raise InvalidFileException for too large bytes and string size instead of returning garbage.
* Raise InvalidFileException instead of ValueError for specific invalid datetime (NaN).
* Raise InvalidFileException instead of TypeError for non-hashable dict keys.
* Add more tests for invalid Plist files..
(cherry picked from commit 34637a0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
ned-deily pushed a commit that referenced this issue Nov 10, 2020
)

* Prevent some possible DoS attacks via providing invalid Plist files
  with extremely large number of objects or collection sizes.
* Raise InvalidFileException for too large bytes and string size instead of returning garbage.
* Raise InvalidFileException instead of ValueError for specific invalid datetime (NaN).
* Raise InvalidFileException instead of TypeError for non-hashable dict keys.
* Add more tests for invalid Plist files..
(cherry picked from commit 34637a0)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@serhiy-storchaka serhiy-storchaka removed their assignment Dec 29, 2020
adorilson pushed a commit to adorilson/cpython that referenced this issue Mar 13, 2021
* Prevent some possible DoS attacks via providing invalid Plist files
  with extremely large number of objects or collection sizes.
* Raise InvalidFileException for too large bytes and string size instead of returning garbage.
* Raise InvalidFileException instead of ValueError for specific invalid datetime (NaN).
* Raise InvalidFileException instead of TypeError for non-hashable dict keys.
* Add more tests for invalid Plist files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA signed type-bug type-security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants