Vulnerabilities in pkg:npm/@blakeembrey/template

PACKAGE
Advisory Identifier: GHSA-q765-wm9j-66qj
Advisory Summary

CVE-2024-45390 is a MODERATE (CVSS 7.3) @blakeembrey/template vulnerable to code injection vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting @blakeembrey/template libraries in the npm ecosystem. The issue involves @blakeembrey/template vulnerable to code injection when attacker controls template input. Remediation is available by upgrading affected packages to version 1.2.0.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/@blakeembrey/template

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/@blakeembrey/template. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-q765-wm9j-66qj CVE-2024-45390 MODERATE @blakeembrey/template vulnerable to code injection when attacker controls template input

CVE-2024-45390 at a Glance

CVE Identifier CVE-2024-45390
GHSA Identifier GHSA-q765-wm9j-66qj
Severity MODERATE
CVSS v3.1 Base Score 7.3
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product @blakeembrey/template
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.3

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:L/I:L/A:L).

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 Low (C:L)
Integrity Low (I:L)
Availability Low (A:L)

How to Fix CVE-2024-45390

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

@blakeembrey/template fixed: 1.2.0
npm install @blakeembrey/template@1.2.0
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 @blakeembrey/template

How to Check if You Are Affected

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

npm ls @blakeembrey/template

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

Note: The npm ls @blakeembrey/template 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 @blakeembrey/template, 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

### Impact It is possible to inject and run code within the template if the attacker has access to write the template name. ```js const { template } = require('@blakeembrey/template'); template("Hello {{name}}!", "exploit() {} && ((()=>{ console.log('success'); })()) && function pwned"); ``` ### Patches Upgrade to 1.2.0. ### Workarounds Don't pass untrusted input as the template display name, or don't use the display name feature. ### References Fixed by removing in https://github.com/blakeembrey/js-template/commit/b8d9aa999e464816c6cfb14acd1ad0f5d1e335aa.

CVE-2024-45390 Affected @blakeembrey/template Versions

1 component(s)
Fixed Versions:
1.2.0
Product / Package Ecosystem Affected Versions Fixed Version
@blakeembrey/template
npm
< 1.2.0
1.2.0

References

Frequently Asked Questions

What is CVE-2024-45390?
CVE-2024-45390 is a security vulnerability in @blakeembrey/template involving @blakeembrey/template vulnerable to code injection when attacker controls template input under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which @blakeembrey/template versions are affected?
Affected versions include releases prior to 1.2.0 across affected packages: @blakeembrey/template.
What version fixes CVE-2024-45390?
Upgrading to 1.2.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @blakeembrey/template affected?
Yes, @blakeembrey/template is affected in releases prior to 1.2.0. Upgrade your dependency to 1.2.0 or later.
What is the CVSS score of CVE-2024-45390?
CVE-2024-45390 has a CVSS v3.1 base score of 7.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L.
What CWE is associated with CVE-2024-45390?
CVE-2024-45390 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-2024-45390?
Run the dependency tree command: 'npm ls @blakeembrey/template'. 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-q765-wm9j-66qj",
  "modified" : "2024-11-18T16:27:09Z",
  "published" : "2024-09-03T19:42:25Z",
  "aliases" : [ "CVE-2024-45390" ],
  "summary" : "@blakeembrey/template vulnerable to code injection when attacker controls template input",
  "details" : "### Impact\n\nIt is possible to inject and run code within the template if the attacker has access to write the template name.\n\n```js\nconst { template } = require('@blakeembrey/template');\n\ntemplate(\"Hello {{name}}!\", \"exploit() {} && ((()=>{ console.log('success'); })()) && function pwned\");\n```\n\n### Patches\n\nUpgrade to 1.2.0.\n\n### Workarounds\n\nDon't pass untrusted input as the template display name, or don't use the display name feature.\n\n### References\n\nFixed by removing in https://github.com/blakeembrey/js-template/commit/b8d9aa999e464816c6cfb14acd1ad0f5d1e335aa.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@blakeembrey/template"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.2.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/blakeembrey/js-template/security/advisories/GHSA-q765-wm9j-66qj"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-45390"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/blakeembrey/js-template/commit/b8d9aa999e464816c6cfb14acd1ad0f5d1e335aa"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/blakeembrey/js-template"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-94" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-09-03T19:42:25Z",
    "nvd_published_at" : "2024-09-03T20:15:08Z"
  }
}