fix: avoid prototype-colliding names in execution values#4653
Conversation
|
@abishekgiri is attempting to deploy a commit to the The GraphQL Foundation Team on Vercel. A member of the Team first needs to authorize it. |
|
Status update
|
|
This would be a breaking change, and would have to land in v17, but we are considering doing so in: See: #4634 (comment) For background, see:
Note that #1056 does not fully address the problem raised by graphql/express-graphql#177. In particular, while @leebyron gave a prototype to the args map itself, an input object arg still itself has no prototype -- just as ExecutionResult.data and its descendants have no prototype. |
|
Actually @abishekgiri -- on my box the new tests pass even without the suggested code changes. Is there an actual bug in this case (we were considering doing so in the linked PR above just because the re-addition of the prototype didn't seem strictly necessary) |
|
@yaacovCR I dug through this end to end and verified that there is an actual bug here on plain \16.x.x So I do think the bug is real. The harder part is branch compatibility: the current fix changes |
|
Ah, my box duplicates it now as well. I wonder if there would be a 16.x.x compatible fix possible, but agree that the direction of this fix would have to wait until 17.x.x. |
Hmmm. actually, yet again looked closer, what the tests are testing is just the case @leebyron warns about in the changed comment, i.e. these objects have a prototype, and therefore one must be careful to not draw items from the prototype through an |
|
@yaacovCR Makes sense to me. Looking closer, this does seem to match the long-standing 16.x.xcontract that these returned objects have a prototype and consumers need an own-property check when reading from them. In that case, I agree there is not really a16.x.xfix to land here without changing behavior. This seems better tracked asv17 work alongside #4634. |
|
Following up here as well: after tracing the history in #1056 and #4631, I agree this does not look like a safe |
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
869cb7c to
e8ebbee
Compare
|
@abishekgiri I rebased this on 17.x.x and changed the PR base (after merging #4634). This PR now contains your tests and comment changes (as well as a small type change that could have also been in #4634 along with the similar type changes there). Let me know if this looks good and will merge to 17.x.x. |
|
@yaacovCR This looks good to me on 17.x.x. Rebasing it after #4634 makes the direction much clearer, and the current scope also looks right: the regression tests, the updated comments, and the small type change all seem consistent with the null-prototype behavior there. I don’t see anything else I’d want to change on this PR from my side, so I’d be happy with merging it into 17.x.x. |
Summary
Fixes an issue where prototype-colliding property names (e.g.,
__proto__,constructor) could interfere with execution value handling.Changes
Motivation
JavaScript objects can inherit properties from the prototype chain. Without proper checks, this can lead to unexpected behavior when handling execution values.
Testing