Interactive Playground
Experiment with the vulnerable code and security rule below. Edit the code to see how the rule detects different vulnerability patterns.
pathfinder scan --ruleset python/PYTHON-LANG-SEC-092 --project .About This Rule
Understanding the vulnerability and how it is detected
Python's xmlrpc module implements the XML-RPC protocol for remote procedure calls. XML-RPC uses XML as its encoding format, and the parser used by xmlrpc.server and xmlrpc.client is vulnerable to XXE attacks when processing malicious XML-RPC payloads.
An attacker who can send XML-RPC requests to a server can craft payloads with external entity references that read local files or make network requests. On the client side, a malicious XML-RPC server can send responses with XXE payloads that read files on the client system.
defusedxml.xmlrpc monkey-patches the xmlrpc module to use safe XML parsing, preventing XXE attacks. For new implementations, REST over HTTPS is a more secure alternative to XML-RPC.
Security Implications
Potential attack scenarios if this vulnerability is exploited
Server-Side File Disclosure via XML-RPC XXE
A client sending a malicious XML-RPC request with XXE entities can cause the server to read local files (configuration files, credentials, SSH keys) and include their contents in error responses or method parameters.
SSRF via XML-RPC Client
When an XML-RPC client receives a malicious response from a compromised or malicious server, XXE entities in the response can cause the client to make HTTP requests to internal network resources or cloud metadata endpoints.
XML-RPC Server DoS via DTD
Billion Laughs attacks via XML-RPC requests can exhaust server memory and CPU resources, causing denial of service for legitimate users.
Blind XXE via XML-RPC Fault Responses
XML-RPC fault responses can contain XXE payloads. Blind XXE via out-of-band DNS or HTTP callbacks to attacker-controlled servers can exfiltrate data even when fault content is not directly returned to the attacker.
How to Fix
Recommended remediation steps
- 1Call defusedxml.xmlrpc.monkey_patch() before using any xmlrpc module to patch the XML parser to prevent XXE.
- 2For new implementations, migrate from XML-RPC to REST over HTTPS for a more secure, modern, and widely supported API protocol.
- 3Use HTTPS instead of HTTP for all XML-RPC endpoints to protect credentials and data in transit.
- 4Implement authentication and authorization on XML-RPC endpoints; the protocol itself provides no access control.
- 5Validate and restrict XML-RPC method names and parameters to an explicit allowlist to prevent exploitation of server-side methods.
Detection Scope
How Code Pathfinder analyzes your code for this vulnerability
This rule detects usage of xmlrpc.client.ServerProxy(), xmlrpc.server.SimpleXMLRPCServer(), and xmlrpc.server.MultiPathXMLRPCServer() without prior application of defusedxml.xmlrpc.monkey_patch(). All xmlrpc usage is flagged for review.
Compliance & Standards
Industry frameworks and regulations that require detection of this vulnerability
References
External resources and documentation
Similar Rules
Explore related security rules for Python
Insecure XML Parsing (XXE Vulnerability)
xml.etree.ElementTree is vulnerable to XML External Entity (XXE) attacks. Use defusedxml for safe XML parsing.
Insecure xml.dom.minidom Usage (XXE)
xml.dom.minidom is vulnerable to XML External Entity (XXE) attacks. Use defusedxml.minidom for safe XML parsing.
Frequently Asked Questions
Common questions about Insecure xmlrpc Usage (XXE Risk)
New feature
Get these findings posted directly on your GitHub pull requests
The Insecure xmlrpc Usage (XXE Risk) rule runs in CI and posts inline review comments on the exact lines — no dashboard, no SARIF viewer.