CVE-2026-118666: GraphQL Tools: Shared legacy executor routes one subscription's results to a different caller
`buildWSLegacyExecutor` in `@graphql-tools/executor-legacy-ws` shares one WebSocket among all subscriptions and delivers every `DATA` frame to the newest subscriber without checking the operation id. A second caller on the same executor receives the first caller's private subscription results. Versions up to 1.1.35 are affected. Upgrade to 1.1.36.
Published Oct 28, 2026 · Analysis Nov 1, 2026
What an attacker can do
The executor keeps one WebSocket in closure state and assigns the message handler to the socket's single onmessage property inside every subscribe() call. A new subscription overwrites the previous handler. The DATA branch calls observer.next(data.payload) and never compares data.id to the operation id of that subscription.
When one executor instance serves overlapping subscriptions, such as a gateway or stitched schema that builds a remote executor once and reuses it per request, the later caller gets the earlier caller's payloads. The reporter showed {"data":{"victimSecret":"..."}} arriving at the second caller, and with wrapSchema() one user received another's account balance. The first caller receives nothing, so the victim's stream also stops.
The attacker needs no control over the downstream server. They only need to start their own subscription through the same shared executor while the victim's is active, and the results must differ by user for it to be a leak. Setups that build a fresh executor per request, as the in-repo UrlLoader does, are not affected. The report calls the CVSS-affecting factors an attack requirement and high attack complexity.
Who is affected
Affected: @graphql-tools/executor-legacy-ws up to and including 1.1.35. The reporter reproduced the leak on 1.1.33 and 1.1.35. You are exposed if one buildWSLegacyExecutor result serves several users at once, for example in a gateway proxying legacy subscriptions-transport-ws subscriptions.
Check your install:
npm ls @graphql-tools/executor-legacy-ws@graphql-tools/executor-legacy-ws
- Ecosystem
- npm
- Affected
- <= 1.1.35
- Fixed in
- 1.1.36
- Check
npm ls @graphql-tools/executor-legacy-ws
How to fix it
Upgrade to @graphql-tools/executor-legacy-ws 1.1.36:
npm install @graphql-tools/[email protected]In this release each execution gets its own socket, and data, error and complete frames are delivered only when the protocol operation id matches. The changes are in pull request 8480. The sources list no workaround besides the design change: create a new executor for each operation instead of sharing one across users.
How to tell if you were hit
Look for gateway code that builds a legacy WebSocket executor once at startup and calls it for many users. In tests, open two overlapping subscriptions on one executor and check that each iterator gets only its own events. In production, user reports of subscriptions that go silent, or events that reach the wrong account, point to this bug.
Original advisory
From the GitHub Advisory Database (CC BY 4.0).
Cross-tenant subscription data leak in @graphql-tools/executor-legacy-ws: a shared websocket.onmessage is replaced on every subscribe(), and DATA frames are delivered without checking the protocol operation id
Report metadata
| Field | Value | | Package | `@graphql-tools/executor-legacy-ws` (npm, `pkg:npm/%40graphql-tools/executor-legacy-ws`) | | Repository | https://github.com/ardatan/graphql-tools | | Component | `buildWSLegacyExecutor` → the returned executor's `subscribe(observer)` / `websocket.onmessage` handler | | Vulnerability class | Cross-tenant data leak (subscription results delivered to the wrong caller) | | Verified against | Source at `b5d1c36ebb8ed3868260ffee5bbcbb423ad5c1f1` (package version 1.1.33); published npm tarball `1.1.33` with matching source at `d304214db06e8a4ce9cb41138f199e3bc6ed36f2`; the same behaviour also reproduces on the current release `1.1.35` | | API surface | Public documented API (`buildWSLegacyExecutor`) | | Affected in default configuration | Yes — `ensureWebsocket()` reuses an already-`OPEN` socket (`index.ts:35-42`), and the socket has a single mutable `onmessage` property (`index.ts:113`). No single-operation-only restriction is documented, and the return type is the general reusable `DisposableExecutor` (`packages/utils/src/executor.ts:34-57`) |
Affected version range: the range recorded for this finding is <= 1.1.33, but that is understated — the same proof of concept reproduces on 1.1.35, and a byte diff of the built CJS output between 1.1.33 and 1.1.35 shows only one unrelated change (rejectUnauthorized).
Summary
buildWSLegacyExecutor keeps one WebSocket in closure state and installs the message handler by assigning to the socket's single websocket.onmessage property inside subscribe(). Every new subscription therefore overwrites the previous subscriber's handler, and the handler's case LEGACY_WS.DATA branch calls observer.next(data.payload) without ever comparing data.id to the operation id that this subscription created at line 103 and sent with START at line 123. When one executor instance is reused for overlapping subscriptions, the most recent caller receives payloads belonging to the earlier caller, and the earlier caller receives nothing.
In a consuming application, the tainted input is an ordinary, correctly-tagged DATA frame emitted by the legitimate downstream server for the victim's operation. The attacker does not need to control or compromise that server; they only need to be able to start their own subscription through the same shared executor while the victim's subscription is active — the natural shape of a gateway, stitched schema, or any service that builds a remote executor once and reuses it per request.
The surrounding code shows the inconsistency:
packages/loaders/url/src/index.ts:262-295(in-repoUrlLoaderwrapper) → constructs a fresh legacy executor inside each request, so that caller avoids the shared state.buildWSLegacyExecutor's returned executor, reused across callers → unsafe: shared `onmessage` overwritten at line 113, `DATA` dispatched without an id check at lines 145-147.packages/loaders/url/src/index.ts:172-182→ also a production caller of the legacy executor; safe only insofar as the wrapper above rebuilds the executor per request, not because of any check in the executor itself.
Impact
A user of a service that shares one legacy executor receives another user's private GraphQL subscription payloads verbatim, with the victim's authorization context, without ever having been authorized for that operation. The victim is simultaneously starved: their own iterator stops receiving the events they subscribed to, because their handler has been detached.
Without this bug, the attacker's observer would receive only results for their own operation — and in this implementation, no result at all, since their operation is never STARTed after CONNECTION_ACK has already fired. The new capability is therefore reading data the attacker could not otherwise obtain by any request they are permitted to make, plus a denial of the victim's subscription stream.
Scoring note: no CVSS vector was computed for this finding, because exploitability depends on the consuming application's data flow — specifically whether one executor instance is shared across mutually untrusted callers. Consumers that construct a new executor per operation (as the in-repo UrlLoader wrapper does at packages/loaders/url/src/index.ts:262-295) are not affected by the cross-caller leak. The set of affected downstream consumers has not been enumerated: unknown.
Preconditions
- One executor value returned by
buildWSLegacyExecutoris reused rather than constructing a new executor per operation. This is the normal use of anExecutor: the contract is invoked once perExecutionRequest, the code explicitly reuses anOPENsocket, and the returned value holdsSymbol.dispose. - Two subscription iterators overlap on an already-
OPENsocket. The deciding default is inensureWebsocket()(packages/executors/legacy-ws/src/index.ts:35-42), which does not create a second socket when one is open, combined with the single mutablewebsocket.onmessageassignment at line 113. - The attacker can cause their own subscription request to be made through that shared executor while the victim's subscription is active and acknowledged. They do not need any control over the downstream server.
- Downstream subscription results differ by user or authorization context, so a misrouted payload is actually a disclosure.
This does not require non-standard usage, monkey-patching, or unusual configuration. packages/executors/legacy-ws/src/index.ts documents no single-operation-only restriction, the return type is the general reusable DisposableExecutor (packages/utils/src/executor.ts:34-57), and the behaviour is not documented as a caller responsibility.
Data flow
- Source — a legitimate
DATAmessage emitted by the downstream server for *another* operation on the shared WebSocket. The victim invokes the returned executor, andsubscribe()installs a closure over the victim's observer and request aswebsocket.onmessage(`packages/executors/legacy-ws/src/index.ts:90-113`). - Propagation — the server's
CONNECTION_ACKstarts the victim's operation withid, created at line 103 and sent withSTARTat line 123 (`packages/executors/legacy-ws/src/index.ts:116-135`). - Sink — the attacker invokes the same executor while
websocket.readyStateisOPEN;ensureWebsocket()does not create a new socket andsubscribe()replaces the solewebsocket.onmessagewith the attacker's closure (`index.ts:35-42`, `index.ts:109-113`). The server'sDATAframe for the victim carries the victim's operation id per the legacy protocol, but the handler ignoresdata.idand callsobserver.next(data.payload)on the attacker's observer (`index.ts:114-147`). - Reachability — the sink sits in the only
subscribepath of the executor produced by the directly exportedbuildWSLegacyExecutor(`index.ts:27-31`).packages/loaders/url/src/index.ts:172-182is a production caller in this repository; direct library consumers reach it by building a remote executor once and reusing it.
Vulnerable code
packages/executors/legacy-ws/src/index.ts, lines 103-167 at b5d1c36ebb8ed3868260ffee5bbcbb423ad5c1f1:
const id = Date.now().toString();
return observableToAsyncIterable({
subscribe(observer) {
ensureWebsocket();
...
websocket.onmessage = event => { // sole handler: overwritten by every new subscribe()
const data = JSON.parse(event.data.toString('utf-8'));
switch (data.type) {
...
case LEGACY_WS.DATA: {
observer.next(data.payload); // SINK: data.id is never compared with id
break;
}
}
};
},
});Two independent defects are visible here: the single mutable onmessage assignment (which detaches the earlier subscriber), and the missing data.id === id check in the DATA branch (which misroutes the payload). The operation id itself is also derived from Date.now(), so it is not collision-resistant.
Reproduction
Verified dynamically against the real published package @graphql-tools/[email protected] (npm tarball with matching source at d304214db06e8a4ce9cb41138f199e3bc6ed36f2). The harness was a protocol-correct legacy graphql-ws server (ws v8) that tags every DATA frame with the operation id of the operation that produced it, plus two callers sharing one executor instance.
- Scenario A (control, single subscription): the subscriber received its own payload, confirming the harness is sound.
- Scenario B (the claim): caller 1 ("victim") subscribed; the server ACKed and the client sent
start id=1790247741390. Caller 2 ("attacker") then invoked the same executor whilereadyStatewasOPEN. The server observed only one socket (ensureWebsocketreused it) and only one started operation — the attacker's operation was never started, becauseCONNECTION_ACKhad already fired. The server then emitted a correctly-taggedDATAframe for the victim's id. The attacker's iterator received{"data":{"victimSecret":"VICTIM-PRIVATE-DATA-a1b2c3"}}and the victim's iterator received nothing. - Scenario C: a
DATAframe tagged with the id"id-that-was-never-started"was still delivered to the subscriber, proving the protocol operation id is never validated. - Realistic wiring: with the executor wired into
wrapSchema()the way a stitching gateway does, two concurrent users subscribing to the same field produced a verbatim cross-tenant leak — User B received{"data":{"accountBalance":"USER-A-PRIVATE-BALANCE-$91402.11"}}while User A received nothing. When the two users select different fields, the wrap layer's result transform masks the foreign field (B sawweather:null), but the misrouting still occurs and the victim is still starved; at the raw executor API the payload leaks verbatim regardless. - Causality control: patching only the
DATAbranch to checkdata.id === ideliminated the leak (the attacker received nothing, and the foreign-id frame was rejected), pinning the leak to the missing id check. Under that patch the victim still received nothing, confirming the second, independent defect: the single sharedwebsocket.onmessageis overwritten on eachsubscribe(), detaching the earlier subscriber's handler entirely. - Scope caveat: the identical proof of concept also reproduces on the current latest release
1.1.35.
Minimal client-side shape:
import WebSocket from 'isomorphic-ws';
import { parse } from 'graphql';
import { buildWSLegacyExecutor } from '@graphql-tools/executor-legacy-ws';
const exec = buildWSLegacyExecutor('ws://localhost:8081/graphql', WebSocket);
const victim = exec({ document: parse('subscription { privateEvent { secret } }') });
const victimPending = victim.next(); // causes connection + START; wait until the server has ACKed
await new Promise(r => setTimeout(r, 100));
const attacker = exec({ document: parse('subscription { publicEvent { id } }') });
const attackerPending = attacker.next(); // overwrites socket.onmessage
// When the server now emits DATA for the victim's id, this prints the victim's secret.
console.log(await attackerPending);Steps:
- Start a normal legacy
subscriptions-transport-wsserver with a private event subscription. - Build one executor and call
victimIterator.next()so the socket receivesconnection_ackandSTARTfor the victim. - While that socket is
OPEN, callattackerIterator.next()using the same executor. - Emit one victim event from the server.
- Expected: a
DATAframe is delivered only to the observer registered fordata.id; the attacker's pendingnext()must never resolve with the victim's payload, and the victim keeps receiving their own events. - Actual: the attacker's
next()resolves with the victim's payload, and the victim's iterator receives nothing.
Suggested remediation
Dispatch protocol frames by operation id to the observer that started that operation, instead of routing every frame to whichever subscriber most recently overwrote the socket's sole onmessage handler.
// 1. Stop the misrouting: ignore frames that belong to another operation.
case LEGACY_WS.DATA: {
if (data.id !== id) {
break;
}
observer.next(data.payload);
break;
}// 2. Stop the handler overwrite: keep a registry of observers keyed by operation id
// and install exactly one shared message listener for the socket.
const observers = new Map<string, Observer<any>>();
function ensureMessageHandler() {
if (messageHandlerInstalled) return;
messageHandlerInstalled = true;
websocket.onmessage = event => {
const data = JSON.parse(event.data.toString('utf-8'));
const target = data.id != null ? observers.get(data.id) : undefined;
// ... dispatch DATA / ERROR / COMPLETE to `target` only, and remove it on COMPLETE
};
}An alternative that keeps the current structure is to create a separate socket (and therefore a separate listener) per execution, as the in-repo UrlLoader wrapper effectively does today.
Notes:
- The same id check is needed on the
ERRORandCOMPLETEbranches, not justDATA; otherwise one operation's termination still tears down another's iterator. - The operation id is generated as
Date.now().toString()(line 103), which is not collision-resistant — two subscriptions created in the same millisecond would share an id even after the dispatch fix. Use a counter or a random component. - The missing id check and the overwritten
onmessageare two independent defects; fixing only the id check stops the leak but leaves the earlier subscriber permanently starved, as the causality control above showed. packages/loaders/url/src/index.ts:262-295already builds a fresh legacy executor inside each request, so that caller needs no change; the fix belongs in the executor itself, because the exportedbuildWSLegacyExecutorreturns a general reusableDisposableExecutor.- No upstream advisory (CVE/GHSA), fix commit, or fixed version is known for this issue: unknown / not verified. The set of affected downstream consumers has likewise not been enumerated.
Suggested regression test alongside the existing packages/executors/legacy-ws test suite: with one executor shared by two overlapping subscriptions on an OPEN socket, assert that a DATA frame tagged with subscription A's operation id resolves only A's iterator and never B's, and that a DATA frame tagged with an id that was never started is dropped rather than delivered to the most recent subscriber.
Resolution
Fixed in @graphql-tools/[email protected], which is published on npm. Each execution has its own socket, and data, error, and complete frames are delivered only when the protocol operation id matches. Upgrade to >=1.1.36.
Questions
- Is every user of executor-legacy-ws affected?
No. The cross-caller leak needs one executor shared by mutually untrusted callers with overlapping subscriptions. Code that creates a new executor per operation avoids it.
- Does 1.1.35 contain the fix?
No. The reporter reproduced the leak on 1.1.35. The fix is 1.1.36.
- Does the attacker have to compromise the GraphQL server?
No. The leaked frames are normal, correctly tagged
DATAframes sent by the legitimate server for the victim's operation. The client library routes them to the wrong subscriber.
References
How this page is made: the data panel comes from the GitHub Advisory Database, CISA’s KEV catalog, the NVD and FIRST EPSS, and updates twice a day. The analysis is written by an AI model from the sources listed above and checked by automated rules before it is published. Check versions against the vendor's advisory before you act. Methodology
