CVE-2022-0764: Strapi Command Injection Vulnerability

MODERATE
Advisory Identifier: GHSA-xrjf-phvv-r4vr
CVSS 6.1
CWE-78 CWE-77
Published
Advisory Summary

CVE-2022-0764 is a MODERATE (CVSS 6.1) command injection vulnerability (CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')) affecting Strapi libraries in the npm ecosystem. The issue involves command injection in strapi. Remediation is available by upgrading affected packages to version 4.1.0.

CVE-2022-0764 at a Glance

CVE Identifier CVE-2022-0764
GHSA Identifier GHSA-xrjf-phvv-r4vr
Severity MODERATE
CVSS v3.1 Base Score 6.1
CWE Classification CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
Affected Product Strapi
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.1

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

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

How to Fix CVE-2022-0764

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

strapi fixed: 4.1.0
npm install strapi@4.1.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 strapi

How to Check if You Are Affected

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

npm ls strapi

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

Note: The npm ls strapi 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-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where the product constructs all or part of an os command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended os command when it is sent to a downstream component. In Strapi, 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

When creating a strapi app using npxcreate-strapi-app, we can inject arbitrary commands through the template cli argument as per the code in this particular [link](https://github.com/strapi/strapi/blob/master/packages/generators/app/lib/utils/fetch-npm-template.js#L13), this happens due to improper sanitization of user input.

CVE-2022-0764 Affected Strapi Versions

1 component(s)
Fixed Versions:
4.1.0
Product / Package Ecosystem Affected Versions Fixed Version
strapi
npm
< 4.1.0
4.1.0

References

Frequently Asked Questions

What is CVE-2022-0764?
CVE-2022-0764 is a security vulnerability in Strapi involving Command injection in strapi under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
Which Strapi versions are affected?
Affected versions include releases prior to 4.1.0 across affected packages: strapi.
What version fixes CVE-2022-0764?
Upgrading to 4.1.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is strapi affected?
Yes, strapi is affected in releases prior to 4.1.0. Upgrade your dependency to 4.1.0 or later.
What is the CVSS score of CVE-2022-0764?
CVE-2022-0764 has a CVSS v3.1 base score of 6.1 (MODERATE) with vector string CVSS:3.0/AV:L/AC:L/PR:H/UI:R/S:U/C:H/I:H/A:L.
What CWE is associated with CVE-2022-0764?
CVE-2022-0764 is classified under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection') (The product constructs all or part of an OS command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended OS command when it is sent to a downstream component.).
How can I check npm dependencies for CVE-2022-0764?
Run the dependency tree command: 'npm ls strapi'. 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-xrjf-phvv-r4vr",
  "modified" : "2022-03-09T20:26:21Z",
  "published" : "2022-02-27T00:00:15Z",
  "aliases" : [ "CVE-2022-0764" ],
  "summary" : "Command injection in strapi",
  "details" : "When creating a strapi app using npxcreate-strapi-app, we can inject arbitrary commands through the template cli argument as per the code in this particular [link](https://github.com/strapi/strapi/blob/master/packages/generators/app/lib/utils/fetch-npm-template.js#L13), this happens due to improper sanitization of user input.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.0/AV:L/AC:L/PR:H/UI:R/S:U/C:H/I:H/A:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "strapi"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "4.1.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-0764"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/strapi/strapi/issues/12879"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/strapi/strapi/commit/2a3f5e988be6a2c7dae5ac22b9e86d579b462f4c"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/strapi/strapi"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/strapi/strapi/blob/master/packages/generators/app/lib/utils/fetch-npm-template.js#L13"
  }, {
    "type" : "WEB",
    "url" : "https://huntr.dev/bounties/001d1c29-805a-4035-93bb-71a0e81da3e5"
  }, {
    "type" : "WEB",
    "url" : "https://www.github.com/strapi/strapi/commit/2a3f5e988be6a2c7dae5ac22b9e86d579b462f4c"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-77", "CWE-78" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-03-01T21:42:15Z",
    "nvd_published_at" : "2022-02-26T15:15:00Z"
  }
}