CVE-2021-43837
JSON

8.4high

Template injection in vault-cli

Severity
8.4high CVSS:3.1 by GitHub_M
Exploit likelihood
5.17% (higher than 93% of CVEs)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-q34h-97wf-8r8jPYSEC-2021-853

Description

vault-cli is a configurable command-line interface tool (and python library) to interact with Hashicorp Vault. In versions before 3.0.0 vault-cli features the ability for rendering templated values. 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 is 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. In 3.0.0, the code related to interpreting vault templated secrets has been removed entirely. Users are advised to upgrade as soon as possible. For users unable to upgrade a workaround does exist. 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.

Affected

Product or packageVersionsReported by
peopledoc vault-cli>= 0.7.0,< 3.0.0CVE List
vault-cli (PyPI)from 0.7.0 before 3.0.0, before 3ba3955887fd6b7d4d646c8b260f21cebf5db852, before 3.0.0GitHub Advisory Database, PyPA Advisory Database
vault-cli_project vault-clifrom 0.7.0 before 3.0.0NVD

All scores

GitHub_M8.4high CVSS:3.1CVSS:3.1/AV:A/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H
GitHub8.4medium CVSS:3.1CVSS:3.1/AV:A/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H
GitHubmedium CVSS:4.0CVSS:4.0/AV:A/AC:L/AT:N/PR:H/UI:N/VC:N/VI:N/VA:N/SC:H/SI:H/SA:H
NVD9.1critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H
NVD9.0high CVSS:2.0AV:N/AC:L/Au:S/C:C/I:C/A:C

Classification

What each source says

CVE List

vault-cli is a configurable command-line interface tool (and python library) to interact with Hashicorp Vault. In versions before 3.0.0 vault-cli features the ability for rendering templated values. 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 is 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. In 3.0.0, the code related to interpreting vault templated secrets has been removed entirely. Users are advised to upgrade as soon as possible. For users unable to upgrade a workaround does exist. 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.

GitHub Advisory Database
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:

NVD (es)

vault-cli es una herramienta configurable de interfaz de línea de comandos (y biblioteca de python) para interactuar con Hashicorp Vault. En versiones anteriores a 3.0.0 vault-cli cuenta con la capacidad de renderizar valores templados. Cuando un secreto comienza con el prefijo "!template!", vault-cli interpreta el resto del contenido del secreto como una plantilla Jinja2. Jinja2 es un potente motor de plantillas y no está diseñado para renderizar de forma segura plantillas arbitrarias. Un atacante que controle una plantilla jinja2 renderizada en una máquina puede lanzar código arbitrario, lo que supone un riesgo de Ejecución de Código Remota (RCE). Si el contenido de la bóveda puede ser completamente confiable, entonces esto no es un problema. De lo contrario, si su modelo de amenaza incluye casos en los que un atacante puede manipular un valor secreto leído desde la bóveda usando vault-cli, entonces esta vulnerabilidad puede afectarle. En la versión 3.0.0, el código relacionado con la interpretación de los secretos de las plantillas de las bóvedas se ha eliminado por completo. Se recomienda a usuarios que actualicen lo antes posible. Para los usuarios que no puedan actualizar, se presenta una solución. Usando la variable de entorno "VAULT_CLI_RENDER=false" o el flag "--no-render" (colocada entre "vault-cli" y el subcomando, por ejemplo "vault-cli --no-render get-all") o añadiendo "render: false" al archivo yaml de configuración de vault-cli es deshabilitada la renderización y se elimina la vulnerabilidad. Usando la librería python, puedes usar "vault_cli.get_client(render=False)" cuando creas tu cliente para conseguir un cliente que no renderice los secretos de las plantillas y así operar de forma segura

References

Sources

SourceRecordLicence
CVE ListCVE-2021-43837 changed 2024-08-04CVE Terms of Use
GitHub Advisory DatabaseGHSA-q34h-97wf-8r8j changed 2026-07-08CC-BY-4.0
NVDCVE-2021-43837 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2021-853 changed 2023-11-08CC-BY-4.0