Opened 7 weeks ago
Last modified 4 weeks ago
#65124 new defect (bug)
Please include additional data validation in class-IXR-server.php
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | 4.7 |
| Component: | General | Keywords: | has-patch has-unit-tests |
| Focuses: | php-compatibility | Cc: |
Description
Line 95 of /wp-includes/IXR/class-IXR-server.php is causing a fatal error, because malicious traffic is posting non-countable $args.
Attachments (1)
Change History (7)
#3
@
6 weeks ago
- Keywords has-patch added; needs-patch removed
Adds validation for malformed XML-RPC arguments before count() is called in IXR_Server, preventing fatal errors when non-countable values are received from invalid requests.
This ticket was mentioned in PR #11842 on WordPress/wordpress-develop by @tommusrhodus.
4 weeks ago
#4
- Keywords has-unit-tests added
*AI Description*: Validates the per-call structure inside IXR_Server::multiCall() and returns a spec-compliant fault (-32602) for malformed entries, rather than passing non-array values to IXR_Server::call() where count() would TypeError on PHP 8+. Also adds a defensive guard inside call() mirroring the existing pattern in IXR_IntrospectionServer::call().
*Human Discussion*:
- Solves a 500 error being thrown in
wp-includes/IXR/class-IXR-server.php, likely by malicious traffic. - Expands upon the existing patch in 65124 to avoid creating issues downstream by simply checking
$argsis an array.
Tested locally by creating an XML file with the following content:
<?xml version="1.0"?> <methodCall> <methodName>system.multicall</methodName> <params> <param><value><array><data> <value><struct> <member><name>methodName</name><value><string>system.listMethods</string></value></member> <member><name>params</name><value><string>malicious-non-array</string></value></member> </struct></value> </data></array></value></param> </params> </methodCall>
and then posting that to the local server:
curl -sS -X POST -H 'Content-Type: text/xml' \
--data-binary @repro-ixr-multicall.xml \
http://localhost:8889/xmlrpc.php -o /tmp/resp.xml -w '%{http_code}\n'
The return before this patch:
500
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><int>500</int></value>
</member>
<member>
<name>faultString</name>
<value><string><p>There has been a critical error on this website.</p><p><a href="https://wordpress.org/documentation/article/faq-troubleshooting/">Learn more about troubleshooting WordPress.</a></p></string></value>
</member>
</struct>
</value>
</fault>
</methodResponse>
The return after this patch:
200
<?xml version="1.0" encoding="UTF-8"?>
<methodResponse>
<params>
<param>
<value>
<array><data>
<value><struct>
<member><name>faultCode</name><value><int>-32602</int></value></member>
<member><name>faultString</name><value><string>server error. invalid method call structure</string></value></member>
</struct></value>
</data></array>
</value>
</param>
</params>
</methodResponse>
Trac ticket: https://core.trac.wordpress.org/ticket/65124
## Use of AI Tools
AI assistance: Yes
Tool(s): Claude
Model(s): Opus 4.7
Used for: Initial investigation route and test suggestions; final implementation and tests were reviewed and edited by me.
@tommusrhodus commented on PR #11842:
4 weeks ago
#5
Unit test failures seem unrelated and belong to different testing groups.
@tommusrhodus commented on PR #11842:
4 weeks ago
#6
Unit test failures seem unrelated and belong to different testing groups.
Here's the error message, just to help people find this ticket:
[23-Apr-2026 14:53:07 UTC] PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in ROOT/wp-includes/IXR/class-IXR-server.php:95 Stack trace: #0 ROOT/wp-includes/IXR/class-IXR-server.php(207): IXR_Server->call() #1 ROOT/wp-includes/IXR/class-IXR-server.php(109): IXR_Server->multiCall() #2 ROOT/wp-includes/IXR/class-IXR-server.php(59): IXR_Server->call() #3 ROOT/wp-includes/IXR/class-IXR-server.php(27): IXR_Server->serve() #4 ROOT/wp-includes/IXR/class-IXR-server.php(35): IXR_Server->__construct() #5 ROOT/wp-includes/class-wp-xmlrpc-server.php(246): IXR_Server->IXR_Server() #6 ROOT/xmlrpc.php(85): wp_xmlrpc_server->serve_request() #7 {main} thrown in ROOT/wp-includes/IXR/class-IXR-server.php on line 95Also, when
$argsisn't as expected, it will be good to provide some context information to help troubleshoot and protect the site.