WordPress Design Flaw Leads to WooCommerce RCE
A shop manager account in WooCommerce could delete the plugin's main file, which disabled WooCommerce and with it the meta capability check that stopped shop managers editing administrators. The shop manager could then reset an administrator's password and take over the site, and from there run PHP code on the server.
Published on sonarsource.com
A flaw in the way WordPress handles privileges can lead to a privilege escalation in WordPress plugins. This affects for example WooCommerce, the most popular e-commerce plugin with over 4 million installations.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the role and its broad edit_users capability are stored in the database and outlive the plugin, while the meta capability filter that restricts shop managers to editing customers only runs while the plugin is active.
Impact
A shop manager could take over any administrator account and then execute code on the server; the file deletion itself was fixed in WooCommerce 3.4.6, but the underlying WordPress design flaw was still unpatched at the time of writing.
What the attacker needed
Control of a shop manager account; WooCommerce installed and active; plugin files writable by the web server
The fix
WooCommerce 3.4.6 fixed the file deletion, but the text says the WordPress privilege design flaw itself was not fixed, so the role model should be changed so a stored role cannot grant broad capabilities once its plugin is inactive.
How it was found
- Log in as a shop manager and open the WooCommerce logging feature.
- Submit a crafted log filename as a GET parameter so the path escapes the log directory.
- The server deletes the plugin's main file, so WordPress can no longer load WooCommerce and disables it.
- With the plugin inactive, edit the administrator account and change its password.
- Log in as the administrator and install a plugin or edit theme files to run PHP code.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
WordPress gives each user a role, and each role has permissions called capabilities. WooCommerce gave the shop manager role a broad permission to edit users, then relied on its own plugin code to narrow that down to customers only. When the plugin was switched off, that narrowing code stopped running, so the broad permission applied to everyone, including administrators.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.