Lodash Path Resolution Vulnerabilities and Fixes

Lodash is one of the most widely used utility libraries in the JavaScript ecosystem, but its deep object manipulation functions historically harbored significant prototype pollution vulnerabilities. These flaws stemmed from how internal path resolution utilities parsed object keys and property paths without properly validating dangerous accessors like __proto__ and constructor.prototype. Over several major releases, the Lodash maintainers implemented native internal protections within core utilities—such as _.set, _.merge, and _.defaultsDeep—to sanitize path traversal, block unauthorized prototype access, and prevent property injection into the global object scope.

The Mechanics of Path Resolution Vulnerabilities

In JavaScript, objects inherit properties from Object.prototype. When a library recursively creates or updates nested structures based on user-supplied paths (e.g., 'a.b.c' or ['a', 'b', 'c']), it must resolve each segment step-by-step.

Prior to major security patches, Lodash did not adequately sanitize segments matching special object properties. Attackers could supply payloads with keys like __proto__ or constructor.prototype. When Lodash functions traversed these segments, the internal traversal logic followed standard JavaScript property access, navigating directly to the global object prototype. Any property assigned at the end of such a path was then added to every object in the JavaScript runtime, causing Prototype Pollution, leading to unexpected behavior, denial of service (DoS), or remote code execution (RCE).

Key Historical CVEs and Affected Utilities

Several high-profile vulnerabilities centered directly on Lodash's object path resolution utilities:

1. CVE-2018-3721 and CVE-2018-16487: _.defaultsDeep and _.merge

2. CVE-2019-10744: _.defaultsDeep via constructor Traversal

3. CVE-2020-8203: _.zipObjectDeep Path Parsing

Native Patch Implementations

The Lodash core team addressed these vulnerabilities by altering the internal functions responsible for object creation, property retrieval, and path traversal: