CVE-2021-23358: Underscore Arbitrary Code Execution Vulnerability

CRITICAL
Advisory Identifier: GHSA-cf4h-3jhx-xvhq
CVSS 9.8
CWE-94
Published
Advisory Summary

CVE-2021-23358 is a CRITICAL (CVSS 9.8) arbitrary code execution vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Underscore libraries in the npm ecosystem. The issue involves arbitrary code execution in underscore. Remediation is available by upgrading affected packages to version 1.12.1.

CVE-2021-23358 at a Glance

CVE Identifier CVE-2021-23358
GHSA Identifier GHSA-cf4h-3jhx-xvhq
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Underscore
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 9.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2021-23358

To remediate this vulnerability, upgrade all affected Underscore dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

underscore fixed: 1.12.1
npm install underscore@1.12.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls underscore

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2021-23358, inspect your project dependencies using npm:

npm ls underscore

Analyze the terminal output to locate any version of Underscore in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.12.1), your application is affected.

Note: The npm ls underscore command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-94: Improper Control of Generation of Code ('Code Injection'), where the product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment. In Underscore, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

The package `underscore` from 1.13.0-0 and before 1.13.0-2, from 1.3.2 and before 1.12.1 are vulnerable to Arbitrary Code Execution via the template function, particularly when a variable property is passed as an argument as it is not sanitized.

CVE-2021-23358 Affected Underscore Versions

1 component(s)
Fixed Versions:
1.12.1
Product / Package Ecosystem Affected Versions Fixed Version
underscore
npm
≥ 1.3.2
< 1.12.1
1.12.1

References

NVD — CVE-2021-23358 NVD
https://nvd.nist.gov/vuln/detail/CVE-2021-23358
Underscore Source Repository REPOSITORY
https://github.com/jashkenas/underscore/pull/2917
Security Fix Commit FIX COMMIT
https://github.com/jashkenas/underscore/commit/4c73526d43838ad6ab43a6134728776632adeb66
Underscore Security Information SECURITY
https://www.tenable.com/security/tns-2021-14
www.npmjs.com/package/underscore WEB
https://www.npmjs.com/package/underscore
Underscore Security Information SECURITY
https://www.debian.org/security/2021/dsa-4883
snyk.io/vuln/snyk-js-unders... WEB
https://snyk.io/vuln/SNYK-JS-UNDERSCORE-1080984
snyk.io/vuln/snyk-java-orgw... WEB
https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSNPM-1081503
snyk.io/vuln/snyk-java-orgw... WEB
https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSBOWERGITHUBJASHKENAS-1081505
snyk.io/vuln/snyk-java-orgw... WEB
https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSBOWER-1081504
Underscore Security Information SECURITY
https://security.netapp.com/advisory/ntap-20241108-0002
Underscore Security Information SECURITY
https://security.netapp.com/advisory/ntap-20240808-0003
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/FGEE7U4Z655A2MK5EW4UQQZ7B64XJWBV
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/EOKATXXETD2PF3OR36Q5PD2VSVAR6J5Z
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/FGEE7U4Z655A2MK5EW4UQQZ7B64XJWBV
lists.fedoraproject.org/archives/list/packa... WEB
https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/EOKATXXETD2PF3OR36Q5PD2VSVAR6J5Z
lists.debian.org/debian-lts-announce... WEB
https://lists.debian.org/debian-lts-announce/2021/03/msg00038.html
lists.apache.org/thread.html/re69ee4... WEB
https://lists.apache.org/thread.html/re69ee408b3983b43e9c4a82a9a17cbbf8681bb91a4b61b46f365aeaf@%3Cissues.cordova.apache.org%3E
lists.apache.org/thread.html/re69ee4... WEB
https://lists.apache.org/thread.html/re69ee408b3983b43e9c4a82a9a17cbbf8681bb91a4b61b46f365aeaf%40%3Cissues.cordova.apache.org%3E
lists.apache.org/thread.html/rbc8492... WEB
https://lists.apache.org/thread.html/rbc84926bacd377503a3f5c37b923c1931f9d343754488d94e6f08039@%3Cissues.cordova.apache.org%3E
lists.apache.org/thread.html/rbc8492... WEB
https://lists.apache.org/thread.html/rbc84926bacd377503a3f5c37b923c1931f9d343754488d94e6f08039%40%3Cissues.cordova.apache.org%3E
lists.apache.org/thread.html/raae088... WEB
https://lists.apache.org/thread.html/raae088abdfa4fbd84e1d19d7a7ffe52bf8e426b83e6599ea9a734dba@%3Cissues.cordova.apache.org%3E
lists.apache.org/thread.html/raae088... WEB
https://lists.apache.org/thread.html/raae088abdfa4fbd84e1d19d7a7ffe52bf8e426b83e6599ea9a734dba%40%3Cissues.cordova.apache.org%3E
lists.apache.org/thread.html/r770f91... WEB
https://lists.apache.org/thread.html/r770f910653772317b117ab4472b0a32c266ee4abbafda28b8a6f9306@%3Cissues.cordova.apache.org%3E
lists.apache.org/thread.html/r770f91... WEB
https://lists.apache.org/thread.html/r770f910653772317b117ab4472b0a32c266ee4abbafda28b8a6f9306%40%3Cissues.cordova.apache.org%3E
lists.apache.org/thread.html/r5df90c... WEB
https://lists.apache.org/thread.html/r5df90c46f7000c4aab246e947f62361ecfb849c5a553dcdb0ef545e1@%3Cissues.cordova.apache.org%3E
lists.apache.org/thread.html/r5df90c... WEB
https://lists.apache.org/thread.html/r5df90c46f7000c4aab246e947f62361ecfb849c5a553dcdb0ef545e1%40%3Cissues.cordova.apache.org%3E
Underscore Release RELEASE
https://github.com/jashkenas/underscore/releases/tag/1.12.1
Underscore Source Repository REPOSITORY
https://github.com/jashkenas/underscore/blob/master/modules/template.js%23L71
Underscore Source Repository REPOSITORY
https://github.com/jashkenas/underscore
seclists.org/fulldisclosure/2025... WEB
http://seclists.org/fulldisclosure/2025/Apr/14

