MEDIUM · CVSS 4.0 CWE-116CWE-94

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

Published 2026-11-19 · Updated 2026-11-19

Summary

The safari-mcp package contains an improper neutralization of input during web page code generation, allowing for arbitrary JavaScript injection via specially crafted tool arguments. Users must upgrade to version 2.22.15 to mitigate this vulnerability.

Who is affected

The vulnerability affects 16 arguments across multiple Safari MCP tools, where improper escaping of backslashes allows an attacker to break out of single-quoted string literals. Notably, several read-only tools are affected, meaning even clients restricted from running arbitrary scripts can still execute code within the context of a browser tab.

Exploitability

The vulnerability is rated as Medium severity, requiring local access with low attack complexity and no user interaction. According to the CVSS 4.0 vector, it poses a high risk to system confidentiality and integrity, though CISA KEV data indicates no evidence of active exploitation.

Remediation

How to check your project

Automated analysis of the published advisory data, generated 2026-11-19. Not human-reviewed; verify against the official advisory. How this works.

Affected packages

EcosystemPackageAffected versionsFixed inUpgrade
npm safari-mcp >= 0, < 2.22.15 2.22.15 npm install [email protected]

CVSS 4.0 vector

CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:N/VI:N/VA:N/SC:H/SI:H/SA:N

Attack vectorLocal
Attack complexityLow
Attack requirementsNone
Privileges requiredLow
User interactionNone
Confidentiality (vulnerable system)None
Integrity (vulnerable system)None
Availability (vulnerable system)None
Confidentiality (subsequent systems)High
Integrity (subsequent systems)High
Availability (subsequent systems)None

Base score is not computed for CVSS 4.0 vectors; severity is taken from the advisory.

FAQ

Can I mitigate this by excluding sensitive tools from my allowlist?

No. The vulnerability affects several read-only tools, meaning even if you restrict tools like safari_evaluate, the injection can still be triggered via other affected parameters.

Is this vulnerability actively being exploited in the wild?

There is no evidence of active exploitation; CISA KEV status is reported as no.

What specifically caused the injection?

The flaw was caused by failing to escape backslashes before escaping single quotes when placing tool arguments into JavaScript string literals, allowing an attacker to escape the literal context.

Original advisory description
### 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

Source records: GHSA-4rj4-rcrq-gr92 (OSV.dev).