The analysis began by examining the provided reference URLs. The initial commit URL provided in the vulnerability details was found to be for a different, though related, XSS vulnerability. By inspecting the pull request URL (https://github.com/openclaw/openclaw/pull/24140), the correct commit (d93d22fc48443b8dcc9544ff93fdcba42b0eff49) that patches the described vulnerability was identified.
The analysis of this commit's diff revealed changes in src/auto-reply/reply/export-html/template.js. Specifically, a new function, sanitizeImageMimeType, was introduced to validate image MIME types against a safe list. This new function was then applied in two key locations where <img> tags were being generated using data: URLs.
- For images related to tool results, the code was changed from
...<img src="data:${img.mimeType};... to ...<img src="data:${sanitizeImageMimeType(img.mimeType)};....
- For images within user messages, a similar change was made.
The vulnerable function was identified as renderEntry, as it is responsible for processing and rendering different types of session entries, including the ones containing the vulnerable image-rendering logic. The vulnerability's root cause is the direct interpolation of unvalidated user-controllable data (img.mimeType) into an HTML attribute, creating a classic stored Cross-Site Scripting (XSS) vector. An attacker who can control the session data (e.g., by crafting a tool that returns a malicious image object) can inject script code that will execute when someone views the exported HTML session log.