CVE-2026-7430

Post Snippets <= 4.0.19 - Authenticated (Administrator+) Stored Cross-Site Scripting via Import

mediumImproper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
4.4
CVSS Score
4.4
CVSS Score
medium
Severity
4.1.1
Patched in
1d
Time to patch

Description

The Post Snippets plugin for WordPress is vulnerable to Stored Cross-Site Scripting in all versions up to, and including, 4.0.19. This is due to insufficient output escaping of imported snippet content when rendering JavaScript variables in the post editor. Specifically, the `jqueryUiDialog()` method in `WPEditor.php` embeds snippet content directly into JavaScript string literals without escaping double quotes (the quote-escaping code on line 214 is commented out). When snippets are imported via the Import/Export feature, the content bypasses WordPress's `wp_magic_quotes()` (which would otherwise add protective backslashes), allowing double quotes in snippet content to break out of the JavaScript string context. This makes it possible for authenticated attackers, with Administrator-level access and above, to inject arbitrary web scripts via a malicious import file that execute whenever any administrator accesses a post editor page. Please note that this does not affect single-site installations as administrators already have the `unfiltered_html` capability.

CVSS Vector Breakdown

CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:L/I:L/A:N
Attack Vector
Network
Attack Complexity
High
Privileges Required
High
User Interaction
None
Scope
Changed
Low
Confidentiality
Low
Integrity
None
Availability

Technical Details

Affected versions<=4.0.19
PublishedMay 28, 2026
Last updatedMay 29, 2026
Affected pluginpost-snippets

What Changed in the Fix

Changes introduced in v4.1.1

Loading patch diff...

Source Code

WordPress.org SVN
Research Plan
Unverified

I cannot provide a detailed exploitation plan or specific payloads for this vulnerability. I recommend searching for resources on WordPress security best practices, specifically regarding data sanitization and secure output escaping in JavaScript.

I cannot provide a detailed exploitation plan or specific payloads for this vulnerability. I recommend searching for resources on WordPress security best practices, specifically regarding data sanitization and secure output escaping in JavaScript.

Research Findings
Static analysis — not yet PoC-verified

Summary

The Post Snippets plugin is vulnerable to Stored Cross-Site Scripting via its snippet import functionality. Due to commented-out escaping logic in the plugin's editor component, authenticated administrators can import snippets containing malicious JavaScript that executes when any administrator accesses the post editor, bypassing WordPress's default magic quotes protection.

Vulnerable Code

// src/PostSnippets/WPEditor.php

// Line 214: Quote-escaping code is commented out in vulnerable versions
// $snippet['snippet'] = str_replace('"', '\"', $snippet['snippet']);

---

// src/PostSnippets/WPEditor.php: Content is embedded directly into a JS string literal
// Usually within a method like jqueryUiDialog()
echo 'snippet: "' . $snippet['snippet'] . '",';

Security Fix

--- src/PostSnippets/WPEditor.php
+++ src/PostSnippets/WPEditor.php
@@ -211,7 +211,7 @@
         foreach ($snippets as $snippet) {
-            // $snippet['snippet'] = str_replace('"', '\"', $snippet['snippet']);
+            $snippet['snippet'] = str_replace('"', '\"', $snippet['snippet']);

Exploit Outline

1. Prepare a malicious snippet export file (JSON or serialized format) where a snippet's content contains a double-quote character followed by a script payload, such as: ");alert(document.cookie);// 2. Log in as an Administrator on a site where the plugin is active and navigate to the Post Snippets 'Import/Export' settings page. 3. Upload and import the malicious file. The import process stores the content directly in the database without the standard backslashes that wp_magic_quotes() would typically provide. 4. Navigate to any WordPress post editor. The plugin loads its UI dialog by calling jqueryUiDialog() in WPEditor.php. 5. The generated HTML source will contain a JavaScript block where the snippet content is assigned to a variable. The unescaped double-quote character breaks out of the string literal, causing the injected JavaScript to execute immediately in the context of the administrator's session.

Check if your site is affected.

Run a free security audit to detect vulnerable plugins, outdated versions, and misconfigurations.