VYPR
High severity7.5NVD Advisory· Published Apr 6, 2026· Updated Apr 27, 2026

CVE-2026-35209

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.

PackageAffected versionsPatched versions
defunpm
< 6.1.56.1.5

Affected products

1
  • cpe:2.3:a:unjs:defu:*:*:*:*:*:node.js:*:*
    Range: <6.1.5

Patches

1
3942bfbbcaa7

fix: prevent prototype pollution via `__proto__` in defaults (#156)

https://github.com/unjs/defuKricsleoApr 1, 2026via ghsa
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

News mentions

0

No linked articles in our index yet.