appium-mcp: Unescaped Locator Data XSS in MCP-UI Resource (createLocatorGeneratorUI)
Date: 2026-06
Affected: npm/appium-mcp
Attack vector: xss
Category: vulnerability-disclosure
Severity: High
CWE: CWE-79
CVSS: 8.2 (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:H/A:N)

## Unescaped Locator Data XSS in MCP-UI Resource (createLocatorGeneratorUI) ### Summary `appium-mcp`'s `createLocatorGeneratorUI` function interpolates attacker-controlled element attributes — `text`, `content-desc`, `resource-id`, and locator selector values — directly into an HTML template literal without any HTML or JavaScript context escaping. An attacker who controls the UI of the app under test can inject arbitrary HTML and JavaScript into the MCP UI resource returned by the `generate_locators` tool. When a victim's MCP client renders this resource, the injected script executes and can invoke arbitrary MCP tools via `window.parent.postMessage`, leading to unauthorized MCP tool execution such as taking screenshots, reading page source, or any other registered capability. ### Details The vulnerability is a stored/reflected cross-site scripting (XSS) issue in the MCP UI generation pipeline. **Vulnerable sink — `src/ui/mcp-ui-utils.ts:730–740`:** ```ts ${element.text ? `<p class="element-text"><strong>Text:</strong> ${element.text}</p>` : ''} ${element.contentDesc ? `<p class="element-text"><strong>Content Desc:</strong> ${element.contentDesc}</p>` : ''} ${element.resourceId ? `<p class="element-text"><strong>Resource ID:</strong> <code>${element.resourceId}</code></p>` : ''} <code class="selector">${selector}</code> <button class="test-btn" onclick="testLocator('${strategy}', `${selector.replace(/`/g, '\\`')}`)">Test</button> ``` None of `element.text`, `element.con


Mitigations:

Architectural layers (MAESTRO):