home-assistant-cli CVE-2026-40602
MEDIUMAttack ChainAIDerived
Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain
-
AccessAttacker crafts malicious Jinja2 template with __globals__ traversal
-
DeliveryDistributes template via community forum or social engineering
-
ExploitVictim downloads and saves template file locally
-
ExecutionVictim runs hass-cli template file.j2 --local
-
PersistUnsandboxed renderer grants access to Python __builtins__
-
ImpactAttacker-controlled code executes as local user
Vulnerability Assessment
| Weakness |
CWE
OWASP Top 10:2025
A05:2025 - Injection
ASVS 5.0
V1 - Encoding and Sanitization Code injection prevention, sandbox exec
MITRE ATT&CK
2 techniques across 2 tactics: Execution, Initial Access The technique list with ATT&CK links and the kill-chain view is part of the Basic plan and up. |
| Exploitation Conditions | Three specific conditions must all be met for exploitation: first, the victim must have home-assistant-cli installed at a version prior to 1.0.0; second, the victim must obtain a maliciously crafted Jinja2 template file distributed by the attacker via social engineering (e.g., community forums, a compromised template repository, or a phishing message); third, the victim must explicitly invoke the |
| Impact | Despite the SSVC "Technical Impact: total" designation, the aggregate risk signal is low-to-moderate. The CVSS 3.1 score of 5.6 correctly reflects the local attack vector (AV:L), high complexity (AC:H), required user interaction (UI:R), and absence of availability impact. EPSS at 0.02% (4th percentile) aligns with SSVC's "Exploitation: none" - no active exploitation activity has been observed. The attack is not automatable per SSVC, and scope is strictly limited to the local machine. One notable inconsistency: the provided CVSS vector includes PR:H, but the description indicates the attacker requires no privileges on the victim's system - the attacker merely distributes a file and relies on social engineering; PR:N is more accurate from the attacker's perspective. SSVC's "Technical Impact: total" reflects that successful exploitation achieves full code execution, but this must be weighed against three hard prerequisites: installation of a pre-1.0.0 build, receipt of a malicious template, and deliberate use of the |
| Exploit ScenarioDerived | An attacker publishes a malicious |
Get an e-mail when this CVE is exploited, patched or re-scored. Free account.
Alert meAnalysisAIv1 – Jul 24, 2026
Unsandboxed Jinja2 template rendering in home-assistant-cli before version 1.0.0 enables arbitrary code execution on the local machine when a user processes a maliciously crafted template with the --local flag. Exploitation chains two steps - an attacker distributes a crafted .j2 template and social-engineers the victim into rendering it locally - allowing traversal of Python's __globals__ and __builtins__ to invoke arbitrary OS commands. No public exploit has been identified and CISA KEV does not list this CVE, consistent with SSVC's assessment of zero current exploitation; despite the "Technical Impact: total" SSVC rating, real-world risk is substantially limited by the multi-step social engineering preconditions.
RemediationAI
Upgrade home-assistant-cli to version 1.0.0 or later using pip install --upgrade homeassistant-cli; this is the vendor-released patch confirmed by PR #453 (https://github.com/home-assistant-ecosystem/home-assistant-cli/pull/453) and advisory GHSA-33qf-q99x-wpm8. Version 1.0.0 switches to ImmutableSandboxedEnvironment and restricts environment variable access to an explicit allowlist. If upgrade is not immediately possible, the vendor-suggested workaround is to manually or tool-based inspect all Jinja2 templates before rendering with --local - specifically audit for expressions referencing __globals__, __builtins__, __import__, or class traversal patterns (__mro__, __subclasses__). This workaround relies on human review and is error-prone, particularly for complex or obfuscated templates; it should be treated as a temporary measure only. Avoid rendering templates from untrusted or unverified external sources under any circumstances.
Affected Packages
Source: OSV (Open Source Vulnerabilities)
Affects your stack
Affects 1 package in pypi
Checking this CVE against your own stacks and servers is part of the Basic plan and up.
Technical ContextAI · show details
The flaw exists in homeassistant_cli/plugins/template.py, where Jinja2's standard Environment class was used without sandboxing restrictions. Jinja2's default environment exposes Python object internals, enabling template authors to chain attribute lookups through environ.__globals__['__builtins__'] to reach __import__ and load arbitrary Python modules including os. The vulnerable package (pip/homeassistant-cli < 1.0.0; CPE: pkg:pip/homeassistant-cli) also bound os.environ.get directly as a template global, providing unrestricted read access to all environment variables - including potentially sensitive values like HASS_TOKEN or HASS_SUPERVISOR_TOKEN. CWE-94 (Code Injection) is the accurate root cause: user-controlled template content was evaluated in an interpreter context without input restriction. The patch replaces jinja2.Environment with jinja2.sandbox.ImmutableSandboxedEnvironment and introduces a SAFE_ENV_VARS allowlist (HASS_SERVER, LANG, TZ) for environment variable access.
Know when Python gets its next vulnerability
- Watch products and get an email when something new is published
- Check this CVE against your own stack and servers
- Exploit and PoC references, threat intelligence from 22 sources
No credit card · 7-day full trial
Severity by source
AV:L/AC:H/PR:H/UI:R/S:U/C:H/I:H/A:N
Attacker needs no system privileges - delivery is via social engineering of a file; PR:N corrects the vendor's PR:H; AV:L and AC:H reflect local rendering and social engineering complexity; no availability impact per advisory.
Primary rating from Vendor (https://github.com/home-assistant-ecosystem/home-assistant-cli).
CVSS VectorVendor: https://github.com/home-assistant-ecosystem/home-assistant-cli
Lifecycle Timeline
2DescriptionCVE.org
Impact
Up 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.
E. g., it was possible to render a template with hass-cli template bad-template.j2 --local that contained entries like
{%- set b = environ.__globals__['__builtins__'] -%}
{%- set os = b['__import__']('os') -%}
{%- set bio = b['__import__']('builtins') -%}
...or other malicious Jinja2 expressions. This can lead to arbitrary code execution on the local machine.
In 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.
The issue only affect the local machine and not a remote Home Assistant instance. It also requires user interventions.
Patches
1.0.0 uses ImmutableSandboxedEnvironment and restricts the usage of environment variables.
Workarounds
Evaluate the Jninja2 templates manually or tool-based before rendering with hass-cli.
Threat Intelligence Overview
How this decision was reached
The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.
What every action level means
SSVC AssessmentENISA
Priority Score
Attack Technique
Code injection occurs when an application accepts user input and passes it directly into a language interpreter or evaluator without proper sanitization.
Remote Code Execution represents the critical moment when an attacker successfully runs arbitrary code on a target system without physical access.
Affected Products (CPE)CVE.org
Wazuh SIEM platform versions 4.4.0 through 4.9.0 contain an unsafe deserialization vulnerability in the DistributedAPI t
BentoML version 1.4.2 and earlier contains an unauthenticated remote code execution vulnerability through insecure deser
pgAdmin 4 contains critical remote code execution vulnerabilities in the Query Tool download and Cloud Deployment endpoi
The renderLocalView function in render/views.py in graphite-web in Graphite 0.9.5 through 0.9.10 uses the pickle Python
BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Rated critica
OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h does not properly restrict processing of ChangeCiph
pyLoad download manager version prior to 0.5.0b3.dev77 exposes the Flask SECRET_KEY through an unauthenticated endpoint.
Langflow (a visual LLM pipeline builder) contains a critical unauthenticated code execution vulnerability (CVE-2026-3301
In Mercurial before 4.1.3, "hg serve --stdio" allows remote authenticated users to launch the Python debugger, and conse
Unauthenticated remote code execution affects Kestra OSS (the open-source event-driven orchestration platform) prior to
Unauthenticated remote code execution in Marimo ≤0.20.4 allows attackers to execute arbitrary system commands via the `/
pyLoad is the free and open-source Download Manager written in pure Python. Rated medium severity (CVSS 5.3), this vulne
GHSA-33qf-q99x-wpm8
NVD
CVE.org
EPSS
Vulnrichment
Exploit-DB