MEDIUM 6.4

CVE-2026-12157: BetterDocs WordPress Plugin Stored XSS via blockId Attribute

BetterDocs, a popular WordPress plugin that creates knowledge bases and FAQ sections, contains a security flaw that allows certain authenticated users to inject malicious code into pages. If a contributor or higher-privilege user exploits this, their injected script will run in the browsers of anyone who visits that page, potentially stealing information, redirecting users, or defacing content. The vulnerability exists in how the plugin handles a specific block setting called 'blockId' without properly cleaning or escaping it before displaying it on the page.

Source data · NVD / CISA · public domain

CVSS
3.1 · 6.4 MEDIUM · CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N
Weaknesses (CWE)
CWE-79
Affected products
0 configuration(s)
Published / Modified
2026-06-19 / 2026-06-22

NVD description (verbatim)

The BetterDocs - Knowledge Base Docs & FAQ Solution for Elementor & Block Editor plugin for WordPress is vulnerable to Stored Cross-Site Scripting via the blockId attribute of the betterdocs/category-slate-layout Gutenberg block in versions up to, and including, 4.5.3. This is due to insufficient input sanitization and output escaping in the CategorySlateLayout::render() method, which echoes the blockId block attribute directly into an HTML class attribute without esc_attr(). This makes it possible for authenticated attackers, with contributor-level access and above, to inject arbitrary web scripts in pages that will execute whenever a user accesses an injected page.

6 reference(s) · View on NVD →

SEC.co analysis · AI-assisted, reviewed against source

Technical summary

CVE-2026-12157 is a Stored Cross-Site Scripting (XSS) vulnerability in the BetterDocs plugin for WordPress, affecting versions up to 4.5.3. The vulnerability resides in the CategorySlateLayout::render() method of the betterdocs/category-slate-layout Gutenberg block. The blockId block attribute is echoed directly into an HTML class attribute without using the WordPress esc_attr() function for proper output escaping. This insufficient input sanitization and output escaping allows authenticated attackers with contributor-level or higher permissions to inject arbitrary JavaScript that persists in the page markup and executes for all subsequent visitors. The CVSS 3.1 score of 6.4 (MEDIUM) reflects the requirement for authenticated access and the cross-site impact scope.

Business impact

Compromise of website integrity and user trust are the primary business risks. An attacker with contributor access could inject redirects to malicious sites, steal session tokens or sensitive form data from visitors, deface published content, or distribute malware. Because the malicious script is stored persistently, it affects all users who view the compromised page until remediation occurs. For organizations using BetterDocs as a customer-facing knowledge base or support portal, unauthorized code injection could significantly damage reputation and expose customer data. The requirement for contributor-level access limits the threat surface to internal teams or compromised accounts, but does not eliminate risk.

Affected systems

The BetterDocs - Knowledge Base Docs & FAQ Solution for Elementor & Block Editor plugin is vulnerable in all versions up to and including 4.5.3. Any WordPress installation running this plugin at a vulnerable version, combined with Gutenberg block editor functionality, is at risk if there are active contributor accounts or higher. Organizations should audit their WordPress user roster and recent content changes to identify potential exposure.

Exploitability

Exploitation requires authenticated access with contributor-level permissions or higher, which reduces the attack surface compared to unauthenticated vulnerabilities. However, this is not a high bar in many WordPress environments where multiple editors or contributors manage content. The attack is straightforward: an attacker simply needs to create or edit a page using the betterdocs/category-slate-layout block and inject malicious code into the blockId parameter. No user interaction is required to trigger execution once the page is saved; all subsequent visitors automatically run the injected script. The vulnerability is not known to be actively exploited in the wild (not currently on the CISA KEV catalog), but the simplicity of exploitation suggests it should be addressed promptly.

Remediation

