Safari MCP patches JavaScript injection vulnerability in version 2.22.15
- Safari MCP
- JavaScript injection
- escaping

Fix addresses improper backslash escaping in tool arguments
Update prevents arbitrary code execution across browser tabs
Users are advised to upgrade to the latest version
Safari MCP maintainers have released version 2.22.15 to address a JavaScript injection vulnerability. This security update corrects how the software handles tool arguments within the application.
The vulnerability occurred because 16 locations in the safari.js file placed tool arguments inside single-quoted JavaScript string literals without first escaping backslashes. An attacker could provide a backslash followed by a single quote to prematurely close the string literal and execute arbitrary JavaScript code in the page context. This issue affected both read-only and other tools, allowing execution even in browser tabs not owned by the session.
The update introduces a shared escJsSingleQuote function to ensure backslashes are properly escaped before quotes. A new build-time test also prevents future regressions. There is no configuration workaround, and users should upgrade to version 2.22.15 to mitigate the vulnerability.