Frequently Asked Questions

What is CVE-2021-23358?
CVE-2021-23358 is a security vulnerability in Underscore involving Arbitrary Code Execution in underscore under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Underscore versions are affected?
Affected versions include releases prior to 1.12.1 across affected packages: underscore.
What version fixes CVE-2021-23358?
Upgrading to 1.12.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is underscore affected?
Yes, underscore is affected in releases prior to 1.12.1. Upgrade your dependency to 1.12.1 or later.
What is the CVSS score of CVE-2021-23358?
CVE-2021-23358 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2021-23358?
CVE-2021-23358 is classified under CWE-94: Improper Control of Generation of Code ('Code Injection') (The product constructs all or part of a code segment using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the syntax or behavior of the intended code segment.).
How can I check npm dependencies for CVE-2021-23358?
Run the dependency tree command: 'npm ls underscore'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-cf4h-3jhx-xvhq",
  "modified" : "2025-11-04T16:33:59Z",
  "published" : "2021-05-06T16:09:43Z",
  "aliases" : [ "CVE-2021-23358" ],
  "summary" : "Arbitrary Code Execution in underscore",
  "details" : "The package `underscore` from 1.13.0-0 and before 1.13.0-2, from 1.3.2 and before 1.12.1 are vulnerable to Arbitrary Code Execution via the template function, particularly when a variable property is passed as an argument as it is not sanitized.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "underscore"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.3.2"
      }, {
        "fixed" : "1.12.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-23358"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jashkenas/underscore/pull/2917"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jashkenas/underscore/commit/4c73526d43838ad6ab43a6134728776632adeb66"
  }, {
    "type" : "WEB",
    "url" : "https://www.tenable.com/security/tns-2021-14"
  }, {
    "type" : "WEB",
    "url" : "https://www.npmjs.com/package/underscore"
  }, {
    "type" : "WEB",
    "url" : "https://www.debian.org/security/2021/dsa-4883"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JS-UNDERSCORE-1080984"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSNPM-1081503"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSBOWERGITHUBJASHKENAS-1081505"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-JAVA-ORGWEBJARSBOWER-1081504"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20241108-0002"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20240808-0003"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/FGEE7U4Z655A2MK5EW4UQQZ7B64XJWBV"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/EOKATXXETD2PF3OR36Q5PD2VSVAR6J5Z"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/FGEE7U4Z655A2MK5EW4UQQZ7B64XJWBV"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/EOKATXXETD2PF3OR36Q5PD2VSVAR6J5Z"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2021/03/msg00038.html"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/re69ee408b3983b43e9c4a82a9a17cbbf8681bb91a4b61b46f365aeaf@%3Cissues.cordova.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/re69ee408b3983b43e9c4a82a9a17cbbf8681bb91a4b61b46f365aeaf%40%3Cissues.cordova.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/rbc84926bacd377503a3f5c37b923c1931f9d343754488d94e6f08039@%3Cissues.cordova.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/rbc84926bacd377503a3f5c37b923c1931f9d343754488d94e6f08039%40%3Cissues.cordova.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/raae088abdfa4fbd84e1d19d7a7ffe52bf8e426b83e6599ea9a734dba@%3Cissues.cordova.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/raae088abdfa4fbd84e1d19d7a7ffe52bf8e426b83e6599ea9a734dba%40%3Cissues.cordova.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/r770f910653772317b117ab4472b0a32c266ee4abbafda28b8a6f9306@%3Cissues.cordova.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/r770f910653772317b117ab4472b0a32c266ee4abbafda28b8a6f9306%40%3Cissues.cordova.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/r5df90c46f7000c4aab246e947f62361ecfb849c5a553dcdb0ef545e1@%3Cissues.cordova.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://lists.apache.org/thread.html/r5df90c46f7000c4aab246e947f62361ecfb849c5a553dcdb0ef545e1%40%3Cissues.cordova.apache.org%3E"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jashkenas/underscore/releases/tag/1.12.1"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/jashkenas/underscore/blob/master/modules/template.js%23L71"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/jashkenas/underscore"
  }, {
    "type" : "WEB",
    "url" : "http://seclists.org/fulldisclosure/2025/Apr/14"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-03-31T21:59:00Z",
    "nvd_published_at" : "2021-03-29T14:15:00Z"
  }
}