Skip to content

Prevent accessing response object's prototype chain#3396

Merged
duckki merged 19 commits intomainfrom
duckki/inc-1012
Mar 13, 2026
Merged

Prevent accessing response object's prototype chain#3396
duckki merged 19 commits intomainfrom
duckki/inc-1012

Conversation

@duckki
Copy link
Contributor

@duckki duckki commented Mar 13, 2026

Fixed several code paths that access response objects to prevent JavaScript prototype pollution and unintended access to the prototype chain.

@duckki duckki requested a review from a team as a code owner March 13, 2026 00:08
@apollo-librarian
Copy link

apollo-librarian bot commented Mar 13, 2026

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: b924d4b045256576c6d96c54
Build Logs: View logs


✅ AI Style Review — No Changes Detected

No MDX files were changed in this pull request.

Review Log: View detailed log

This review is AI-generated. Please use common sense when accepting these suggestions, as they may not always be accurate or appropriate for your specific context.

@changeset-bot
Copy link

changeset-bot bot commented Mar 13, 2026

🦋 Changeset detected

Latest commit: 5f9a9b3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@apollo/query-planner Patch
@apollo/federation-internals Patch
@apollo/gateway Patch
@apollo/composition Patch
@apollo/query-graphs Patch
@apollo/subgraph Patch
apollo-federation-integration-testsuite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

sachindshinde and others added 18 commits March 12, 2026 17:19
Currently, when iterating through the `source`'s own properties in `deepMerge()`, we do not check whether the property is also an own property of `target`. This can lead to a bug where the prototype chain of `target` is mistakenly searched for the property, and if found, the data in `source` may then be merged into that non-own property's value, potentially causing issues for other objects that share that prototype chain. In one example, properties being defined in `source` were used to add properties to `Object.prototype`, which is a security issue.

The fix here is to explicitly initialize the property on `target` if it's a non-own property of `target` via `Object.defineProperty()`. With this change, any downstream references to `target[key]` are guaranteed to change the `key` property on `target` instead of some property upstream in the prototype chain. (We can also remove the bit that skips the `__proto__` property, as this results in a bug when a GraphQL field is aliased to this.)

---------

Co-authored-by: Duckki Oe <duckki.oe@apollographql.com>
@duckki duckki merged commit 84e9226 into main Mar 13, 2026
17 of 18 checks passed
@duckki duckki deleted the duckki/inc-1012 branch March 13, 2026 00:39
sachindshinde added a commit that referenced this pull request Mar 13, 2026
…for 2.11) (#3398)

Fixed several code paths that access response objects to prevent
JavaScript prototype pollution and unintended access to the prototype
chain.

---------

Co-authored-by: Sachin D. Shinde <sachin@apollographql.com>
sachindshinde added a commit that referenced this pull request Mar 13, 2026
…for 2.10) (#3399)

Fixed several code paths that access response objects to prevent
JavaScript prototype pollution and unintended access to the prototype
chain.

---------

Co-authored-by: Sachin D. Shinde <sachin@apollographql.com>
sachindshinde added a commit that referenced this pull request Mar 13, 2026
…for 2.12) (#3397)

Fixed several code paths that access response objects to prevent
JavaScript prototype pollution and unintended access to the prototype
chain.

---------

Co-authored-by: Sachin D. Shinde <sachin@apollographql.com>
sachindshinde added a commit that referenced this pull request Mar 13, 2026
…for 2.9) (#3400)

Fixed several code paths that access response objects to prevent
JavaScript prototype pollution and unintended access to the prototype
chain.

---------

Co-authored-by: Sachin D. Shinde <sachin@apollographql.com>
sachindshinde pushed a commit that referenced this pull request Mar 13, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @apollo/composition@2.13.2

### Patch Changes

- Updated dependencies
\[[`84e9226b606b176ede097410f5ba35ba03d140ed`](84e9226)]:
    -   @apollo/federation-internals@2.13.2
    -   @apollo/query-graphs@2.13.2

## @apollo/gateway@2.13.2

### Patch Changes

- Fixed several code paths that access response objects to prevent
JavaScript prototype pollution and unintended access to the prototype
chain. ([#3396](#3396))

See the associated GitHub Advisories
[GHSA-pfjj-6f4p-rvmh](GHSA-pfjj-6f4p-rvmh)
for more information.

- Updated dependencies
\[[`84e9226b606b176ede097410f5ba35ba03d140ed`](84e9226)]:
    -   @apollo/query-planner@2.13.2
    -   @apollo/federation-internals@2.13.2
    -   @apollo/composition@2.13.2

## @apollo/federation-internals@2.13.2

### Patch Changes

- Fixed several code paths that access response objects to prevent
JavaScript prototype pollution and unintended access to the prototype
chain. ([#3396](#3396))

See the associated GitHub Advisories
[GHSA-pfjj-6f4p-rvmh](GHSA-pfjj-6f4p-rvmh)
for more information.

## @apollo/query-graphs@2.13.2

### Patch Changes

- Updated dependencies
\[[`84e9226b606b176ede097410f5ba35ba03d140ed`](84e9226)]:
    -   @apollo/federation-internals@2.13.2

## @apollo/query-planner@2.13.2

### Patch Changes

- Fixed several code paths that access response objects to prevent
JavaScript prototype pollution and unintended access to the prototype
chain. ([#3396](#3396))

See the associated GitHub Advisories
[GHSA-pfjj-6f4p-rvmh](GHSA-pfjj-6f4p-rvmh)
for more information.

- Updated dependencies
\[[`84e9226b606b176ede097410f5ba35ba03d140ed`](84e9226)]:
    -   @apollo/federation-internals@2.13.2
    -   @apollo/query-graphs@2.13.2

## @apollo/subgraph@2.13.2

### Patch Changes

- Updated dependencies
\[[`84e9226b606b176ede097410f5ba35ba03d140ed`](84e9226)]:
    -   @apollo/federation-internals@2.13.2

## apollo-federation-integration-testsuite@2.13.2

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants