Published : November 28, 2026

CVE-2026-121521: Postie <= 1.9.91 Unauthenticated Stored Cross-Site Scripting via Email Body HTML Attribute Entity Decoding PoC, Patch Analysis & Rule

Plugin postie
Severity Medium (CVSS 5.4)
CWE 79
Vulnerable Version 1.9.91
Patched Version 1.9.92
Disclosed November 25, 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-121521:

CVE-2026-121521 is an unauthenticated stored cross-site scripting (XSS) vulnerability in the Postie WordPress plugin affecting versions up to and including 1.9.91. The flaw resides in the email HTML body parsing and storage logic, allowing an attacker to inject arbitrary web scripts through a crafted email. Atomic Edge research rates this as high severity (CVSS 5.4) because exploitation requires no authentication and the stored payload executes in an administrator’s browser, potentially leading to full site compromise.

The root cause involves the plugin’s handling of HTML entity decoding and insufficient output escaping. In postie-message.php, the filter_ReplaceImageCIDs function (lines 496-499 in the diff) previously replaced the entire email content with a version that decoded entities like " and ‘ without proper sanitization. This decoding occurred before the content was passed to wp_insert_post(). When the request runs under a user with unfiltered_html capability (e.g., when Force User Login is enabled or an admin manually triggers a fetch), the wp_filter_post_kses filter is disabled, allowing the decoded entities to break out of HTML attribute contexts. The vulnerable code path is triggered when an email contains a content-id header with a malformed value (e.g., empty or missing brackets), causing the CID replacement logic to fail and leaving decoded payloads intact. The patch (postie-message.php) removes the unsafe str_replace decoding block, and other files (fMailbox.php, postie-filters.php) add validation to skip empty or malformed content-id values, preventing the mishandling.

An attacker sends an email to the WordPress site’s Postie-configured mailbox (e.g., postie@example.com) with a specially crafted HTML body. The payload exploits an HTML attribute context by using an image tag with an onerror event handler, such as . The attacker includes a malformed Content-ID header (e.g., Content-ID: ) to trigger the vulnerable CID replacement path, where the lack of validation causes the entity-decoded payload to be stored verbatim. When an administrator views the post or page via the WordPress admin interface, the script executes, stealing cookies or performing privileged actions. The attack requires no authentication; the attacker only needs to send an email to the target address.

The patch fixes the vulnerability by eliminating the unsafe entity decoding in postie-message.php (removing the str_replace block) and hardening Content-ID processing in fMailbox.php (adding trimming and validation to skip empty or bracketless CIDs) and postie-filters.php (skipping empty CIDs). Before the patch, the decoded entity replacements allowed attackers to inject quotes and other characters that broke HTML attributes, and the malformed CID caused the plugin to bypass related attachment processing. After the patch, entities remain encoded, and malformed CIDs are ignored, preventing the attribute breakout. Additionally, the patch addresses a race condition in postie.php by removing a redundant query filter and ensuring logging does not recurse, but this is auxiliary.

Successful exploitation leads to stored XSS, which executes in the context of an administrator or any user viewing the injected post. This enables session hijacking, credential theft, privilege escalation (creating rogue admin accounts), and potentially remote code execution via plugin/theme editor access. The vulnerability is particularly dangerous for sites with Force User Login enabled, as unauthenticated attackers can directly queue the payload. Atomic Edge analysis confirms the impact is severe given the plugin’s widespread use for automated posting.

Differential between vulnerable and patched code

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

Code Diff
--- a/postie/lib/fMailbox.php
+++ b/postie/lib/fMailbox.php
@@ -297,12 +297,20 @@
         }

         // This indicates a content-id which is used for multipart/related
