Summary
Docmost's public share page feature fails to HTML-escape page titles before placing them into meta and title tags, enabling stored Cross-Site Scripting (XSS).
An attacker who can control a shared page's title may inject JavaScript that executes in the browser of any user who opens the shared link.
Affected context
This vulnerability affects Docmost instances where users can create or edit pages that are then shared via public links.
The issue occurs when user-controlled page titles are inserted into HTML meta tags and the <title> element without proper HTML escaping or output encoding.
Any environment that exposes these public share URLs to other users, including external collaborators or anonymous visitors, may be at risk if attackers can influence page titles.
Exploit preconditions
- Attack surface: Web browser rendering Docmost public share pages
- Required access: Ability to create or modify a Docmost page that can be shared publicly (e.g., authenticated user with page edit rights)
- Trigger point: A victim opening a crafted public share URL in their browser
- Why exploitation is possible: The page's title, controlled by the attacker, is written directly into meta and title tags without HTML escaping or context-appropriate output encoding, allowing injected script to execute.
Why this happens
The root cause is improper output encoding of user-supplied data in an HTML context, mapped to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting).
The application takes a page title, which may contain markup or script, and embeds it directly into meta tags and the <title> element in the document head.
Without applying HTML-escaping or a templating mechanism that enforces context-aware escaping, the browser interprets the injected content as active HTML/JavaScript rather than as plain text, enabling stored XSS.
Potential impact
- Theft of user session data (e.g., cookies if not properly protected)
- Execution of arbitrary JavaScript in the context of the Docmost application
- Unauthorized actions performed on behalf of the victim (e.g., modifying content, changing settings) via CSRF-like behavior within the same origin
- Phishing or UI redressing attacks, such as injecting deceptive content or prompts
- Exfiltration of sensitive information accessible within the victim's browser context
General mitigation guidance
Effective mitigation focuses on robust output encoding and strict handling of untrusted data in HTML:
- Apply context-aware escaping for all user-supplied values rendered into HTML, ensuring page titles are properly HTML-escaped before insertion into meta and title tags.
- Use templating engines or frameworks that default to safe escaping and avoid raw HTML injections, especially in layout and head sections.
- Treat all user-controlled fields (titles, descriptions, custom labels) as untrusted input and avoid interpreting them as HTML; prefer plain-text rendering.
- Introduce defense-in-depth controls such as a strong Content Security Policy (CSP) that limits inline script execution and restricts script sources.
- Follow least-privilege principles in the application UI so that actions available via the browser are minimized for compromised sessions.
How teams detect issues like this
Detection typically involves a combination of automated and manual techniques:
- Static analysis: Scan templates and server-side rendering code for direct insertion of user-controlled variables into HTML without escaping, especially in head/meta/title sections.
- Security-focused code review: Flag any use of raw HTML output methods or bypasses of the default escaping mechanisms.
- Dynamic application testing: Use automated and manual tests that insert typical XSS payload markers into page titles and verify whether they execute when viewing public share pages.
- Policy enforcement in CI/CD: Add checks or linters that disallow rendering functions known to output unescaped content, and enforce secure coding guidelines for view templates.

