Skip to content

fix: Raw JSON.parse used in production provider code (prototype pollution risk) - #16579

Merged
lgrammel merged 2 commits into
mainfrom
bugfix/15812-1
Jul 2, 2026
Merged

fix: Raw JSON.parse used in production provider code (prototype pollution risk)#16579
lgrammel merged 2 commits into
mainfrom
bugfix/15812-1

Conversation

@lgrammel

@lgrammel lgrammel commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Background

Provider code was synchronously parsing LLM/tool/error JSON with raw JSON.parse, bypassing the SDK's prototype-pollution protections.

Summary

Exported secureJsonParse from @ai-sdk/provider-utils and replaced the six reported production JSON.parse call sites in Google, Anthropic, and Gateway code with secureJsonParse while preserving existing try/catch fallback behavior.

Testing

Kept the reproduction regression test that verifies prototype-polluting Google Interactions tool-call input is rejected/falls back instead of being parsed as arguments.

Related Issues

Fixes #15812

@lgrammel
lgrammel merged commit c6f5e62 into main Jul 2, 2026
54 checks passed
@lgrammel
lgrammel deleted the bugfix/15812-1 branch July 2, 2026 14:18
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

🚀 Published in:

Package Version
ai 7.0.12 github npm
@ai-sdk/alibaba 2.0.5 github npm
@ai-sdk/amazon-bedrock 5.0.9 github npm
@ai-sdk/angular 3.0.12 github npm
@ai-sdk/anthropic 4.0.6 github npm
@ai-sdk/assemblyai 3.0.4 github npm
@ai-sdk/azure 4.0.6 github npm
@ai-sdk/baseten 2.0.4 github npm
@ai-sdk/black-forest-labs 2.0.4 github npm
@ai-sdk/bytedance 2.0.5 github npm
@ai-sdk/cerebras 3.0.4 github npm
@ai-sdk/cohere 4.0.4 github npm
@ai-sdk/deepgram 3.0.4 github npm
@ai-sdk/deepinfra 3.0.4 github npm
@ai-sdk/deepseek 3.0.4 github npm
@ai-sdk/elevenlabs 3.0.5 github npm
@ai-sdk/fal 3.0.5 github npm
@ai-sdk/fireworks 3.0.5 github npm
@ai-sdk/gateway 4.0.9 github npm
@ai-sdk/gladia 3.0.4 github npm
@ai-sdk/google 4.0.7 github npm
@ai-sdk/google-vertex 5.0.9 github npm
@ai-sdk/groq 4.0.4 github npm
@ai-sdk/harness 1.0.15 github npm
@ai-sdk/harness-claude-code 1.0.15 github npm
@ai-sdk/harness-codex 1.0.16 github npm
@ai-sdk/harness-deepagents 1.0.14 github npm
@ai-sdk/harness-opencode 1.0.15 github npm
@ai-sdk/harness-pi 1.0.15 github npm
@ai-sdk/huggingface 2.0.4 github npm
@ai-sdk/hume 3.0.4 github npm
@ai-sdk/klingai 4.0.5 github npm
@ai-sdk/langchain 3.0.12 github npm
@ai-sdk/llamaindex 3.0.12 github npm
@ai-sdk/lmnt 3.0.4 github npm
@ai-sdk/luma 3.0.5 github npm
@ai-sdk/mcp 2.0.6 github npm
@ai-sdk/mistral 4.0.4 github npm
@ai-sdk/moonshotai 3.0.6 github npm
@ai-sdk/open-responses 2.0.4 github npm
@ai-sdk/openai 4.0.6 github npm
@ai-sdk/openai-compatible 3.0.4 github npm
@ai-sdk/otel 1.0.12 github npm
@ai-sdk/perplexity 4.0.5 github npm
@ai-sdk/policy-opa 1.0.12 github npm
@ai-sdk/prodia 2.0.5 github npm
@ai-sdk/provider-utils 5.0.4 github npm
@ai-sdk/quiverai 2.0.4 github npm
@ai-sdk/react 4.0.13 github npm
@ai-sdk/replicate 3.0.5 github npm
@ai-sdk/revai 3.0.4 github npm
@ai-sdk/rsc 3.0.12 github npm
@ai-sdk/sandbox-just-bash 1.0.15 github npm
@ai-sdk/sandbox-vercel 1.0.15 github npm
@ai-sdk/svelte 5.0.12 github npm
@ai-sdk/togetherai 3.0.5 github npm
@ai-sdk/tui 1.0.12 github npm
@ai-sdk/valibot 3.0.4 github npm
@ai-sdk/vercel 3.0.4 github npm
@ai-sdk/voyage 2.0.4 github npm
@ai-sdk/vue 4.0.12 github npm
@ai-sdk/workflow 1.0.12 github npm
@ai-sdk/workflow-harness 1.0.15 github npm
@ai-sdk/xai 4.0.5 github npm

gr2m pushed a commit that referenced this pull request Jul 6, 2026
…ype pollution risk) (#16763)

## Background

Provider code was synchronously parsing LLM/tool/error JSON with raw
JSON.parse, bypassing the SDK's prototype-pollution protections.

## Summary

Exported secureJsonParse from @ai-sdk/provider-utils and replaced the
six reported production JSON.parse call sites in Google, Anthropic, and
Gateway code with secureJsonParse while preserving existing try/catch
fallback behavior.

## Testing

Kept the reproduction regression test that verifies prototype-polluting
Google Interactions tool-call input is rejected/falls back instead of
being parsed as arguments.

## Related Issues

Fixes #15812

Backport of #16579
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Raw JSON.parse used in production provider code (prototype pollution risk)

2 participants