/

CVE-2021-47779

Severity:

HIGH RISK

(7.2)

Stored XSS in Dolibarr ERP-CRM Ticket Creation Module

CVE-2021-47779

Analyzed

Vulnerability type

Category:

Stored Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Privilege Escalation and Session Hijacking via Stored XSS

Severity:

HIGH RISK

(7.2)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Dolibarr ERP-CRM 14.0.2 contains a stored cross-site scripting vulnerability in the ticket creation module that allows low-privilege users to inject persistent JavaScript into ticket messages.

When an administrator later interacts with the crafted ticket text (for example, by copying the message), the malicious script can execute in the admin's browser context, potentially enabling privilege escalation and unauthorized actions.

Affected context

The vulnerability occurs in the ticket creation workflow of Dolibarr ERP-CRM 14.0.2, where user-supplied ticket messages are stored and later rendered in the administrative interface.

It becomes relevant when low-privilege or helpdesk users can submit tickets containing rich text or HTML-like content, and when the application displays this content to higher-privileged users without consistently sanitizing or encoding it in all views and interaction flows.

The risk is heightened in environments where administrators frequently review, copy, or otherwise interact with ticket content in a modern web browser.

Exploit preconditions

  • Attack surface: Web-based ticket creation and review pages within Dolibarr's ERP-CRM interface.
  • Required access: Ability to authenticate or otherwise act as a low-privilege user who can create or update tickets.
  • Trigger point: An administrator or higher-privileged user opens the malicious ticket and performs specific interactions (such as copying text) that cause the browser to process and execute the embedded script.
  • Why exploitation is possible: User-controlled ticket message content is stored server-side and later rendered into an administrative page without sufficient output encoding or sanitization, allowing script execution in the context of the admin's session.

Why this happens

This issue stems from improper neutralization of user-controlled input before it is included in a web page, corresponding to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting).

The ticket creation module accepts arbitrary message content from low-privilege users and stores it, but when the same content is later retrieved and presented in the admin interface, it is not consistently HTML-encoded or filtered.

As a result, embedded JavaScript or event handlers can survive storage and be interpreted by the browser as active code rather than inert text, particularly during user interactions such as selecting or copying content.

The underlying pattern is a lack of strict separation between data and executable markup when rendering untrusted text in privileged views.

Potential impact

  • Execution of arbitrary JavaScript in the browser of an administrator or other privileged user.
  • Theft of session cookies or tokens associated with high-privilege accounts, which could enable account takeover.
  • Unauthorized actions performed on behalf of an administrator (e.g., configuration changes, user management, or data manipulation) via forged requests in the admin's session.
  • Modification or exfiltration of sensitive ERP/CRM data accessible to the targeted administrator.
  • Establishment of persistent malicious content within the application interface, affecting multiple admin sessions.

General mitigation guidance

Mitigation usually focuses on enforcing context-aware output encoding and strict handling of untrusted HTML-like input:

  • Treat all ticket message content as untrusted and apply HTML-encoding by default when displaying it, especially in administrative views.
  • Use a vetted, server-side HTML sanitization library if rich text is genuinely required, configured with a restrictive allowlist of tags and attributes, and explicitly stripping all scripting capabilities (e.g., <script>, on* event handlers, javascript: URLs).
  • Apply output encoding at the point of rendering, tailored to the specific context (HTML body, attribute, URL, JavaScript, etc.) rather than relying solely on input validation.
  • Implement role-aware display rules that avoid rendering untrusted user content with elevated privileges unless it has been safely transformed.
  • Limit the need for administrators to work directly with raw, user-supplied markup by providing safe, text-only modes or preview components.

How teams detect issues like this

Detection generally involves a mix of review, tooling, and testing:

  • Static analysis: Configure security linters or SAST tools to flag direct insertion of user-controlled variables into templates or DOM construction APIs without encoding functions.
  • Code review: Examine the ticket creation and display code paths for unchecked use of request parameters, database fields, or template variables within HTML, attributes, or inline scripts.
  • Security testing: Use automated and manual web security testing tools to inject benign XSS test payloads into ticket messages and observe whether any are reflected or stored and later executed in admin views.
  • Policy enforcement: Define development guidelines that mandate output encoding helpers in templating layers and prohibit direct interpolation of raw user content in privileged UIs, with pre-merge checks to enforce these patterns.

Sources

SourceLink
github.comgithub.com/Dolibarr
dolibarr.orgdolibarr.org/
exploit-db.comexploit-db.com/exploits/50432
vulncheck.comvulncheck.com/advisories/dolibarr-erp-crm-stored-cross-site-scripting-xss-privilege-escalation

Frequently asked

questions

It can be, depending on deployment. If the Dolibarr instance is accessible over the internet or to a broad user base, any remote user with the ability to create tickets could potentially exploit the issue to target admins. In more restricted deployments, the attacker would need internal or partner access.

The attacker typically needs low-privilege access sufficient to create or update tickets. They do not need administrative rights; the attack relies on stored malicious content later being viewed or interacted with by an administrator.

The safest approach is to ensure that all user-supplied ticket content is properly context-encoded or sanitized immediately before rendering, eliminating the possibility of script execution while still allowing safe text display. Where rich text is required, use a strict allowlist-based sanitizer that strips scripting and dangerous attributes.

Adopt a defense-in-depth strategy: standardize on output encoding helpers in templates, enforce secure coding guidelines for handling untrusted input, apply automated static analysis and security testing focused on XSS patterns, and limit the rendering of raw user content in privileged interfaces. Regular security reviews of new UI features can help catch unsafe patterns early.

Find out what's already
exploitable in your codebase.