CVE-2026-35209
Description
defu is software that allows uers to assign default properties recursively. Prior to version 6.1.5, applications that pass unsanitized user input (e.g. parsed JSON request bodies, database records, or config files from untrusted sources) as the first argument to defu() are vulnerable to prototype pollution. A crafted payload containing a __proto__ key can override intended default values in the merged resul. The internal _defu function used Object.assign({}, defaults) to copy the defaults object. Object.assign invokes the __proto__ setter, which replaces the resulting object's [[Prototype]] with attacker-controlled values. Properties inherited from the polluted prototype then bypass the existing __proto__ key guard in the for...in loop and land in the final result. Version 6.1.5 replaces Object.assign({}, defaults) with object spread ({ ...defaults }), which uses [[DefineOwnProperty]] and does not invoke the __proto__ setter.
Affected packages
Versions sourced from the GitHub Security Advisory.
| Package | Affected versions | Patched versions |
|---|---|---|
defunpm | < 6.1.5 | 6.1.5 |
Affected products
1Patches
13942bfbbcaa7fix: prevent prototype pollution via `__proto__` in defaults (#156)
2 files changed · +7 −1
src/defu.ts+1 −1 modified@@ -7,7 +7,7 @@ function _defu<T>(baseObject: T, defaults: any, namespace = ".", merger?: Merger return _defu(baseObject, {}, namespace, merger); } - const object = Object.assign({}, defaults); + const object = { ...defaults }; for (const key in baseObject) { if (key === "__proto__" || key === "constructor") {
test/defu.test.ts+6 −0 modified@@ -106,6 +106,12 @@ describe("defu", () => { defu({}, payload); defu(payload, {}); defu(payload, payload); + + const malicious = JSON.parse('{"__proto__":{"isAdmin":true}}'); + const result = defu(malicious, { isAdmin: false }); + + expect(result.isAdmin).toBe(false); + // @ts-ignore expect({}.isAdmin).toBe(undefined); });
Vulnerability mechanics
Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
6- github.com/unjs/defu/commit/3942bfbbcaa72084bd4284846c83bd61ed7c8b29nvdPatchWEB
- github.com/unjs/defu/pull/156nvdIssue TrackingPatchWEB
- github.com/advisories/GHSA-737v-mqg7-c878ghsaADVISORY
- github.com/unjs/defu/security/advisories/GHSA-737v-mqg7-c878nvdMitigationVendor AdvisoryWEB
- nvd.nist.gov/vuln/detail/CVE-2026-35209ghsaADVISORY
- github.com/unjs/defu/releases/tag/v6.1.5nvdRelease NotesWEB
News mentions
0No linked articles in our index yet.