CVE-2026-40602: Homeassistant cli Handling Of User-supplied Jinja2 Templates Vulnerability
MODERATECVE-2026-40602 is a MODERATE (CVSS 5.6) handling of user-supplied jinja2 templates vulnerability (CWE-94: Improper Control of Generation of Code ('Code Injection')) affecting Homeassistant cli libraries in the PyPI ecosystem. The issue involves handling of user-supplied jinja2 templates. Remediation is available by upgrading affected packages to version 1.0.0.
CVE-2026-40602 at a Glance
Security Impact
CVSS: 5.6
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:U/C:H/I:H/A:N).
How to Fix CVE-2026-40602
To remediate this vulnerability, upgrade all affected Homeassistant 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.
pip install homeassistant-cli>=1.0.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show homeassistant-cli
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2026-40602, inspect your installed packages using pip:
pip show homeassistant-cli
Analyze the terminal output to locate any version of Homeassistant cli in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.0.0), your application is affected.
Note: The pip show homeassistant-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 Homeassistant 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
CVE-2026-40602 Affected Homeassistant cli Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
homeassistant-cli
|
PyPI |
< 1.0.0
|
1.0.0
|
References
Frequently Asked Questions
What is CVE-2026-40602?
Which Homeassistant cli versions are affected?
What version fixes CVE-2026-40602?
Is homeassistant-cli affected?
What is the CVSS score of CVE-2026-40602?
What CWE is associated with CVE-2026-40602?
How can I check PyPI dependencies for CVE-2026-40602?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-33qf-q99x-wpm8",
"modified" : "2026-04-27T16:15:58Z",
"published" : "2026-04-16T21:28:39Z",
"aliases" : [ "CVE-2026-40602" ],
"summary" : "Home Assistant Command-line Interface: Handling of user-supplied Jinja2 templates",
"details" : "### Impact\n\nUp to 1.0.0 of `home-assitant-cli` (or `hass-cli` for short) an unrestricted environment was used to handle Jninja2 templates instead of a sandboxed one. The user-supplied input within Jinja2 templates was rendered locally with no restrictions. This gave users access to Python's internals and extended the scope of templating beyond the intended usage.\n\nE. g., it was possible to render a template with `hass-cli template bad-template.j2 --local` that contained entries like\n\n````j2\n{%- set b = environ.__globals__['__builtins__'] -%}\n{%- set os = b['__import__']('os') -%}\n{%- set bio = b['__import__']('builtins') -%}\n...\n````\n\nor other malicious Jinja2 expressions. This can lead to arbitrary code execution on the local machine.\n\nIn a two step process an adversary could trick/convince an user to download third-party templates which contain harmful code (e. g., perform data manipulation or establish a remote shell) then to render those templates unchecked/reviewed/verified with `--local`. \n\nThe issue only affect the local machine and not a remote Home Assistant instance. It also requires user interventions.\n\n### Patches\n\n1.0.0 uses `ImmutableSandboxedEnvironment` and restricts the usage of environment variables.\n\n### Workarounds\n\nEvaluate the Jninja2 templates manually or tool-based before rendering with `hass-cli`.",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:U/C:H/I:H/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "homeassistant-cli"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "1.0.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/home-assistant-ecosystem/home-assistant-cli/security/advisories/GHSA-33qf-q99x-wpm8"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-40602"
}, {
"type" : "WEB",
"url" : "https://github.com/home-assistant-ecosystem/home-assistant-cli/pull/453"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/home-assistant-ecosystem/home-assistant-cli"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-1336", "CWE-94" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2026-04-16T21:28:39Z",
"nvd_published_at" : "2026-04-21T18:16:51Z"
}
}