CVE-2018-16487: Prototype Pollution in lodash

lodash Updated 02 Oct 2025

Summary

07/02/2019
Yes i
High
Not published

CVE-2018-16487: Prototype Pollution in lodash. Affects lodash versions < 4.17.11. Fixed in 4.17.11. How to fix ↓

Also tracked for

The same CVE-2018-16487 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

Background

lodash is a popular JavaScript utility library that provides helpful functions for manipulating and working with arrays, objects, and other data types. It is widely used in various applications and frameworks. However, versions of lodash before 4.17.5 are vulnerable to prototype pollution.

Vulnerability Detail

Prototype pollution is a vulnerability that allows an attacker to modify the prototype of an object, leading to unexpected behavior and potential security issues. In the case of lodash, the vulnerable functions 'defaultsDeep', 'merge', and 'mergeWith' can be exploited by a malicious user to modify the prototype of the Object constructor. By passing a payload like {constructor: {prototype: {...}}}, the attacker can add or modify properties that will exist on all objects, potentially leading to code execution or privilege escalation.

How To Fix

Latest published version: 4.18.1 as of 22 Oct 2026

npm install lodash@4.18.1

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

4.17.11

This is the first release that contains the fix.

npm install lodash@4.17.11

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

If updating lodash is not immediately feasible, a possible workaround is to sanitize and validate any user input or data before using the vulnerable functions. By carefully validating and sanitizing the input, the risk of prototype pollution can be mitigated. Here's an example of how to sanitize user input in Node.js:

const _ = require('lodash');

function sanitizeInput(input) {
  if (typeof input === 'object' && !Array.isArray(input)) {
    // Sanitize the input object
    return _.pickBy(input, (value, key) => typeof value === 'string');
  }

  // Return the input as is
  return input;
}

const userPayload = { constructor: { prototype: { isAdmin: true } } };
const sanitizedPayload = sanitizeInput(userPayload);

// Use the sanitized payload with the vulnerable lodash function
_.merge({}, sanitizedPayload);

Conclusion

Prototype pollution in lodash versions prior to 4.17.5 can lead to serious security issues. It is crucial to update to version 4.17.11 or later to mitigate the vulnerability. If immediate update is not possible, carefully sanitize and validate user input before using the vulnerable functions. For further assistance and support in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for lodash →

Share this vulnerability

FAQ

Prototype pollution is a vulnerability that allows an attacker to modify the prototype of an object, leading to unexpected behavior and potential security issues. It can be exploited to add or modify properties that will exist on all objects.

Versions of lodash before 4.17.5 are vulnerable to prototype pollution. It is recommended to update to version 4.17.11 or later to fix the issue.

Exploiting this vulnerability can lead to code execution, privilege escalation, or unexpected behavior in applications that use the vulnerable lodash functions.

If updating lodash is not immediately feasible, a workaround is to carefully sanitize and validate user input or data before using the vulnerable functions. This can help mitigate the risk of prototype pollution.

Related vulnerabilities

Recent vulnerabilities recorded for lodash.

Sponsored Lume, the Habilume companion Habilume Habit tracker with a companion that grows with you Complete habits, earn Lume Points, and watch your Lume grow as you stay consistent. App Store Google Play

How To Fix

Latest published version: 4.18.1 as of 22 Oct 2026

npm install lodash@4.18.1

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

4.17.11

This is the first release that contains the fix.

npm install lodash@4.17.11

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback