Safari MCP single-quoted tool parameters fail to escape backslashes, causing JavaScript injection, fixed in 2.22.15
Safari MCP: JavaScript injection through single-quoted tool arguments (backslash not escaped)
safari-mcp (npm) versions before 2.22.15 contain a JavaScript injection vulnerability: in safari.js, 16 places place tool parameters into single-quoted JavaScript string literals while escaping only single quotes and not first escaping backslashes; a parameter containing a backslash followed by a quote can close the literal, and the rest is executed as JavaScript in the page. Of these, 7 belong to read-only tools exempt from the tab ownership check, such as the filter of safari_network_details, the selector of safari_snapshot, and the dbName and storeName of safari_get_indexed_db; even if the MCP client authorizes only read-only tools and the allowlist excludes safari_evaluate and safari_run_script, arbitrary page JavaScript can still be run this way, including in tabs not owned by the session.
The advisory states that removing high-risk tools from the allowlist still cannot prevent injection, and that parameters of read-only tools can likewise execute arbitrary page scripts; MCP permission configurations can be reviewed accordingly.