CVE-2024-54226
Executive Summary
CVE-2024-54226 is a Cross-Site Request Forgery (CSRF) vulnerability in the WordPress plugin Country Blocker by karlkiesinger, affecting versions through 3.2. This flaw allows an attacker to trick an authenticated administrator into performing unintended actions, such as modifying plugin settings or injecting malicious scripts. The CSRF vector is compounded by a Stored Cross-Site Scripting (XSS) impact, meaning an attacker can inject persistent JavaScript payloads that execute in the context of other admin sessions. The vulnerability has a CVSS score of 7.1 (High) and currently has no known patch or public exploit code. The EPSS score is 0.0%, indicating low exploitation likelihood at this time, but the risk remains significant for unpatched WordPress installations.
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 via the official WordPress plugin repository. Since the plugin is not a standard package manager (NPM, PyPI, etc.), supply chain risks are limited to the plugin’s update mechanism. However, the lack of a patch means site administrators must manually disable or remove the plugin to mitigate risk.
CVSS Breakdown & Threat Level
- Attack Vector (AV): Network (N) – Exploitable remotely.
- Attack Complexity (AC): Low (L) – No special conditions required.
- Privileges Required (PR): None (N) – Attacker does not need authentication.
- User Interaction (UI): Required (R) – Victim admin must click a crafted link or visit a malicious page.
- Scope (S): Changed (C) – Impact extends beyond the vulnerable component.
- Confidentiality (C): Low (L) – Limited data exposure.
- Integrity (I): Low (L) – Limited modification of data.
- Availability (A): Low (L) – Limited service disruption.
Threat Level: High (7.1) – Exploitation requires user interaction but can lead to persistent XSS, enabling further attacks like credential theft or plugin backdooring.
Deep Dive & Mechanics
The vulnerability resides in the Country Blocker plugin’s administrative interface. The plugin fails to implement CSRF tokens (nonces) on state-changing requests, such as saving settings or whitelist/blacklist rules. An attacker can craft a malicious HTML page or email that, when visited by an authenticated WordPress admin, triggers a forged request to the plugin’s admin-ajax.php or admin-post.php endpoints.
Because the plugin also lacks proper output sanitization, the attacker can inject JavaScript payloads into stored settings (e.g., custom messages or redirect URLs). These payloads are then executed when other admins view the plugin’s settings page, leading to Stored XSS. The attack chain:
- Attacker crafts a CSRF payload that modifies a plugin setting to include a malicious script.
- Victim admin (with privileges to manage the plugin) visits the attacker’s page.
- The forged request updates the plugin’s stored configuration.
- When the victim or another admin reloads the plugin settings page, the injected script executes in their browser session.
Vulnerable vs. Patched Code
Since no patch is available, the vulnerable code is the entire plugin version <= 3.2. The missing CSRF protection is typically implemented via WordPress nonce fields (wp_nonce_field()) and verification (check_admin_referer() or wp_verify_nonce()). A patched version would include:
// Vulnerable (no nonce check)
function save_settings() {
update_option('country_blocker_settings', $_POST['settings']);
}
// Patched (with nonce verification)
function save_settings() {
if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'country_blocker_save')) {
wp_die('Security check failed.');
}
update_option('country_blocker_settings', $_POST['settings']);
}
Additionally, output escaping (e.g., esc_html(), esc_attr()) must be applied to all stored values before rendering in the admin panel.
Exploitation & Lab Setup
Red Team (Attacker)
Prerequisites:
- A WordPress site with Country Blocker <= 3.2 installed and an admin user logged in.
- Ability to host a malicious HTML page or send a crafted email.
Exploitation Steps:
- Craft CSRF Payload: Create an HTML page that auto-submits a form to the vulnerable endpoint.
<html>
<body>
<form id="csrf" action="http://target/wp-admin/admin-post.php?action=country_blocker_save" method="POST">
<input type="hidden" name="settings[blocked_message]" value="<script>alert('XSS')</script>">
<input type="submit" value="Submit">
</form>
<script>document.getElementById('csrf').submit();</script>
</body>
</html>
Deliver Payload: Host the page and trick the admin into visiting it (e.g., via phishing email or malicious ad).
Trigger XSS: Once the admin visits, the CSRF updates the plugin settings with the XSS payload. The next time the admin views the plugin settings page, the script executes.
Note: No public exploit code is available; this is a conceptual demonstration.
Blue Team (Defender)
Detection & Prevention:
- Monitor for unexpected changes to plugin settings via audit logs.
- Use Web Application Firewall (WAF) rules to block requests lacking a valid nonce.
- Implement Content Security Policy (CSP) headers to mitigate XSS impact.
- Regularly review plugin code for missing CSRF tokens.
Lab Setup:
- Install WordPress with Country Blocker 3.2 on a local environment (e.g., XAMPP, Docker).
- Use browser developer tools to inspect network requests and verify missing nonces.
- Simulate CSRF attack using a local HTML file and observe the XSS execution.
Indicators of Compromise (IOCs)
- Network: HTTP POST requests to
/wp-admin/admin-post.php?action=country_blocker_savewithout a valid_wpnonceparameter. - File: Modified
wp_optionstable entries forcountry_blocker_settingscontaining<script>tags or unusual JavaScript. - Log: WordPress debug log entries showing unexpected settings changes.
- Behavior: Admin users reporting unexpected pop-ups or redirects when accessing the Country Blocker settings page.
Detection Engineering
YARA Rule
rule CVE_2024_54226_Country_Blocker_CSRF_XSS {
meta:
description = "Detects CSRF and Stored XSS indicators in Country Blocker plugin"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2024-54226"
strings:
$csrf_endpoint = "admin-post.php?action=country_blocker_save"
$xss_payload = /<script[^>]*>.*<\/script>/i
$nonce_missing = /_wpnonce/i
condition:
$csrf_endpoint and not $nonce_missing and $xss_payload
}
Sigma Rule
title: CVE-2024-54226 - Country Blocker CSRF to Stored XSS
id: 7a8b9c0d-1e2f-3a4b-5c6d-7e8f9a0b1c2d
status: experimental
description: Detects HTTP requests to Country Blocker plugin endpoints without nonce, indicating potential CSRF attack.
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
service: access_combined
detection:
selection:
cs-method: 'POST'
cs-uri-query|contains: 'action=country_blocker_save'
cs-uri-query|contains: 'settings'
filter:
cs-uri-query|contains: '_wpnonce'
condition: selection and not filter
falsepositives:
- Legitimate admin actions if nonce is missing due to plugin bug
level: high
Suricata Rule
alert http any any -> $HOME_NET any (
msg:"CVE-2024-54226 - Country Blocker CSRF Attempt";
flow:to_server,established;
content:"POST";
http_method;
content:"admin-post.php";
http_uri;
content:"action=country_blocker_save";
http_uri;
content:"settings";
http_client_body;
pcre:"/^settings\[/";
sid:1000001;
rev:1;
reference:cve,2024-54226;
classtype:web-application-attack;
priority:1;
)
Remediation & Mitigation
Immediate Actions:
- Disable the plugin until a patch is released.
- Remove the plugin if not essential.
- Audit admin accounts for unauthorized changes.
Long-term Fixes:
- Apply a custom patch by adding nonce verification and output escaping (see Vulnerable vs. Patched Code section).
- Monitor the plugin repository for an official update.
- Implement a Web Application Firewall (WAF) with rules to block CSRF-like requests.
Workarounds:
- Restrict access to the plugin settings page via
.htaccessor IP whitelisting. - Use a security plugin (e.g., Wordfence) that adds CSRF protection to all admin actions.
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.