Kcaptcha <= 1.0.1 - Cross-Site Request Forgery to Settings Update
Description
The Kcaptcha plugin for WordPress is vulnerable to Cross-Site Request Forgery in all versions up to and including 1.0.1. This is due to missing nonce validation in the plugin's settings page handler (admin/setting.php). The settings form does not include a wp_nonce_field() and the form processing code does not call wp_verify_nonce() or check_admin_referer() before saving settings to the database via $wpdb->update(). This makes it possible for unauthenticated attackers to modify the plugin's CAPTCHA settings (enabling or disabling CAPTCHA on login, registration, lost password, and comment forms) 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
# Exploitation Research Plan: CVE-2026-4121 (Kcaptcha CSRF) ## 1. Vulnerability Summary The **Kcaptcha** plugin for WordPress (versions up to and including 1.0.1) is vulnerable to **Cross-Site Request Forgery (CSRF)**. The vulnerability exists in the plugin's settings management logic located in `a…
Show full research plan
Exploitation Research Plan: CVE-2026-4121 (Kcaptcha CSRF)
1. Vulnerability Summary
The Kcaptcha plugin for WordPress (versions up to and including 1.0.1) is vulnerable to Cross-Site Request Forgery (CSRF). The vulnerability exists in the plugin's settings management logic located in admin/setting.php. The plugin fails to include a security nonce in the settings form and neglects to verify a nonce when processing the form submission. This allows an attacker to trick a logged-in administrator into involuntarily modifying the plugin's CAPTCHA configurations, potentially disabling security measures on critical forms (login, registration, etc.).
2. Attack Vector Analysis
- Vulnerable Endpoint:
wp-admin/admin.php?page=kcaptcha(inferred slug). - HTTP Method: POST.
- Vulnerable File:
admin/setting.php. - Vulnerable Logic: The code lacks
wp_nonce_field()in the HTML form and lackscheck_admin_referer()orwp_verify_nonce()in the PHP processing block. - Authentication Requirement: Administrator (victim must be logged in).
- Preconditions: An administrator must be induced to click a link or visit a page controlled by the attacker while their WordPress session is active.
3. Code Flow
- Registration: The plugin registers an admin menu page, likely using
add_menu_page()oradd_options_page(), pointing toadmin/setting.phpas the callback or included file. - Form Rendering: When the admin visits the settings page,
admin/setting.phprenders an HTML<form>. This form lacks the<?php wp_nonce_field(...); ?>call. - Form Submission: Upon clicking "Save" or "Submit", the browser sends a POST request to the same URL or
admin-post.php. - Processing: The top of
admin/setting.php(or anadmin_inithook) checks if$_POSTvariables are present. - Database Sink: Without any nonce check, the code proceeds to update settings in the database, specifically using
$wpdb->update()on the plugin's configuration table (likelywp_kcaptchaor updating thewp_optionstable).
4. Nonce Acquisition Strategy
No nonce is required.
According to the vulnerability description, the plugin completely lacks nonce validation in the settings handler. An unauthenticated attacker does not need to bypass a nonce check; they only need to forge the request that an administrator would normally send.
5. Exploitation Strategy
The goal is to demonstrate that a POST request sent to the settings page can modify plugin options without a nonce.
Step-by-Step Plan:
- Preparation: Identify the exact POST parameters used by the plugin to toggle CAPTCHA. Based on the description, these likely correspond to:
kcaptcha_login(inferred)kcaptcha_registration(inferred)kcaptcha_lostpassword(inferred)kcaptcha_comment(inferred)submit(inferred - often used as a trigger)
- Execution: Use the
http_requesttool to send a POST request towp-admin/admin.php?page=kcaptchawith the admin's session cookies. - Payload:
- URL:
http://localhost:8080/wp-admin/admin.php?page=kcaptcha - Method:
POST - Headers:
Content-Type: application/x-www-form-urlencoded - Body:
kcaptcha_login=0&kcaptcha_registration=0&kcaptcha_lostpassword=0&kcaptcha_comment=0&submit=Save+Settings
- URL:
6. Test Data Setup
- Plugin Installation: Install and activate the
kcaptchaplugin (version <= 1.0.1). - Initial Configuration: Manually enable all CAPTCHA options in the admin UI to ensure we have a state to "unset" via CSRF.
- Admin Victim: Ensure an administrator user exists (default:
admin/password). - Session Acquisition: The agent must obtain the admin cookies to simulate the CSRF attack.
7. Expected Results
- The server should return a
200 OKor a302 Redirectback to the settings page. - No "Are you sure you want to do this?" (WordPress's default nonce-failure message) should appear.
- The database values for the CAPTCHA settings should be updated to the attacker-supplied values (e.g., all disabled).
8. Verification Steps
After the http_request, use WP-CLI to verify the change in state:
- Check Options Table:
wp option get kcaptcha_settings(inferred name)
OR - Check Plugin Table:
wp db query "SELECT * FROM wp_kcaptcha"(inferred table name) - Check Front-end:
Navigate to the login page (/wp-login.php) and verify that the CAPTCHA field is no longer visible.
9. Alternative Approaches
If the settings are not stored in wp_options or a custom table, they might be stored as individual options.
- Individual Option Check:
wp option get kcaptcha_login - Form Discovery: If the inferred parameters are incorrect, the agent should first perform a
GETrequest towp-admin/admin.php?page=kcaptchaand usebrowser_evalto extract all input names from the form:browser_eval("Array.from(document.querySelectorAll('input[name]')).map(i => i.name)")
This discovery step ensures the POST payload matches the exact version of the plugin being tested.
Summary
The Kcaptcha plugin for WordPress is vulnerable to Cross-Site Request Forgery (CSRF) in versions up to 1.0.1. This vulnerability exists because the plugin's settings page handler in 'admin/setting.php' does not implement nonce validation, allowing attackers to modify CAPTCHA configurations by tricking an administrator into submitting a forged request.
Vulnerable Code
// admin/setting.php (approximate based on description) if (isset($_POST['submit'])) { // Vulnerable: No check_admin_referer() or wp_verify_nonce() call here $wpdb->update($wpdb->prefix . 'kcaptcha', array( 'login' => $_POST['kcaptcha_login'], 'registration' => $_POST['kcaptcha_registration'], 'lostpassword' => $_POST['kcaptcha_lostpassword'], 'comment' => $_POST['kcaptcha_comment'] ), array('id' => 1)); } // --- // admin/setting.php (form rendering) <form method="post" action=""> <!-- Vulnerable: Missing wp_nonce_field() --> <input type="checkbox" name="kcaptcha_login" value="1"> <input type="submit" name="submit" value="Save"> </form>
Security Fix
@@ -1,4 +1,5 @@ if (isset($_POST['submit'])) { + check_admin_referer('kcaptcha_update_settings'); $wpdb->update($wpdb->prefix . 'kcaptcha', array( 'login' => $_POST['kcaptcha_login'], 'registration' => $_POST['kcaptcha_registration'], @@ -10,4 +11,5 @@ ... <form method="post" action=""> + <?php wp_nonce_field('kcaptcha_update_settings'); ?> <input type="checkbox" name="kcaptcha_login" value="1"> <input type="submit" name="submit" value="Save">
Exploit Outline
The exploit targets the plugin's settings management endpoint. An unauthenticated attacker crafts a malicious HTML page containing a hidden form that targets 'wp-admin/admin.php?page=kcaptcha' via the POST method. The form contains parameters such as 'kcaptcha_login=0', 'kcaptcha_registration=0', and 'submit=Save', which are intended to disable the CAPTCHA functionality. When a logged-in administrator visits the attacker's page, the form is automatically submitted using the administrator's session cookies. Since the plugin lacks nonce verification, it processes the request and updates the database settings, effectively disabling CAPTCHA protections across the site.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.