Skip to content

gh-148954: sanitize methodname in xmlrpc.client.dumps() to prevent XML injection#148968

Open
sanyamk23 wants to merge 6 commits intopython:mainfrom
sanyamk23:fix-xmlrpc-methodname-sanitization
Open

gh-148954: sanitize methodname in xmlrpc.client.dumps() to prevent XML injection#148968
sanyamk23 wants to merge 6 commits intopython:mainfrom
sanyamk23:fix-xmlrpc-methodname-sanitization

Conversation

@sanyamk23
Copy link
Copy Markdown

Summary

This PR fixes an XML injection vulnerability in xmlrpc.client.dumps() where the methodname was interpolated directly into the <methodName> tag without escaping.

Details

The methodname is now passed through the module's escape() helper function before being added to the XML request body. This prevents attackers from injecting arbitrary XML markup if they can control the method name.

Verification

  • Confirmed that a payload like 'foo</methodName><injected attr="evil"/><methodName>bar' is correctly escaped as 'foo&lt;/methodName&gt;&lt;injected attr="evil"/&gt;&lt;methodName&gt;bar'.
  • Verified that standard method names (alpha-numeric) continue to work without modification.
  • Verified that special characters in method names are correctly recovered when unmarshalled.

Fixes gh-148954

@python-cla-bot
Copy link
Copy Markdown

python-cla-bot Bot commented Apr 24, 2026

The following commit authors need to sign the Contributor License Agreement:

CLA not signed

@sanyamk23 sanyamk23 force-pushed the fix-xmlrpc-methodname-sanitization branch from 4c5e015 to 4e67dfd Compare April 24, 2026 17:25
Copy link
Copy Markdown
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

@bedevere-app
Copy link
Copy Markdown

bedevere-app Bot commented Apr 24, 2026

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Comment thread Lib/test/test_xmlrpc.py Outdated
Comment thread Lib/test/test_xmlrpc.py Outdated
Copy link
Copy Markdown
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

cc @sethmlarson @StanFromIreland (I think this was a GHSA right? I didn't follow the discussion so there might be more that you wanted to add).

Comment thread Misc/NEWS.d/next/Security/2026-04-24-19-54-00.gh-issue-148954.v1.rst Outdated
@StanFromIreland
Copy link
Copy Markdown
Member

FTR: this was GHSA-w5gj-44cx-wmcj.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xmlrpc.client lacks sanitization in methodname

3 participants