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

Medium

OSV id
GHSA-4rj4-rcrq-gr92
Published
Last modified

Affected packages

PackageAffected versionsFixed in
safari-mcp
npm
< 2.22.15 2.22.15

How to fix it

Upgrade safari-mcp to 2.22.15 or later.

npm install safari-mcp@2.22.15
# if it is an indirect dependency: npm update safari-mcp (or npm audit fix)
  • If it is an indirect dependency, upgrade the package that depends on it, or force the version with "overrides" (npm), "resolutions" (Yarn) or "pnpm.overrides" (pnpm) in package.json.
  • Check the changelog for breaking changes (especially across major versions), update the lockfile with the package manager, and run your tests.

Not sure whether your project uses an affected version? Check your lockfile below for free.

Details

Impact

Sixteen places in safari.js placed a tool argument inside a single-quoted JavaScript string literal and escaped the single quote without first escaping backslashes. An argument containing a backslash followed by a quote therefore closed the literal, and the rest of the argument ran as JavaScript in the page.

Seven of the affected arguments belong to read-only tools that are exempt from the tab-ownership check: filter in safari_network_details and safari_extract_links, level in safari_console_filter, selector in safari_snapshot, safari_accessibility_snapshot and safari_extract_tables, and dbName / storeName in safari_get_indexed_db. An MCP client limited to read-only tools (with safari_evaluate and safari_run_script excluded from its allowlist) could still run arbitrary page JavaScript through them, including in a tab the session does not own. The other affected arguments are ref in safari_select_option, safari_react_select_set and safari_react_select_list_options, the key in safari_press_key, the file name in safari_upload_file and safari_paste_image, and the first line of the text in safari_replace_editor.

Patches

Fixed in 2.22.15: every affected site uses the shared escJsSingleQuote, which escapes the backslash before the quote, and a test fails the build if a quote-only escape returns.

Workarounds

Upgrade to 2.22.15. There is no configuration workaround: excluding safari_evaluate and safari_run_script from a client's tool list did not prevent the injection.

Credits

Reported privately on 2026-10-09 by Aliaksandr Palei (@fakepooh) under the coordinated-disclosure process in SECURITY.md.

References

Am I affected?

Upload or paste your lockfile. We check every package version in it against OSV.dev, this advisory included, and email you the vulnerable ones with the version that fixes them. Free, and no account needed.

or paste its content

Needed when you paste. package.json and pyproject.toml only have version ranges: use the lockfile next to them.

Only package names and versions are checked; the file itself is not kept. We use your email to send this report and nothing else unless you tick the box above. Privacy policy.

About this data

Source: GitHub Advisory Database via OSV.dev (CC-BY 4.0). Severity comes from the advisory's own rating when it has one, else from its CVSS score.