GHSA-w7xj-8fx7-wfch Open WebUI vulnerable to Stored DOM XSS via prompts when 'Insert Prompt as Rich Text' is enabled resulting in ATO/RCE
SummaryThe functionality that inserts custom prompts into the chat window is vulnerable to DOM XSS when 'Insert Prompt as Rich Text' is enabled, since the prompt body is assigned to the DOM sink `.innerHtml` without sanitisation. Any user with permissions to create prompts can abuse this to plant a payload that could be triggered by other users if they run the corresponding `/` command to insert the prompt.DetailsThe affected line is https://github.com/open-webui/open-webui/blob/7a83e7dfa367d19f762ec17cac5e4a94ea2bd97d/src/lib/components/common/RichTextInput.svelte#L348User controlled HTML from the prompt body is assigned to `tempDiv.innerHTML` without (meaningful) sanitisation. `marked.parse` introduces some character limitations but does not sanitise the content, as stated in their README.PoCCreate a custom prompt as follows:
<img width="3006" height="1100" alt="image" src="https://github.com/user-attachments/assets/47de7a11-514d-48f9-8c6a-04ab1894f981" />Via settings, ensure 'Insert Prompt as Rich Text' is enabled:
<img width="2204" height="1268" alt="image" src="https://github.com/user-attachments/assets/f188065f-7c11-4f09-9ced-4e7d2e6f4d48" />Run the command `/poc` via a chat window.
<img width="2470" height="1332" alt="image" src="https://github.com/user-attachments/assets/5a112f51-210a-43f3-b999-915b1d0e6744" />Observe the alert is triggered.
<img width="2452" height="1456" alt="image" src="https://github.com/user-attachments/assets/fa15dbd6-44a7-4cfc-bd93-4cc56aac5eea" />RCESince admins can naturally run arbitrary Python code on the server via the 'Functions' feature, this XSS could be used to force any admin that triggers it to run one such of these function with Python code of the attackers choosing.This can be accomplished by making them run the following fetch request:This cannot be done directly because the `marked.parse` call the HTML is passed through will neutralise payloads containing quotes
<img width="1718" height="482" alt="image" src="https://github.com/user-attachments/assets/6797efbd-4f2e-4570-ad9f-59a65dba1745" />
To get around this strings must be manually constructed from their decimal values using `String.fromCodePoint`. The following Python script automates generating a viable payload from given JavaScript:An admin that triggers the corresponding payload via a prompt command will trigger a Python function to run that runs a reverse shell payload, giving command line access on the server to the attacker.
<img width="2476" height="756" alt="image" src="https://github.com/user-attachments/assets/01f9e991-832a-4cfb-8c3e-3b2ce02cff15" />ImpactAny user running the malicious prompt could have their account compromised via malicious JavaScript that reads their session token from localstorage and exfiltrates it to an attacker controlled server.Admin users running the malicious prompt risk exposing the backend server to remote code execution (RCE) since malicious JavaScript running via the vulnerability can be used to send requests as the admin user that run malicious Python functions, that may run operating system commands.CaveatsLow privilege users cannot create prompts by default, the USER_PERMISSIONS_WORKSPACE_PROMPTS_ACCESS permission is needed, which may be given out via e.g. a custom group. see: https://docs.openwebui.com/features/workspace/prompts/#access-control-and-permissionsA victim user running the command to trigger the prompt needs to have the 'Insert Prompt as Rich Text' setting enabled via preferences for the vulnerability to trigger. The setting is off by default. Users with this setting disabled are unaffected.RemediationSanitise the user controlled HTML with DOMPurify before assigning it to `.innerHtml`
CVSS v3.1 score: 8.7