-        if ($structure['content_id'] && $structure['type'] != 'text') {
+        $cid = '';
+        if (!empty($structure['content_id'])) {
+            $cid = trim($structure['content_id']);
+            if (substr($cid, 0, 1) === '<' && substr($cid, -1) === '>') {
+                $cid = substr($cid, 1, -1);
+            }
+            $cid = trim($cid);
+        }
+
+        if ($cid !== '' && $structure['type'] != 'text') {
             //DebugEcho('handlePart: multipart/related: ' . $structure['content_id']);
             if (!isset($info['related'])) {
                 $info['related'] = array();
             }
-            $cid = $structure['content_id'][0] == '<' ? substr($structure['content_id'], 1, -1) : $structure['content_id'];
             //DebugEcho("handlePart: cid: $cid ($filename) {$structure['type']}/{$structure['subtype']}");
             $info['related']['cid:' . $cid] = array(
                 'filename' => $filename,
@@ -812,11 +820,22 @@
             //DebugEcho('parseStructure: multipart');
             //DebugDump($structure);
         } else {
+            $content_id = isset($headers['content-id']) ? trim($headers['content-id']) : NULL;
+            if ($content_id !== NULL) {
+                $clean_cid = $content_id;
+                if (substr($clean_cid, 0, 1) === '<' && substr($clean_cid, -1) === '>') {
+                    $clean_cid = substr($clean_cid, 1, -1);
+                }
+                if (trim($clean_cid) === '') {
+                    $content_id = NULL;
+                }
+            }
+
             $structure = array(
                 'type' => $type,
                 'type_fields' => !empty($headers['content-type']['fields']) ? $headers['content-type']['fields'] : array(),
                 'subtype' => $subtype,
-                'content_id' => isset($headers['content-id']) ? $headers['content-id'] : NULL,
+                'content_id' => $content_id,
                 'encoding' => isset($headers['content-transfer-encoding']) ? strtolower($headers['content-transfer-encoding']) : '8bit',
                 'disposition' => isset($headers['content-disposition']) ? strtolower($headers['content-disposition']['value']) : NULL,
                 'disposition_fields' => isset($headers['content-disposition']) ? $headers['content-disposition']['fields'] : array());
--- a/postie/lib/pConnection.php
+++ b/postie/lib/pConnection.php
@@ -56,6 +56,10 @@

     abstract function isPersistant();

+    public function fetchMessageSource($uid) {
+        return null;
+    }
+
     public function getMailbox() {
         return $this->mailbox;
     }
--- a/postie/lib/pCurlConnection.php
+++ b/postie/lib/pCurlConnection.php
@@ -144,4 +144,73 @@
     public function isPersistant() {
         return false;
     }
+
+    public function buildFetchUrl($uid) {
+        if ($this->type == 'imap') {
+            $mailbox = trim($this->mailbox, '/');
+            if ($mailbox === '') {
+                $mailbox = 'INBOX';
+            }
+            return ($this->secure ? 'imaps' : 'imap') . '://' . $this->host . '/' . $mailbox . '/;UID=' . $uid;
+        }
+
+        return ($this->secure ? 'pop3s' : 'pop3') . '://' . $this->host . '/' . $uid;
+    }
+
+    public function fetchMessageSource($uid) {
+        $url = $this->buildFetchUrl($uid);
+        return $this->executeFetch($url, $uid);
+    }
+
+    protected function executeFetch($url, $uid) {
+        DebugEcho("curl fetch: $url");
+
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_USERPWD, "$this->username:$this->password");
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_PORT, $this->port);
+        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
+        curl_setopt($ch, CURLOPT_HEADER, false);
+        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout);
+        curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
+
+        $fp = fopen('php://temp', 'w+');
+        curl_setopt($ch, CURLOPT_WRITEFUNCTION, function ($ch, $data) use ($fp) {
+            return fwrite($fp, $data);
+        });
+
+        $headers = array();
+        curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($ch, $header) use (&$headers) {
+            $headers[] = $header;
+            return strlen($header);
+        });
+
+        curl_setopt($ch, CURLOPT_VERBOSE, true);
+        $verbose = fopen('php://temp', 'w+');
+        curl_setopt($ch, CURLOPT_STDERR, $verbose);
+
+        $res = curl_exec($ch);
+
+        rewind($verbose);
+        $verboseLog = stream_get_contents($verbose);
+        DebugEcho("curl log: $verboseLog");
+        fclose($verbose);
+
+        if (false === $res) {
+            $error = curl_error($ch);
+            $errno = curl_errno($ch);
+            DebugEcho("Curl fetch error: $error ($errno)");
+            fclose($fp);
+            curl_close($ch);
+            throw new fConnectivityException('Unable to fetch message %1$s from %2$s server %3$s on port %4$s: %5$s', $uid, strtoupper($this->type), $this->host, $this->port, $error);
+        }
+
+        curl_close($ch);
+
+        rewind($fp);
+        $message = stream_get_contents($fp);
+        fclose($fp);
+
+        return $message;
+    }
 }
