A Dropdown Value Is Still User Input: SQL Injection in WooCommerc
The sort_direction parameter in the Advanced Order Export For WooCommerce plugin was not validated against a whitelist, allowing an authenticated Shop Manager to inject SQL into an ORDER BY clause. An attacker could use time-based blind injection to read any table in the WordPress database, including admin password hashes, secret keys, and session tokens.
Published on medium.com
WooCommerce powers over 6 million online stores. Advanced Order Export For WooCommerce (installed on 100,000 to 500,000 of them) is the de facto plugin for exporting order data to CSV, Excel, and PDF.
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
The sort_direction parameter was only checked for emptiness and then concatenated directly into an ORDER BY clause without whitelisting, unlike the adjacent sort parameter which was properly validated.
Impact
An authenticated Shop Manager could read any table in the WordPress database, including admin password hashes, secret keys, and active session tokens, leading to full site compromise.
What the attacker needed
Shop Manager or higher account
The fix
The vulnerability was fixed in version 4.1.0 by whitelisting the sort_direction parameter to only allow 'ASC' or 'DESC'.
How it was found
- Authenticate as a Shop Manager or higher.
- Send a request to the admin-ajax.php endpoint with the order_exporter action and a valid nonce.
- Include a JSON payload where the sort_direction value contains a SQL injection payload.
- Observe the delayed response time to confirm the injection.
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.
A plugin that exports order data let a user with a shop manager account change a hidden setting called sort direction. Because the plugin did not check what was typed there, the user could sneak extra database commands into the request. This let them read sensitive information like password hashes and secret keys from the site's database.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.