The vulnerability is a classic stored Cross-Site Scripting (XSS) flaw within the OpenClaw Control UI. The root cause lies in the server-side rendering of the main HTML page, where configuration data (assistant name and avatar) was injected directly into an inline <script> block. The developers used JSON.stringify to serialize this data, which is unsafe for embedding within a script context because it does not escape HTML-like syntax, specifically the </script> tag.
An attacker with privileges to modify the assistant's identity could set the name to a malicious payload such as a\";</script><script>alert('XSS');//. When the Control UI page was rendered for a user, this payload would prematurely close the legitimate script tag and allow the attacker's script to execute with the full permissions of the UI's origin, leading to potential session theft or unauthorized actions.
The analysis of the provided patch commits confirms this. Commit adc818db4a4b3b8d663e7674ef20436947514e1b shows the complete removal of the server-side function injectControlUiConfig from src/gateway/control-ui.ts, which was the function that created the vulnerable script string. The calling function, serveIndexHtml, and the main request handler, handleControlUiHttpRequest, were modified to stop this injection practice. Instead, the fix implements a safer pattern: the configuration is now served from a separate JSON endpoint (/__openclaw/control-ui-config.json), and the client-side code (as seen in commit 3b4096e02e7e335f99f5986ec1bd566e90b14a7e) fetches this data asynchronously. This completely decouples the data from the HTML rendering and mitigates the XSS risk. Additionally, a stricter Content Security Policy (script-src 'self') was added as a defense-in-depth measure to block inline scripts altogether.