Skip to main content
Menu
Advisories

SDK defaultHeaders mutation can leak API keys across Client instances

GHSA-432W-3H3V-2PV4Published Updated GitHub

Description

The LangGraph JS SDK stores the defaultHeaders object passed to Client by reference and writes the client's x-api-key into it. Clients constructed from the same headers object therefore share one API key, and a later client's key replaces the key sent by earlier clients.

Details

BaseClient assigned config.defaultHeaders directly to its own headers and then set x-api-key on that object, so the caller's object was mutated and shared by every client built from it. A client constructed without an API key (apiKey: null, or no key and no API key environment variable) also sends whichever key another client wrote into the shared object, including to a different apiUrl.

@langchain/langgraph-sdk versions 0.0.7 through 1.12.2 are affected, as is the deprecated 2.0.0 release. Versions 0.0.6 and earlier do not set x-api-key.

RemoteGraph in @langchain/langgraph 0.2.19 and later is also affected when used with a vulnerable SDK version. It passes its headers option to the SDK client as defaultHeaders, and its dependency range permits affected SDK versions.

Impact

An application is affected only if it reuses one defaultHeaders object (or one RemoteGraph headers object) across clients with different API keys, or across clients where one has no API key. In that configuration, requests from one client can be authenticated with another client's API key, which can send operations or data to the wrong account or tenant, or send the key to a different host. An external attacker cannot trigger this without that application configuration.

The LangGraph Platform is not exposed to this issue.

Remediation

Upgrade @langchain/langgraph-sdk to version 1.12.3 or later, and @langchain/langgraph to version 1.4.21 or later, which requires the fixed SDK. The fix copies defaultHeaders when a client is constructed, so the caller's object is never written to. Users of the deprecated 2.0.0 SDK release should move to 1.12.3 or later. Regression tests should assert that clients sharing one headers object keep their own API keys and that the input object is unchanged.

Affected versions

References

GitHub · langchain-ai/langgraphjs