{"id":"CVE-2026-40602","aliases":["CVE-2026-40602","GHSA-33qf-q99x-wpm8","PYSEC-2026-2518"],"related":[],"kind":"vulnerability","state":"published","title":"hass-cli: Handling of user-supplied Jinja2 templates","summary":"The Home Assistant Command-line interface (hass-cli) is a command-line tool for Home Assistant. Up to 1.0.0 of home-assitant-cli 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. This vulnerability is fixed in 1.0.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"The Home Assistant Command-line interface (hass-cli) is a command-line tool for Home Assistant. Up to 1.0.0 of home-assitant-cli 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. This vulnerability is fixed in 1.0.0.","source":"cvelist"},{"lang":"en","text":"### 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`.","format":"markdown","source":"ghsa"},{"lang":"es","text":"La interfaz de línea de comandos de Home Assistant (hass-cli) es una herramienta de línea de comandos para Home Assistant. Hasta la versión 1.0.0 de home-assistant-cli, se utilizaba un entorno sin restricciones para manejar plantillas Jinja2 en lugar de uno aislado. La entrada proporcionada por el usuario dentro de las plantillas Jinja2 se renderizaba localmente sin restricciones. Esto daba a los usuarios acceso a los componentes internos de Python y extendía el alcance de la creación de plantillas más allá del uso previsto. Esta vulnerabilidad está corregida en la versión 1.0.0.","source":"nvd"}],"published":"2026-04-16T21:28:39.000Z","modified":"2026-10-26T21:10:00.170Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:U/C:H/I:H/A:N","score":5.6,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:U/C:H/I:H/A:N","score":5.6,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:U/C:H/I:H/A:N","score":5.6,"rating":"MEDIUM"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:U/C:H/I:H/A:N","score":5.6,"rating":"MEDIUM"}],"cwes":["CWE-94","CWE-1336"],"affected":[{"ranges":[{"version":"< 1.0.0","status":"affected"}],"vendor":"home-assistant-ecosystem","product":"home-assistant-cli","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.0.0"}],"ecosystem":"PyPI","package":"homeassistant-cli","purl":"pkg:pypi/homeassistant-cli","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"1.0.0"}],"vendor":"home-assistant-ecosystem","product":"home_assistant_command-line_interface","cpe":"cpe:2.3:a:home-assistant-ecosystem:home_assistant_command-line_interface:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.0.0"}],"ecosystem":"PyPI","package":"homeassistant-cli","purl":"pkg:pypi/homeassistant-cli","source":"pysec"}],"references":[{"url":"https://github.com/home-assistant-ecosystem/home-assistant-cli/security/advisories/GHSA-33qf-q99x-wpm8","tags":["mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/home-assistant-ecosystem/home-assistant-cli/pull/453","tags":["issue-tracking","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-40602","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/home-assistant-ecosystem/home-assistant-cli","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/homeassistant-cli","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-33qf-q99x-wpm8","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"total","date":"2026-04-21T19:01:54.397Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-40602","url":"https://www.cve.org/CVERecord?id=CVE-2026-40602","licence":"CVE Terms of Use","modified":"2026-04-21T19:02:03.968Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-33qf-q99x-wpm8","url":"https://github.com/advisories/GHSA-33qf-q99x-wpm8","licence":"CC-BY-4.0","modified":"2026-07-13T16:42:26.177Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-40602","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-40602","licence":"Public domain","modified":"2026-10-26T21:10:00.170Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-2518","url":"https://osv.dev/vulnerability/PYSEC-2026-2518","licence":"CC-BY-4.0","modified":"2026-07-13T16:31:57.119Z"}],"updatedAt":"2026-11-25T22:59:19.126Z","epss":{"score":0.00107,"percentile":0.01266,"date":"2026-12-02T12:00:21.000Z"}}