diff options
author | Miss Skeleton (bot) <31488909+miss-islington@users.noreply.github.com> | 2020-10-20 04:38:30 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-20 04:38:30 (GMT) |
commit | a158fb9c5138db94adf24fbc5690467cda811163 (patch) | |
tree | eb519c962b5f50a0600e4db9150d8db94595b437 /Lib/plistlib.py | |
parent | a69002ce6cbf32eb63a6c30deea41fe204015db7 (diff) | |
download | cpython-a158fb9c5138db94adf24fbc5690467cda811163.zip cpython-a158fb9c5138db94adf24fbc5690467cda811163.tar.gz cpython-a158fb9c5138db94adf24fbc5690467cda811163.tar.bz2 |
bpo-42051: Reject XML entity declarations in plist files (GH-22760) (GH-22801) (GH-22804)
Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com>
(cherry picked from commit e512bc799e3864fe3b1351757261762d63471efc)
Co-authored-by: Ned Deily <nad@python.org>
Diffstat (limited to 'Lib/plistlib.py')
-rw-r--r-- | Lib/plistlib.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/plistlib.py b/Lib/plistlib.py index a918643..6e030f2 100644 --- a/Lib/plistlib.py +++ b/Lib/plistlib.py @@ -322,9 +322,16 @@ class _PlistParser: self.parser.StartElementHandler = self.handle_begin_element self.parser.EndElementHandler = self.handle_end_element self.parser.CharacterDataHandler = self.handle_data + self.parser.EntityDeclHandler = self.handle_entity_decl self.parser.ParseFile(fileobj) return self.root + def handle_entity_decl(self, entity_name, is_parameter_entity, value, base, system_id, public_id, notation_name): + # Reject plist files with entity declarations to avoid XML vulnerabilies in expat. + # Regular plist files don't contain those declerations, and Apple's plutil tool does not + # accept them either. + raise InvalidFileException("XML entity declarations are not supported in plist files") + def handle_begin_element(self, element, attrs): self.data = [] handler = getattr(self, "begin_" + element, None) |