JavaScript injection in safari-mcp via single-quoted tool arguments
Key facts
- Attack vector
- Local
- Privileges required
- Low
- User interaction
- None
- Attack complexity
- Low
- Attack requirements
- None
- Impact type
- Code execution
- Confidentiality · integrity · availability
- None · None · None
- Fix status
- Fixed
Attack profile from CVSS 4.0 · GHSA-4rj4-rcrq-gr92. Fix status from GitHub. Impact type from CWE-94.
Summary
The safari-mcp npm package from 0 before 2.22.15 places tool arguments inside single-quoted JavaScript strings and escapes single quotes without escaping backslashes first. An argument with a backslash before a quote closes the string literal early, so the rest of the argument runs as JavaScript in the page (CWE-94). A local user with low privileges can run arbitrary page JavaScript, including through read-only tools in tabs the session does not own.
Written with Claude Haiku 5.5 from the sources below · 2026-11-19
Description from the GitHub advisory
### 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.
Why it matters now
SSVC decision points
Not available: CISA has not published SSVC decision points for this record.
Affected products
| Vendor | Product | Affected versions | Fixed in | Status | Source |
|---|---|---|---|---|---|
| — | safari-mcp (npm) | before 2.22.15 | 2.22.15 | Patch available | GHSA-4rj4-rcrq-gr92 |
- safari-mcp (npm) Vendor— Affected before 2.22.15 Fixed in 2.22.15 Patch available GHSA-4rj4-rcrq-gr92
Remediation
Upgrade safari-mcp to version 2.22.15, which escapes backslashes before quotes at every affected site.
Written with Claude Haiku 5.5 from the sources below · 2026-11-19
- Fix · GHSA-4rj4-rcrq-gr92 safari-mcp (npm) Fixed in 2.22.15 Advisory →
Timeline
- 2026-11-19 Threatist record created from GHSA-4rj4-rcrq-gr92
References
Other 4
Sources
This product uses the NVD API but is not endorsed or certified by the NVD. Sources and licences