CVE-2022-24065: Cookiecutter OS Command Injection Vulnerability

CRITICAL
Advisory Identifier: GHSA-f4q6-9qm4-h8j4
CVSS 8.1
CWE-78
Published
Advisory Summary

CVE-2022-24065 is a CRITICAL (CVSS 8.1) os command injection vulnerability (CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')) affecting Cookiecutter libraries in the PyPI ecosystem. The issue involves os command injection in cookiecutter. Remediation is available by upgrading affected packages to version 2.1.1.

CVE-2022-24065 at a Glance

CVE Identifier CVE-2022-24065
GHSA Identifier GHSA-f4q6-9qm4-h8j4
Severity CRITICAL
CVSS v3.1 Base Score 8.1
CWE Classification CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection')
Affected Product Cookiecutter
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.1

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

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
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-2022-24065

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

cookiecutter fixed: 2.1.1
pip install cookiecutter>=2.1.1
Verify Direct and Transitive Dependencies

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

pip show cookiecutter

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2022-24065, inspect your installed packages using pip:

pip show cookiecutter

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

Note: The pip show cookiecutter command checks currently installed packages in your active Python environment.

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 Cookiecutter, 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 cookiecutter before 2.1.1 is vulnerable to Command Injection via hg argument injection. When calling the cookiecutter function from Python code with the checkout parameter, it is passed to the hg checkout command in a way that additional flags can be set. The additional flags can be used to perform a command injection.

CVE-2022-24065 Affected Cookiecutter Versions

1 component(s)
Fixed Versions:
2.1.1
Product / Package Ecosystem Affected Versions Fixed Version
cookiecutter
PyPI
< 2.1.1
2.1.1

References

Frequently Asked Questions

What is CVE-2022-24065?
CVE-2022-24065 is a security vulnerability in Cookiecutter involving OS Command Injection in cookiecutter under CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection').
Which Cookiecutter versions are affected?
Affected versions include releases prior to 2.1.1 across affected packages: cookiecutter.
What version fixes CVE-2022-24065?
Upgrading to 2.1.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is cookiecutter affected?
Yes, cookiecutter is affected in releases prior to 2.1.1. Upgrade your dependency to 2.1.1 or later.
What is the CVSS score of CVE-2022-24065?
CVE-2022-24065 has a CVSS v3.1 base score of 8.1 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2022-24065?
CVE-2022-24065 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 PyPI dependencies for CVE-2022-24065?
Run the dependency tree command: 'pip show cookiecutter'. 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-f4q6-9qm4-h8j4",
  "modified" : "2024-11-18T16:26:26Z",
  "published" : "2022-06-09T23:48:49Z",
  "aliases" : [ "CVE-2022-24065" ],
  "summary" : "OS Command Injection in cookiecutter",
  "details" : "The package cookiecutter before 2.1.1 is vulnerable to Command Injection via hg argument injection. When calling the cookiecutter function from Python code with the checkout parameter, it is passed to the hg checkout command in a way that additional flags can be set. The additional flags can be used to perform a command injection.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "cookiecutter"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.1.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-24065"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/cookiecutter/cookiecutter/commit/fdffddb31fd2b46344dfa317531ff155e7999f77"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-f4q6-9qm4-h8j4"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/cookiecutter/cookiecutter"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/cookiecutter/cookiecutter/releases/tag/2.1.1"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/cookiecutter/PYSEC-2022-204.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/G5TXC4JYTNGOUFMCXPZ6QKWEZN3URTAK"
  }, {
    "type" : "WEB",
    "url" : "https://lists.fedoraproject.org/archives/list/package-announce@lists.fedoraproject.org/message/HQKWT7SGFDCUPPLDIELTN7FVTHWDL5YK"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-PYTHON-COOKIECUTTER-2414281"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-78" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-06-09T23:48:49Z",
    "nvd_published_at" : "2022-06-08T08:15:00Z"
  }
}