-
fix(cli): remove `new Function()` eval from JSON-ish input parsing (#3878)
发布于
2026-07-21 07:14:55 +00:00 This PR:
- removes an in-process arbitrary-code-execution surface:
parse-json-ish.tsfell back toFunction("return (…)")()for any
tools execute --data,listen --params, orproxybody value that
failed JSON and comment-JSON parsing — the CLI is agent-facing and
--dataalso accepts@fileand stdin, so crafted or prompt-injected
input reached the eval - lands the parser in its final consolidated shape:
src/utils/parse-json.tsparses JSON5 (unquoted keys, single quotes,
trailing commas, comments) without evaluating anything and returns
Eitherwith a typedJsonParsingError - consolidates the
effect-errorsread-json duplicates onto the same
parser and swapscomment-jsonforjson5(the stack's only lockfile
change) - pins code-execution probes in unit tests (
new Date(), computed
expressions,globalThiswrites are rejected, never evaluated) - intentional narrowing: JS expressions such as
1+1that only worked
because of the eval now fail with a parse error; proxy bodies that are
not JSON5 records fall back to the raw string
Stack (re-slice of https://github.com/ComposioHQ/composio/pull/3859;
each PR targets its parent and auto-retargets tonextas parents
merge):- https://github.com/ComposioHQ/composio/pull/3877 — guidelines + inert
rule groups - https://github.com/ComposioHQ/composio/pull/3878 —
new Function()
eval security fix ← this PR - https://github.com/ComposioHQ/composio/pull/3879 — behavioral fix
pack - https://github.com/ComposioHQ/composio/pull/3880 — platform-imports
rule + migration - https://github.com/ComposioHQ/composio/pull/3881 — terminal-streams
rule + TerminalUI boundary - https://github.com/ComposioHQ/composio/pull/3882 — descriptor seam +
zod→Schema - https://github.com/ComposioHQ/composio/pull/3883 — test-tree lint +
deterministic suites - https://github.com/ComposioHQ/composio/pull/3884 — typed error
boundaries + v4 seams - https://github.com/ComposioHQ/composio/pull/3885 — try/catch+env ban
- boundary ratchet
On stacked bases CI runs lint/build and the CLI Docker e2e job; unit
tests and typecheck are verified locally per PR and re-verified by full
CI when each PR is retargeted tonext.下载附件
- removes an in-process arbitrary-code-execution surface: