mirror of
https://github.com/python/cpython.git
synced 2026-06-10 11:52:01 +00:00
gh-148954: Escape methodname in xmlrpc.client.dumps() to prevent XML injection (GH-148968)
This commit is contained in:
parent
69851a6407
commit
ab930175e7
3 changed files with 13 additions and 1 deletions
|
|
@ -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</methodName><injected attr="evil"/>'
|
||||
'<methodName>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))
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Fix XML injection vulnerability in :func:`xmlrpc.client.dumps` where the ``methodname`` was not being escaped before interpolation into the XML body.
|
||||
Loading…
Add table
Add a link
Reference in a new issue