--- a/postie/lib/pImapMailServer.php
+++ b/postie/lib/pImapMailServer.php
@@ -72,6 +72,11 @@

     function fetchMessageSource($uid) {

+        $source = $this->connection->fetchMessageSource($uid);
+        if ($source !== null) {
+            return $source;
+        }
+
         $response = $this->connection->write('UID FETCH ' . $uid . ' (BODY[])');

         $j = 0;
--- a/postie/lib/pPop3MailServer.php
+++ b/postie/lib/pPop3MailServer.php
@@ -28,6 +28,11 @@
     }

     public function fetchMessageSource($uid) {
+        $source = $this->connection->fetchMessageSource($uid);
+        if ($source !== null) {
+            return $source;
+        }
+
         $response = $this->connection->write('RETR ' . $uid);
         array_shift($response);
         $response = join("rn", $response);
--- a/postie/postie-filters.php
+++ b/postie/postie-filters.php
@@ -496,6 +496,9 @@
         if (count($email['related'])) {
             DebugEcho("filter_ReplaceImageCIDs: # CID attachments: " . count($email['related']));
             foreach ($email['related'] as $cid => &$attachment) {
+                if ($cid === '' || $cid === 'cid:' || trim($cid) === 'cid:') {
+                    continue;
+                }
                 if (false !== stripos($content, $cid)) {
                     DebugEcho("filter_ReplaceImageCIDs: CID: $cid");
                     if (isset($attachment['wp_id'])) {
--- a/postie/postie-message.php
+++ b/postie/postie-message.php
@@ -84,12 +84,7 @@
         global $postie_post;
         $postie_post = $details;

-        //fix quoting
         $content = $postie_post['post_content'];
-        $char = array('"', '‘', '’', '“', '”', '′', '″');
-        $replace = array('"', "'", "'", '"', '"', "'", '"');
-        $content = str_replace($char, $replace, $content);
-
         $newcontent = do_shortcode($content);
         $details = $postie_post; // need to copy values back in case a shortcode modified them
         $details['post_content'] = $newcontent;
--- a/postie/postie.class.php
+++ b/postie/postie.class.php
@@ -535,6 +535,9 @@
     }

     function log_onscreen($data) {
+        if ((function_exists('wp_doing_ajax') && wp_doing_ajax()) || (defined('DOING_AJAX') && DOING_AJAX)) {
+            return;
+        }
         if (php_sapi_name() == 'cli') {
             echo esc_html($data) . "n";
         } else {
--- a/postie/postie.php
+++ b/postie/postie.php
@@ -4,7 +4,7 @@
   Plugin Name: Postie
   Plugin URI: http://PostiePlugin.com/
   Description: Create posts via email. Significantly upgrades the Post by Email features of WordPress.
-  Version: 1.9.91
+  Version: 1.9.92
   Author: Wayne Allen
   Author URI: http://PostiePlugin.com/
   License: GPL3
@@ -28,7 +28,7 @@
  */

 /*
-  $Id: postie.php 3798962 2026-11-12 17:43:21Z WayneAllen $
+  $Id: postie.php 3821111 2026-11-24 17:30:41Z WayneAllen $
  */

 if (!defined('WPINC')) {
@@ -50,6 +50,8 @@

     class PostieInit {

+        private static $is_logging_query = false;
+
         public function __construct() {
             //WordPress Actions
             add_action('init', array($this, 'init_action'), 20);
@@ -145,8 +147,13 @@
         }

         function query_filter($query) {
-            if (Postie::is_debugmode()) {
-                DebugEcho("Query: $query");
+            if (!self::$is_logging_query && Postie::is_debugmode()) {
+                self::$is_logging_query = true;
+                try {
+                    DebugEcho("Query: $query");
+                } finally {
+                    self::$is_logging_query = false;
+                }
             }

             return $query;
@@ -318,6 +325,7 @@

             $raw_output = ob_get_clean();
             remove_action('postie_log_debug', $log_collector);
+            remove_filter('query', array($this, 'query_filter'));

             $duration = round(microtime(true) - $start_time, 2);

@@ -390,6 +398,7 @@

             $raw_output = ob_get_clean();
             remove_action('postie_log_debug', $log_collector);
+            remove_filter('query', array($this, 'query_filter'));

             $duration = round(microtime(true) - $start_time, 2);

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.