# BetterDocs <= 4.9.5 - Authenticated (Contributor+) Stored Cross-Site Scripting via 'toc_title' Shortcode Attribute

- **ID:** WPSEC-2026-2870
- **Plugin:** BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot (`betterdocs`), https://wordpress.org/plugins/betterdocs/
- **Affected versions:** all versions before 4.9.6
- **Fixed in:** 4.9.6 (Update to 4.9.6 or later.)
- **Severity:** Medium 6.4 (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:L/I:L/A:N)
- **Weakness:** CWE-79
- **Usage among sites WPSec scans:** plugin Medium, affected versions Medium (as of 2026-11-12)
- **Attack surface analysis:** https://attacksurface.wpsec.com/plugin/betterdocs
- **Fix released:** 2026-11-10
- **Published:** 2026-11-12
- **URL:** https://wpsec.com/vuln/WPSEC-2026-2870/

## Description

The BetterDocs plugin for WordPress is vulnerable to Stored Cross-Site Scripting via the 'toc_title' attribute of the betterdocs_toc shortcode in all versions up to, and including, 4.9.5 due to insufficient output escaping on user-supplied attributes. Only the fallback title taken from the plugin settings was escaped. A title supplied through the shortcode attribute was echoed without escaping. 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.

## References

- https://wpsec.com/vuln/WPSEC-2026-2870/
- https://plugins.svn.wordpress.org/betterdocs/tags/4.9.6/
- https://wordpress.org/plugins/betterdocs/

Source: WPSec, https://wpsec.com/vuln/WPSEC-2026-2870/

License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Free to use, share and adapt, also commercially, if you credit WPSec and link to this advisory.
