fix(provider-utils): prevent unicode escape bypass in secureJsonParse#13079
Merged
fix(provider-utils): prevent unicode escape bypass in secureJsonParse#13079
Conversation
Update regex patterns to detect unicode-escaped variants of __proto__ and constructor keys, matching the upstream fix in fastify/secure-json-parse. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ureJsonParse Align with upstream fastify/secure-json-parse by guarding against node.constructor being null or a non-object before calling hasOwnProperty on it. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
vercel-ai-sdk bot
pushed a commit
that referenced
this pull request
Mar 5, 2026
…#13079) ## Summary - Update `secureJsonParse` regex patterns to detect unicode-escaped variants of `__proto__` and `constructor` keys, preventing prototype pollution bypass - Aligns with the upstream fix in [fastify/secure-json-parse](https://github.com/fastify/secure-json-parse) - Add regression tests for partial and fully unicode-escaped key variants ## Security Resolves VULN-774. The previous regex fast-path only matched literal `"__proto__"` and `"constructor"` strings. Unicode escapes (e.g., `\u005f\u005fproto__`) bypassed the regex gate, skipping the `filter()` safety check, while `JSON.parse` still normalized them into dangerous keys. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
|
✅ Backport PR created: #13083 |
Contributor
|
🚀 Published in:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
secureJsonParseregex patterns to detect unicode-escaped variants of__proto__andconstructorkeys, preventing prototype pollution bypassSecurity
Resolves VULN-774. The previous regex fast-path only matched literal
"__proto__"and"constructor"strings. Unicode escapes (e.g.,\u005f\u005fproto__) bypassed the regex gate, skipping thefilter()safety check, whileJSON.parsestill normalized them into dangerous keys.Test plan
secureJsonParsetests pass__proto__is rejectedconstructoris rejected