Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Lib/test/test_xmlrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,17 @@ def test_dump_encoding(self):
self.assertEqual(xmlrpclib.loads(strg)[0][0], value)
self.assertEqual(xmlrpclib.loads(strg)[1], methodname)

def test_dump_escape_methodname(self):
payload = 'foo</methodName><injected attr="evil"/><methodName>bar'
s = xmlrpclib.dumps((), methodname=payload)
self.assertIn(
'<methodName>foo&lt;/methodName&gt;&lt;injected attr="evil"/&gt;'
'&lt;methodName&gt;bar</methodName>', s
)
self.assertNotIn('<injected attr="evil"/>', s)
load, m = xmlrpclib.loads(s)
self.assertEqual(m, payload)

def test_dump_bytes(self):
sample = b"my dog has fleas"
self.assertEqual(sample, xmlrpclib.Binary(sample))
Expand Down
2 changes: 1 addition & 1 deletion Lib/xmlrpc/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,7 @@ def dumps(params, methodname=None, methodresponse=None, encoding=None,
data = (
xmlheader,
"<methodCall>\n"
"<methodName>", methodname, "</methodName>\n",
"<methodName>", escape(methodname), "</methodName>\n",
data,
"</methodCall>\n"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix XML injection vulnerability in :func:`xmlrpc.client.dumps` where the ``methodname``
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@StanFromIreland Was it expected to be fixed as a regular bugfix or security issue? in the former case, please move the NEWS entry to "Library" (the esasiest way to do it is simply to remove that file and re-create one from scratch).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was expected to be treated as a regular bugfix, please do move it to "library," otherwise it is misleading and contradicts the security warning.

was not being escaped before interpolation into the XML body.
Loading