Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS1xMzRoLTk3d2YtOHI4as0cqA

vault-cli contains possible RCE when reading user-defined data

Impact

What kind of vulnerability is it? Who is impacted?

vault-cli features the ability for rendering templated values (as explained in the documentation). 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:

Permalink: https://github.com/advisories/GHSA-q34h-97wf-8r8j
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS1xMzRoLTk3d2YtOHI4as0cqA
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: over 2 years ago
Updated: over 1 year ago


CVSS Score: 8.5
CVSS vector: CVSS:3.1/AV:A/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H

Identifiers: GHSA-q34h-97wf-8r8j, CVE-2021-43837
References: Repository: https://github.com/peopledoc/vault-cli
Blast Radius: 0.0

Affected Packages

pypi:vault-cli
Dependent packages: 0
Dependent repositories: 1
Downloads: 7,424 last month
Affected Version Ranges: >= 0.7.0, < 3.0.0
Fixed in: 3.0.0
All affected versions: 0.7.0, 0.8.0, 0.9.0, 0.10.0, 0.11.0, 0.12.0, 0.13.0, 1.0.0, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.4.0, 1.5.1, 1.6.0, 1.7.0, 1.8.0, 2.0.0, 2.1.0, 2.2.0
All unaffected versions: 0.1.0, 0.2.0, 0.2.1, 0.2.2, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4, 0.3.5, 0.3.6, 0.3.7, 0.3.8, 0.3.9, 0.4.0, 0.4.1, 0.5.0, 0.5.1, 0.6.0, 3.0.0, 3.1.0