Executive brief
The set-in npm package, used to manipulate JavaScript objects, contains a flaw that allows attackers to inject malicious properties into the core JavaScript Object prototype. An attacker can exploit this by crafting inputs that override built-in protection checks, potentially leading to unauthorized access, service disruption, or code execution in any application using this library with untrusted input. The vulnerability affects versions 2.0.1 through 2.0.4.
Technical details
This is a prototype pollution vulnerability in set-in caused by an inadequate check on forbidden keys. The vulnerable code at line 28 uses Array.prototype.includes() to validate whether user-supplied path keys are dangerous (e.g., "constructor", "__proto__"). An attacker can bypass this by overriding Array.prototype.includes to return false, allowing the forbidden key check to pass while still polluting Object.prototype. The attack requires only the ability to supply a crafted path array to the setIn() function; no authentication or user interaction is needed. Successful exploitation allows injection of arbitrary properties into Object.prototype, potentially leading to authentication bypass (if auth logic relies on property checks), denial of service (if the polluted properties cause exceptions), or remote code execution (if the polluted properties flow to dangerous sinks like eval or child_process.spawn). The fix in version 2.0.5 likely uses a more robust method to check forbidden keys that cannot be bypassed via prototype manipulation.
Affected products
- ahdinosaur set-in >=2.0.1, <2.0.5
Timeline
- 2026-02-11: disclosed: GHSA-2c4m-g7rx-63q7 published
- 2026-02-11: patched: Fixed in version 2.0.5
References
- https://github.com/ahdinosaur/set-in/security/advisories/GHSA-2c4m-g7rx-63q7
- https://github.com/ahdinosaur/set-in/pull/6
- https://github.com/ahdinosaur/set-in/commit/34842cc02de3fd65d6f8bd0b268347e7b390125b
- https://github.com/ahdinosaur/set-in/commit/6bad255961d379e4b1f5fbc52ef9dc8420816f24
- https://github.com/ahdinosaur/set-in/commit/b8e1dabfdbd35c8d604b6324e01d03f280256c3d
- https://github.com/ahdinosaur/set-in/commit/d87c1a09fa2edb55cd76440a67d83d1cb828df11