Vulnerabilities in pkg:pypi/vault-cli

PACKAGE
Advisory Identifier: GHSA-q34h-97wf-8r8j
Advisory Summary

CVE-2021-43837 is a MODERATE (CVSS 8.4) remote code execution vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Vault cli libraries in the PyPI ecosystem. The issue involves vault-cli contains possible rce when reading user-defined data. Remediation is available by upgrading affected packages to version 3.0.0.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/vault-cli

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/vault-cli. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-q34h-97wf-8r8j CVE-2021-43837 MODERATE vault-cli contains possible RCE when reading user-defined data

CVE-2021-43837 at a Glance

CVE Identifier CVE-2021-43837
GHSA Identifier GHSA-q34h-97wf-8r8j
Severity MODERATE
CVSS v3.1 Base Score 8.4
CWE Classification CWE-94: Improper Control of Generation of Code ('Code Injection')
Affected Product Vault cli
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 8.4

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

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

How to Fix CVE-2021-43837

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

vault-cli fixed: 3.0.0
pip install vault-cli>=3.0.0
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 vault-cli

How to Check if You Are Affected

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

pip show vault-cli

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

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

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 Vault cli, 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 _What kind of vulnerability is it? Who is impacted?_ vault-cli features the ability for rendering templated values (as explained in the [documentation](https://github.com/peopledoc/vault-cli/blob/2.2.1/docs/howto/templated_secrets.rst)). When a secret starts with the prefix `!template!`, vault-cli interprets the rest of the contents of the secret as a Jinja2 template. Jinja2 is a powerful templating engine and it's not designed to safely render arbitrary templates. An attacker controlling a jinja2 template rendered on a machine can trigger arbitrary code, making this a Remote Code Execution (RCE) risk. If the content of the vault can be completely trusted, then this is not a problem. Otherwise, if your threat model includes cases where an attacker can manipulate a secret value read from the vault using vault-cli, then this vulnerability may impact you. This does not impact `vault` itself, except for the fact that the attacker, having an RCE on the machine that executes `vault-cli`, may abuse the token that `vault-cli` uses, to read, write or delete other data from the vault. ### Patches _Has the problem been patched? What versions should users upgrade to?_ In 3.0.0, the code related to interpreting vault templated secrets has been removed entirely. ### Workarounds _Is there a way for users to fix or remediate the vulnerability without upgrading?_ Using the environment variable `VAULT_CLI_RENDER=false` or the flag `--no-render` (placed between `vault-cli` and the subcommand, e.g. `vault-cli --no-render get-all`) or adding `render: false` to the vault-cli configuration yaml file disables rendering and removes the vulnerability. Using the python library, you can use: `vault_cli.get_client(render=False)` when creating your client to get a client that will not render templated secrets and thus operates securely. ### References _Are there any links users can visit to find out more?_ Here's an article explaining how jinja2 templates might be exploited to have side effects: https://podalirius.net/en/publications/grehack-2021-optimizing-ssti-payloads-for-jinja2/ ### For more information If you have any questions or comments about this advisory: * Open an issue in [the vault-cli repo](https://github.com/peopledoc/vault-cli/issues/new)

CVE-2021-43837 Affected Vault cli Versions

1 component(s)
Fixed Versions:
3.0.0
Product / Package Ecosystem Affected Versions Fixed Version
vault-cli
PyPI
≥ 0.7.0
< 3.0.0
3.0.0

References

Frequently Asked Questions

What is CVE-2021-43837?
CVE-2021-43837 is a security vulnerability in Vault cli involving vault-cli contains possible RCE when reading user-defined data under CWE-94: Improper Control of Generation of Code ('Code Injection').
Which Vault cli versions are affected?
Affected versions include releases prior to 3.0.0 across affected packages: vault-cli.
What version fixes CVE-2021-43837?
Upgrading to 3.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is vault-cli affected?
Yes, vault-cli is affected in releases prior to 3.0.0. Upgrade your dependency to 3.0.0 or later.
What is the CVSS score of CVE-2021-43837?
CVE-2021-43837 has a CVSS v3.1 base score of 8.4 (MODERATE) with vector string CVSS:3.1/AV:A/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2021-43837?
CVE-2021-43837 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 PyPI dependencies for CVE-2021-43837?
Run the dependency tree command: 'pip show vault-cli'. 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-q34h-97wf-8r8j",
  "modified" : "2024-11-18T22:46:40Z",
  "published" : "2021-12-16T21:02:12Z",
  "aliases" : [ "CVE-2021-43837" ],
  "summary" : "vault-cli contains possible RCE when reading user-defined data",
  "details" : "### Impact\n_What kind of vulnerability is it? Who is impacted?_\n\nvault-cli features the ability for rendering templated values (as explained in the [documentation](https://github.com/peopledoc/vault-cli/blob/2.2.1/docs/howto/templated_secrets.rst)). When a secret starts with the prefix `!template!`, vault-cli interprets the rest of the contents of the secret as a Jinja2 template.\nJinja2 is a powerful templating engine and it's not designed to safely render arbitrary templates. An attacker controlling a jinja2 template rendered on a machine can trigger arbitrary code, making this a Remote Code Execution (RCE) risk.\nIf the content of the vault can be completely trusted, then this is not a problem. Otherwise, if your threat model includes cases where an attacker can manipulate a secret value read from the vault using vault-cli, then this vulnerability may impact you.\n\nThis does not impact `vault` itself, except for the fact that the attacker, having an RCE on the machine that executes `vault-cli`, may abuse the token that `vault-cli` uses, to read, write or delete other data from the vault.\n\n### Patches\n_Has the problem been patched? What versions should users upgrade to?_\n\nIn 3.0.0, the code related to interpreting vault templated secrets has been removed entirely.\n\n### Workarounds\n_Is there a way for users to fix or remediate the vulnerability without upgrading?_\n\nUsing the environment variable `VAULT_CLI_RENDER=false` or the flag `--no-render` (placed between `vault-cli` and the subcommand, e.g. `vault-cli --no-render get-all`) or adding `render: false` to the vault-cli configuration yaml file disables rendering and removes the vulnerability.\nUsing the python library, you can use: `vault_cli.get_client(render=False)` when creating your client to get a client that will not render templated secrets and thus operates securely.\n\n### References\n_Are there any links users can visit to find out more?_\n\nHere's an article explaining how jinja2 templates might be exploited to have side effects: https://podalirius.net/en/publications/grehack-2021-optimizing-ssti-payloads-for-jinja2/\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [the vault-cli repo](https://github.com/peopledoc/vault-cli/issues/new)\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:A/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:A/AC:L/AT:N/PR:H/UI:N/VC:N/VI:N/VA:N/SC:H/SI:H/SA:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "vault-cli"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.7.0"
      }, {
        "fixed" : "3.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/peopledoc/vault-cli/security/advisories/GHSA-q34h-97wf-8r8j"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-43837"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/peopledoc/vault-cli/pull/198"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/peopledoc/vault-cli/commit/3ba3955887fd6b7d4d646c8b260f21cebf5db852"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/peopledoc/vault-cli"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/peopledoc/vault-cli/releases/tag/3.0.0"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/vault-cli/PYSEC-2021-853.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://podalirius.net/en/publications/grehack-2021-optimizing-ssti-payloads-for-jinja2"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-74", "CWE-94" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-12-16T19:28:49Z",
    "nvd_published_at" : "2021-12-16T19:15:00Z"
  }
}