Command Injection Vulnerability in Lodash Package: CVE-2021-23337

node-lodash Updated 02 Oct 2025

Summary

15/02/2021
N/A
Yes i
High
7.2

CVE-2021-23337: Lodash versions prior to 4.17.21 are vulnerable to Command Injection via the template function. Affects node-lodash across 2 version ranges.

< 4.17.21+dfsg+~cs8.31.173-1 < c6e281b878b315c7a10d90f9c2af4cdb112d9625

Fixed in 4.17.21+dfsg+~cs8.31.173-1. How to fix ↓

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

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Mobile apps built by Devnack Design, build and launch iOS and Android apps with a senior product team. From idea to store release Start a project

Background

Lodash is a popular JavaScript utility library that provides modularity, performance, and extras for JavaScript applications. It simplifies common programming tasks such as manipulating arrays, objects, and strings. However, versions prior to 4.17.21 are susceptible to a command injection vulnerability through its template function, which can lead to severe security risks if exploited.

Vulnerability Detail

The vulnerability, identified as CVE-2021-23337, arises from the way Lodash handles user input in its template function. Attackers can exploit this flaw to execute arbitrary commands on the server, potentially leading to unauthorized access, data breaches, or system compromise. The vulnerability affects all versions of Lodash prior to 4.17.21, making it critical for users to update to a secure version to mitigate risks.

How To Fix

Minimum fixed version

4.17.21+dfsg+~cs8.31.173-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade node-lodash

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

Workaround

If immediate upgrading is not feasible, consider sanitizing user inputs before passing them to the Lodash template function. This can help mitigate the risk of command injection. For example:

const _ = require('lodash');

function safeTemplate(templateString, data) {
    // Sanitize inputs here
    return _.template(templateString)(data);
}

Conclusion

CVE-2021-23337 represents a significant security risk for applications using vulnerable versions of Lodash. It is crucial for developers to upgrade to version 4.17.21 or later to protect their applications from potential command injection attacks. Implementing input sanitization can serve as a temporary measure while transitioning to a secure version.

See every vulnerability recorded for node-lodash →

Share this vulnerability

FAQ

CVE-2021-23337 is a command injection vulnerability found in Lodash versions prior to 4.17.21, which can allow attackers to execute arbitrary commands.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

The CVSS score for CVE-2021-23337 is 7.2, indicating a high severity level.

If you cannot upgrade immediately, implement input sanitization as a temporary workaround to reduce the risk of exploitation.

You can find more information about Lodash and its features on its official GitHub repository at https://github.com/lodash/lodash.

Related vulnerabilities

Recent vulnerabilities recorded for node-lodash.

How To Fix

Minimum fixed version

4.17.21+dfsg+~cs8.31.173-1

This is the first release that contains the fix.

sudo apt-get install --only-upgrade node-lodash

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