Update BetterDocs to a patched version as soon as the vendor releases a fix that properly escapes the blockId attribute using esc_attr(). Until a patch is available, consider temporarily disabling the betterdocs/category-slate-layout block, restricting contributor access to trusted team members only, or limiting who can publish or modify pages. Monitor your WordPress audit logs for any suspicious edits to pages containing this block, and review page source code on live sites for unexpected scripts in class attributes.

Patch guidance

Consult the official BetterDocs plugin repository or vendor advisory for the specific patched version number. WordPress administrators should enable automatic plugin updates if available, or manually check for updates in the WordPress admin dashboard under Plugins > Installed Plugins. Verify the update changelog explicitly mentions a fix for blockId sanitization in the CategorySlateLayout block. Test the update in a staging environment first to ensure no compatibility issues with your Elementor or block editor configuration before deploying to production.

Detection guidance

Review WordPress audit logs and post revision history for unusual edits to pages using the betterdocs/category-slate-layout block, particularly changes to the blockId parameter that contain suspicious characters or script tags. Use WordPress security plugins or server-side logging to detect stored XSS payloads in post_meta or post_content tables where block attributes are stored. Search the database for patterns like javascript:, <script>, or event handlers within blockId values. Monitor for user complaints of unexpected redirects or script activity when viewing knowledge base pages. Browser console errors or unexpected network requests from knowledge base page views may also indicate active exploitation.

Why prioritize this

Although not yet on the CISA KEV list, this vulnerability merits prompt attention because: (1) it affects a publicly available, widely-used WordPress plugin; (2) exploitation is trivial for anyone with contributor access; (3) the payload persists and affects all page visitors; (4) the impact includes data theft and malware distribution; and (5) contributor accounts are often more common and less tightly controlled than admin accounts in multi-user WordPress environments. Organizations with knowledge bases or customer-facing documentation powered by BetterDocs should prioritize patching within 2–4 weeks, or implement compensating controls immediately.

Risk score, explained

The CVSS 3.1 score of 6.4 (MEDIUM) reflects a stored XSS with relatively broad scope (cross-site impact via C:L, I:L) but limited by the requirement for authenticated access with contributor-level privileges (PR:L). The attack vector is network-based (AV:N) and does not require special conditions to exploit (AC:L). The score does not account for organizational context: environments with strict access controls and minimal contributor accounts may view this as lower risk, while organizations with many editors or loose access management should treat this as higher priority.

Frequently asked questions

Do I need to be a WordPress administrator to exploit this vulnerability?

No. The vulnerability requires only contributor-level access or higher. Contributors can edit and publish pages, making them a sufficient threat actor for this vulnerability. Editors and administrators are also at risk if their accounts are compromised.

Will updating BetterDocs remove malicious scripts already injected into my pages?

No. Updating the plugin will prevent new injections but will not automatically clean pages that have already been compromised. After patching, manually review and edit any pages that may have been targeted, or restore from a clean backup if you suspect widespread injection.

Can I detect if someone has exploited this vulnerability on my site?

Yes. Check your WordPress post revisions and audit logs for unexpected edits to pages with the betterdocs/category-slate-layout block, review page source code for suspicious scripts in class attributes, and monitor your site's browser console for errors. Database queries on the postmeta table can also reveal suspicious blockId values.

Is there a temporary workaround if I can't patch immediately?

Consider disabling the betterdocs/category-slate-layout block entirely, restricting contributor access to a small trusted group, or using a Web Application Firewall rule to block requests with suspicious characters in block attributes. However, these are stopgap measures and patching should remain your priority.

This analysis is based on the CVE description and CVSS scoring published by the vendor. SEC.co does not independently verify patch availability, version numbers, or vendor timeline. Organizations should validate patch information directly with the BetterDocs vendor advisory and test thoroughly in staging before production deployment. The absence of a CISA KEV listing does not guarantee the vulnerability is not actively exploited; organizations should still prioritize remediation. For the most current information, consult the official WordPress plugin repository and the vendor's security announcements. Source: NVD (public-domain), retrieved 2026-07-27. Analysis generated by SEC.co (claude-haiku-4-5).