Friendly Functions for Welcart <= 1.2.5 - Cross-Site Request Forgery to Settings Update
Description
The Friendly Functions for Welcart plugin for WordPress is vulnerable to Cross-Site Request Forgery in all versions up to, and including, 1.2.5. This is due to missing or incorrect nonce validation on the settings page. This makes it possible for unauthenticated attackers to update plugin settings via a forged request granted they can trick a site administrator into performing an action such as clicking on 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
<=1.2.5Source Code
WordPress.org SVNThis research plan outlines the process for analyzing and exploiting a Cross-Site Request Forgery (CSRF) vulnerability in the **Friendly Functions for Welcart** plugin (versions <= 1.2.5). ### 1. Vulnerability Summary The plugin fails to implement proper nonce validation on its administrative setti…
Show full research plan
This research plan outlines the process for analyzing and exploiting a Cross-Site Request Forgery (CSRF) vulnerability in the Friendly Functions for Welcart plugin (versions <= 1.2.5).
1. Vulnerability Summary
The plugin fails to implement proper nonce validation on its administrative settings page. When an administrator saves settings, the backend handler processes the update request without verifying that the request originated from a legitimate administrative session on the site. This allows an attacker to forge a request (via a malicious link or auto-submitting form) that changes plugin settings when executed by a logged-in administrator.
2. Attack Vector Analysis
- Target Endpoint: Likely
wp-admin/admin-post.phpor the plugin settings page directly (wp-admin/admin.php?page=friendly-functions-for-welcart). - Vulnerable Action: A function hooked to
admin_initoradmin_post_{action}that callsupdate_option(). - Preconditions:
- The attacker must know the parameter names used in the settings form.
- An administrator with
manage_optionscapabilities must be logged in. - The administrator must be tricked into visiting a malicious URL or page controlled by the attacker.
- Authentication: Requires an active administrator session (leveraged via CSRF).
3. Code Flow (Inferred)
Since source files are not provided, the following trace is based on standard WordPress development patterns for settings pages:
- Entry Point: The plugin registers a settings page using
add_menu_pageoradd_options_pagewith the slugfriendly-functions-for-welcart(inferred). - Hook Registration: The plugin likely uses
add_action('admin_init', ...)oradd_action('admin_post_...', ...)to handle form submissions. - Submission Logic:
- The handler checks for a specific POST parameter (e.g.,
$_POST['submit']or a hiddenactionfield). - Vulnerability: The code proceeds to
update_option()without callingcheck_admin_referer()orwp_verify_nonce().
- The handler checks for a specific POST parameter (e.g.,
- Sink:
update_option('ffw_settings', ...)(inferred option name).
4. Nonce Acquisition Strategy
According to the vulnerability description, no nonce is validated (or it is incorrectly validated). Therefore, no nonce is required to perform the exploit.
If the agent finds that a nonce is present in the form but suspected to be "incorrectly validated" (e.g., the result of wp_verify_nonce is not checked), the agent should:
- Navigate to the settings page:
wp-admin/admin.php?page=friendly-functions-for-welcart(inferred slug). - Inspect the HTML for a hidden field named
_wpnonceor similar. - Attempt the request both with and without the found nonce to confirm the bypass.
5. Exploitation Strategy
Step 1: Discovery
Identify the exact settings page slug and the POST parameters.
- Execute
grep -r "add_menu_page" .to find the slug. - Execute
grep -r "update_option" .to find which options are modified. - Search for the form handling function to see which
$_POSTkeys it reads.
Step 2: Verification of Missing Nonce Check
Check the identified handler function for the absence of check_admin_referer or wp_verify_nonce.
Step 3: PoC Execution
Using the http_request tool, simulate an administrator's browser submitting the settings form without a nonce.
- URL:
http://localhost:8080/wp-admin/admin.php?page=friendly-functions-for-welcart(or the identifiedadmin-post.phphandler). - Method:
POST - Headers:
Content-Type: application/x-www-form-urlencoded - Body: (Example based on inferred Welcart logic)
ffw_custom_css=/*Hacked*/&ffw_save_settings=1&action=ffw_update_options
6. Test Data Setup
- Install and activate the plugin (v1.2.5).
- Ensure Welcart (the parent plugin) is also active if the plugin depends on its existence for its settings page to load.
- Verify the current state of the plugin settings using WP-CLI:
wp option get ffw_settings(or the identified option name).
7. Expected Results
- The
http_request(sent with admin cookies but no nonce) should return a302 redirect(common after saving settings) or a200 OK. - The plugin settings in the database should be updated with the attacker-supplied values.
8. Verification Steps
After the exploit attempt, verify the change via WP-CLI:
# Check if the option has been modified to the payload value
wp option get <identified_option_name>
If the option reflects the /*Hacked*/ or similar payload, the CSRF is confirmed.
9. Alternative Approaches
If the plugin uses the WordPress Settings API (register_setting, settings_fields, do_settings_sections):
- The vulnerability might exist because the developer manually handles the POST request in
admin_initbefore the Settings API's built-in nonce check runs. - Alternatively, the developer might have implemented a custom AJAX handler (
wp_ajax_save_ffw_settings) without callingcheck_ajax_referer. - If
admin_initis used, the agent should check if the code filters bycurrent_user_can('manage_options'). If it does, but lacks a nonce, it is still CSRF-vulnerable. If it lacks both, it might be an Unauthenticated Settings Update.
Grep Commands for Discovery:
# Find the settings slug
grep -rn "add_submenu_page" .
# Find where settings are saved
grep -rn "update_option" .
# Check for nonce functions
grep -rn "wp_verify_nonce" .
grep -rn "check_admin_referer" .
Summary
The Friendly Functions for Welcart plugin for WordPress is vulnerable to Cross-Site Request Forgery in versions up to 1.2.5 due to a lack of nonce validation when updating settings. This allow unauthenticated attackers to modify plugin configurations by tricking a logged-in administrator into interacting with a malicious link or form.
Vulnerable Code
/** * Inferred logic based on research plan from friendly-functions-for-welcart.php */ add_action('admin_init', 'ffw_handle_settings_save'); function ffw_handle_settings_save() { // The code checks for a POST parameter but lacks check_admin_referer() or wp_verify_nonce() if (isset($_POST['ffw_save_settings'])) { if (current_user_can('manage_options')) { $settings = $_POST['ffw_settings']; update_option('ffw_settings', $settings); } } }
Security Fix
@@ -10,6 +10,10 @@ function ffw_handle_settings_save() { if (isset($_POST['ffw_save_settings'])) { + + if (!isset($_POST['ffw_nonce']) || !wp_verify_nonce($_POST['ffw_nonce'], 'ffw_settings_update')) { + wp_die('Security check failed'); + } + if (current_user_can('manage_options')) { update_option('ffw_settings', $_POST['ffw_settings']); } @@ -20,4 +24,5 @@ function ffw_settings_page_html() { ?> <form method="post" action=""> + <?php wp_nonce_field('ffw_settings_update', 'ffw_nonce'); ?> <!-- existing settings fields -->
Exploit Outline
The exploit targets the plugin's administrative settings handler by bypassing the missing nonce check. An attacker identifies the POST parameters used to update settings (e.g., 'ffw_settings') and the trigger parameter (e.g., 'ffw_save_settings'). A malicious HTML page is then crafted containing an auto-submitting form or a hidden cross-site request that mimics a legitimate settings update. When an administrator with 'manage_options' capabilities is logged into the WordPress dashboard and visits the attacker-controlled page, the browser automatically sends the POST request to the vulnerable site, including the administrator's session cookies. Because the plugin does not verify a cryptographic nonce, it accepts the request as valid and updates the database settings with the attacker's payload.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.