Skip to content
MediumVulnerability

GHSA-4rj4-rcrq-gr92: Safari MCP: JavaScript injection through single-quoted tool arguments (backslash not escaped)

Published
Record updated
View JSON
Affected
  • safari-mcp < 2.22.15
Fixed in
2.22.15
  • released October 10, 2026, 40 days before disclosure

Summary

Sixteen sites in `safari.js` of Safari MCP placed tool arguments inside single-quoted JavaScript string literals and escaped the quote without escaping backslashes first. A backslash followed by a quote closed the literal, so the remaining argument text ran as JavaScript in the page, including through seven read-only tools that are exempt from the tab-ownership check. An MCP client restricted to read-only tools with `safari_evaluate` and `safari_run_script` excluded could still execute arbitrary page JavaScript, including in tabs the session does not own.

Mitigation

Fixed in 2.22.15: every affected site now uses the shared `escJsSingleQuote`, which escapes the backslash before the quote, and a test fails the build if a quote-only escape returns. Upgrade to 2.22.15; there is no configuration workaround, since excluding `safari_evaluate` and `safari_run_script` from a client's tool list did not prevent the injection.