Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12:Update
python3.33811
CVE-2022-48565-plistlib-XML-vulns.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File CVE-2022-48565-plistlib-XML-vulns.patch of Package python3.33811
From 4d8f9e2e4461de92bd1e0c92ed433480d761670f Mon Sep 17 00:00:00 2001 From: Ned Deily <nad@python.org> Date: Mon, 19 Oct 2020 22:36:27 -0400 Subject: [PATCH] bpo-42051: Reject XML entity declarations in plist files (GH-22760) (GH-22801) Co-authored-by: Ronald Oussoren <ronaldoussoren@mac.com> (cherry picked from commit e512bc799e3864fe3b1351757261762d63471efc) Co-authored-by: Ned Deily <nad@python.org> --- Lib/plistlib.py | 7 +++ Lib/test/test_plistlib.py | 18 ++++++++++ Misc/NEWS.d/next/Security/2020-10-19-10-56-27.bpo-42051.EU_B7u.rst | 3 + 3 files changed, 28 insertions(+) create mode 100644 Misc/NEWS.d/next/Security/2020-10-19-10-56-27.bpo-42051.EU_B7u.rst --- 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) --- a/Lib/test/test_plistlib.py +++ b/Lib/test/test_plistlib.py @@ -374,6 +374,19 @@ INVALID_BINARY_PLISTS = [ ), ] +XML_PLIST_WITH_ENTITY=b'''\ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd" [ + <!ENTITY entity "replacement text"> + ]> +<plist version="1.0"> + <dict> + <key>A</key> + <string>&entity;</string> + </dict> +</plist> +''' + class TestPlistlib(unittest.TestCase): @@ -711,6 +724,11 @@ class TestPlistlib(unittest.TestCase): pl2 = plistlib.loads(data) self.assertEqual(dict(pl), dict(pl2)) + def test_xml_plist_with_entity_decl(self): + with self.assertRaisesRegex(plistlib.InvalidFileException, + "XML entity declarations are not supported"): + plistlib.loads(XML_PLIST_WITH_ENTITY, fmt=plistlib.FMT_XML) + class TestBinaryPlistlib(unittest.TestCase): --- /dev/null +++ b/Misc/NEWS.d/next/Security/2020-10-19-10-56-27.bpo-42051.EU_B7u.rst @@ -0,0 +1,3 @@ +The :mod:`plistlib` module no longer accepts entity declarations in XML +plist files to avoid XML vulnerabilities. This should not affect users as +entity declarations are not used in regular plist files.
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor