CVE-2021-24159

8.8 HIGH

📋 TL;DR

This vulnerability in the Contact Form 7 Style WordPress plugin allows attackers to inject malicious JavaScript through the custom CSS feature due to lack of sanitization and nonce protection. Attackers can trick administrators into clicking malicious links to execute cross-site request forgery (CSRF) attacks, potentially compromising affected WordPress sites. All sites using Contact Form 7 Style plugin versions up to 3.1.9 are vulnerable.

💻 Affected Systems

Products:
  • Contact Form 7 Style WordPress Plugin
Versions: All versions up to and including 3.1.9
Operating Systems: Any OS running WordPress
Default Config Vulnerable: ⚠️ Yes
Notes: Requires plugin to be installed and active. Vulnerability exists in the custom CSS feature accessible to administrators.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Site takeover through admin account compromise leading to complete website defacement, data theft, malware distribution, or ransomware deployment.

🟠

Likely Case

Malicious JavaScript injection leading to session hijacking, credential theft, or redirecting visitors to phishing/malware sites.

🟢

If Mitigated

Attack fails due to proper CSRF protection, input validation, or administrator security awareness preventing the initial click.

🌐 Internet-Facing: HIGH
🏢 Internal Only: LOW

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: LOW

Exploitation requires social engineering to trick an administrator into clicking a malicious link. The vulnerability is well-documented in security advisories.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: None - vulnerability was never patched

Vendor Advisory: https://wpscan.com/vulnerability/363182f1-9fda-4363-8f6a-be37c4c07aa9

Restart Required: No

Instructions:

1. Remove Contact Form 7 Style plugin completely. 2. Find alternative contact form styling solutions. 3. The plugin was abandoned and never received a security patch.

🔧 Temporary Workarounds

Remove Vulnerable Plugin

all

Completely uninstall Contact Form 7 Style plugin as no patch exists

wp plugin delete contact-form-7-style
Or delete via WordPress admin panel

Implement CSRF Protection

all

Add nonce verification to all plugin forms and AJAX requests

Requires custom code modification: wp_nonce_field() and wp_verify_nonce() implementation

🧯 If You Can't Patch

  • Disable plugin immediately and use alternative contact form styling solutions
  • Implement web application firewall (WAF) rules to block malicious CSS/JS injection attempts

🔍 How to Verify

Check if Vulnerable:

Check WordPress admin panel > Plugins > Contact Form 7 Style. If version is 3.1.9 or lower, you are vulnerable.

Check Version:

wp plugin get contact-form-7-style --field=version

Verify Fix Applied:

Verify plugin is completely removed from /wp-content/plugins/ directory and no longer appears in WordPress admin

📡 Detection & Monitoring

Log Indicators:

  • POST requests to /wp-admin/admin-ajax.php with action=cf7s_save_custom_css
  • Unusual CSS content containing JavaScript tags or event handlers
  • Multiple failed admin login attempts followed by CSS update requests

Network Indicators:

  • HTTP requests containing malicious JavaScript in CSS parameters
  • Traffic patterns showing CSRF attacks against admin endpoints

SIEM Query:

source="wordpress.log" AND ("cf7s_save_custom_css" OR "contact-form-7-style") AND ("script" OR "javascript" OR "onclick" OR "onload")

🔗 References

📤 Share & Export