summaryrefslogtreecommitdiffstats
path: root/Lib/plistlib.py
diff options
context:
space:
mode:
authorRonald Oussoren <ronaldoussoren@mac.com>2020-10-19 18:13:49 (GMT)
committerGitHub <noreply@github.com>2020-10-19 18:13:49 (GMT)
commit05ee790f4d1cd8725a90b54268fc1dfe5b4d1fa2 (patch)
tree58e7bd477ec641a442c50424f6a5acc7d792957c /Lib/plistlib.py
parent985f0ab3ad5e8e9a8d7fc53026c38390b1f2b466 (diff)
downloadcpython-05ee790f4d1cd8725a90b54268fc1dfe5b4d1fa2.zip
cpython-05ee790f4d1cd8725a90b54268fc1dfe5b4d1fa2.tar.gz
cpython-05ee790f4d1cd8725a90b54268fc1dfe5b4d1fa2.tar.bz2
bpo-42051: Reject XML entity declarations in plist files (#22760)
Diffstat (limited to 'Lib/plistlib.py')
-rw-r--r--Lib/plistlib.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/plistlib.py b/Lib/plistlib.py
index aff5fe3..ba7ac19 100644
--- a/Lib/plistlib.py
+++ b/Lib/plistlib.py
@@ -173,9 +173,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)