Ni WooCommerce Order Export <= 3.1.6 - Cross-Site Request Forgery to Settings Update via ni_order_export_action AJAX Action
Description
The Ni WooCommerce Order Export plugin for WordPress is vulnerable to Cross-Site Request Forgery in all versions up to and including 3.1.6. This is due to missing nonce validation in the ni_order_export_action() AJAX handler function. The handler processes settings updates when the 'page' parameter is set to 'nioe-order-settings', delegating to Ni_Order_Setting::page_ajax() which calls update_option('ni_order_export_option', $_REQUEST) without verifying any nonce or checking user capabilities. This makes it possible for unauthenticated attackers to modify the plugin's settings via a forged request, granted they can trick a site administrator into performing an action such as clicking a link.
CVSS Vector Breakdown
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:NTechnical Details
<=3.1.6This research plan outlines the process for exploiting a Cross-Site Request Forgery (CSRF) vulnerability in the Ni WooCommerce Order Export plugin. ## 1. Vulnerability Summary The **Ni WooCommerce Order Export** plugin (up to version 3.1.6) fails to implement nonce verification and capability check…
Show full research plan
This research plan outlines the process for exploiting a Cross-Site Request Forgery (CSRF) vulnerability in the Ni WooCommerce Order Export plugin.
1. Vulnerability Summary
The Ni WooCommerce Order Export plugin (up to version 3.1.6) fails to implement nonce verification and capability checks in its AJAX handler for the ni_order_export_action action. Specifically, when the page parameter is set to nioe-order-settings, the code delegates processing to Ni_Order_Setting::page_ajax(). This function takes the entire $_REQUEST array and saves it directly into the WordPress database using update_option('ni_order_export_option', ...).
Because there is no verification that the request was intentionally sent by an administrator, an attacker can trick a logged-in admin into submitting a request that overwrites the plugin's configuration.
2. Attack Vector Analysis
- Endpoint:
/wp-admin/admin-ajax.php - AJAX Action:
ni_order_export_action - Vulnerable Parameter:
page(must benioe-order-settings) - Payload Parameters: Any key-value pairs sent in the request (e.g., via POST or GET) will be written to the
ni_order_export_optionoption. - Authentication Level: The attacker is unauthenticated but requires an Authenticated Administrator to execute the request (via CSRF).
- Preconditions:
- The Ni WooCommerce Order Export plugin is active.
- WooCommerce is active (as it is a dependency).
3. Code Flow (Inferred from Patch/Description)
- Registration: The plugin registers the AJAX hook:
add_action('wp_ajax_ni_order_export_action', 'ni_order_export_action'); - Entry Point:
ni_order_export_action()is executed when the AJAX request is received. - Branching Logic: The function checks
$_REQUEST['page']. - Vulnerable Branch: If
$_REQUEST['page'] === 'nioe-order-settings', it callsNi_Order_Setting::page_ajax(). - The Sink: Inside
page_ajax(), the code executes:update_option('ni_order_export_option', $_REQUEST); - Failure: No
check_ajax_referer()orcurrent_user_can('manage_options')is called before theupdate_optionsink.
4. Nonce Acquisition Strategy
According to the vulnerability description, this specific AJAX handler missing nonce validation entirely. Therefore, no nonce is required to successfully exploit the vulnerability.
If a nonce were required, it would typically be found in the admin dashboard under the "Order Export" settings page, likely localized under a JS object. However, for this CVE, the strategy is to bypass the nonce check by simply omitting it or providing any value, as it is not verified in the affected versions.
5. Exploitation Strategy
The goal is to modify the plugin's export settings (e.g., the default filename for exports) to demonstrate unauthorized data modification.
Step-by-Step Plan:
- Identify Target Option Content: First, check the existing value of
ni_order_export_optionto understand the expected array structure. - Construct Payload: Create a POST request targeting
admin-ajax.php. - Simulate CSRF: Use the
http_requesttool with the Administrator's cookies to execute the state-changing request.
HTTP Request (CSRF Simulation):
- Method:
POST - URL:
http://localhost:8080/wp-admin/admin-ajax.php - Headers:
Content-Type: application/x-www-form-urlencoded
- Body:
action=ni_order_export_action&page=nioe-order-settings&ni_filename=vulnerable_poc_export&ni_common_settings[buttons]=pwned
Note: Since the plugin saves the entire $_REQUEST array, the keys used depend on what the plugin's settings form expects. The keys ni_filename or ni_common_settings are common identifiers for this plugin.
6. Test Data Setup
- Install/Activate Plugin: Ensure
ni-woocommerce-order-exportandwoocommerceare installed and active. - Initial Configuration: Navigate to the plugin settings once as an admin to ensure the default options are initialized in the database.
- Identify Admin Session: The agent should already have access to the administrator session via the environment.
7. Expected Results
- The server should return a successful response (often
0or1for WordPress AJAX, or a JSON success message). - The WordPress option
ni_order_export_optionwill be updated with the malicious values provided in the request.
8. Verification Steps
After performing the http_request, verify the change using WP-CLI:
# Check the value of the affected option
wp option get ni_order_export_option --format=json
Successful Exploit Criteria:
- The output contains
"ni_filename": "vulnerable_poc_export". - The output contains the
actionandpagekeys (side effect of the plugin saving the entire$_REQUESTarray).
9. Alternative Approaches
If the plugin performs basic validation on the array structure:
- Form Extraction: Use
browser_navigateto the plugin's settings page and usebrowser_evalto extract the exact names of the input fields:browser_eval("Array.from(document.querySelectorAll('input[name]')).map(i => i.name)") - Refined Payload: Re-run the
http_requestusing the exact keys found in the real settings form to ensure theupdate_optioncall doesn't fail due to data type mismatches.
Summary
The Ni WooCommerce Order Export plugin for WordPress is vulnerable to Cross-Site Request Forgery (CSRF) in versions up to and including 3.1.6. The plugin fails to implement nonce validation and capability checks in its 'ni_order_export_action' AJAX handler, specifically when processing settings updates. This allows an attacker to overwrite the plugin's configuration options by tricking a logged-in administrator into clicking a link or visiting a malicious page.
Vulnerable Code
// File: ni-woocommerce-order-export.php add_action('wp_ajax_ni_order_export_action', 'ni_order_export_action'); function ni_order_export_action() { if (isset($_REQUEST['page']) && $_REQUEST['page'] === 'nioe-order-settings') { Ni_Order_Setting::page_ajax(); } } --- // File: includes/class-ni-order-setting.php class Ni_Order_Setting { public static function page_ajax() { // Vulnerable: No nonce check or capability check before updating options update_option('ni_order_export_option', $_REQUEST); wp_die(); } }
Security Fix
@@ -1,5 +1,8 @@ public static function page_ajax() { + if ( ! current_user_can( 'manage_options' ) ) { + wp_die( -1 ); + } + check_ajax_referer( 'ni_order_export_nonce', 'security' ); update_option('ni_order_export_option', $_REQUEST); wp_die(); }
Exploit Outline
The attacker targets the 'ni_order_export_action' AJAX action via the /wp-admin/admin-ajax.php endpoint. By setting the 'page' parameter to 'nioe-order-settings', the plugin delegates the request to a function that saves the entire contents of $_REQUEST into the 'ni_order_export_option' database option. An attacker can craft a payload containing arbitrary configuration values (e.g., 'ni_filename=pwned') and trick an authenticated administrator into submitting it using a CSRF attack (such as a hidden auto-submitting HTML form on a malicious website), resulting in unauthorized modification of the plugin's export settings.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.