The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • AI Data Pipelines
      Security Data Pipeline for AI SIEM and Data Optimization
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2026-40602

CVE-2026-40602: Home Assistant CLI RCE Vulnerability

CVE-2026-40602 is a remote code execution flaw in Home Assistant Command-line interface that allows unrestricted Jinja2 template rendering with access to Python internals. This post covers technical details, affected versions, impact, and mitigation steps.

Published: April 23, 2026

CVE-2026-40602 Overview

CVE-2026-40602 is a code injection vulnerability in the Home Assistant Command-line interface (hass-cli), a command-line tool for Home Assistant. In versions up to 1.0.0 of home-assistant-cli, an unrestricted environment was used to handle Jinja2 templates instead of a sandboxed one. The user-supplied input within Jinja2 templates was rendered locally with no restrictions, giving users access to Python's internals and extending the scope of templating beyond its intended usage.

Critical Impact

This vulnerability allows attackers with local access to inject malicious Jinja2 templates that execute arbitrary Python code, potentially leading to unauthorized access to sensitive data or system compromise.

Affected Products

  • Home Assistant CLI (hass-cli) versions prior to 1.0.0

Discovery Timeline

  • 2026-04-21 - CVE CVE-2026-40602 published to NVD
  • 2026-04-22 - Last updated in NVD database

Technical Details for CVE-2026-40602

Vulnerability Analysis

This vulnerability falls under CWE-94 (Improper Control of Generation of Code), commonly known as code injection. The core issue stems from the use of an unrestricted Jinja2 template rendering environment in the Home Assistant CLI. Jinja2 is a powerful templating engine for Python that, when used without proper sandboxing, can expose the full Python runtime to template authors.

In a properly secured application, Jinja2 templates should be rendered within a sandboxed environment that restricts access to potentially dangerous Python built-ins, modules, and object attributes. The Home Assistant CLI failed to implement these restrictions, allowing template authors to access Python's internal mechanisms such as __class__, __mro__, __subclasses__(), and other introspection capabilities.

This unrestricted access enables attackers to traverse Python's object hierarchy to reach dangerous classes like os, subprocess, or builtins, ultimately achieving arbitrary code execution on the local system.

Root Cause

The root cause of this vulnerability is the failure to use a sandboxed Jinja2 environment when rendering user-supplied templates. The Home Assistant CLI used the standard jinja2.Environment instead of the safer jinja2.sandbox.SandboxedEnvironment, which restricts access to unsafe attributes and methods. Without sandboxing, any user input processed through the template engine could leverage Python's introspection capabilities to escape the template context and execute arbitrary code.

Attack Vector

The attack requires local access to the system running Home Assistant CLI and elevated privileges. An attacker must craft a malicious Jinja2 template that exploits Python's introspection capabilities. The template is then processed by the CLI without restrictions, allowing the attacker to access Python internals.

A typical Server-Side Template Injection (SSTI) attack against unsandboxed Jinja2 involves traversing the Method Resolution Order (MRO) to locate dangerous classes. Attackers can navigate from a basic object like an empty string to the base object class, then enumerate all subclasses to find modules that provide system access such as file operations or command execution. For detailed technical information about this vulnerability, see the GitHub Security Advisory GHSA-33qf-q99x-wpm8.

Detection Methods for CVE-2026-40602

Indicators of Compromise

  • Unusual Jinja2 template syntax in CLI inputs containing Python dunder methods like __class__, __mro__, or __subclasses__
  • Log entries showing unexpected template rendering errors or Python exceptions related to introspection
  • Evidence of unauthorized file access or command execution traced back to CLI operations

Detection Strategies

  • Implement input validation to detect and block template syntax containing Python introspection patterns
  • Monitor CLI usage for anomalous template inputs, particularly those containing double-underscore attributes
  • Review application logs for template rendering exceptions that may indicate exploitation attempts

Monitoring Recommendations

  • Enable verbose logging for the Home Assistant CLI to capture template processing activity
  • Set up alerts for patterns matching Jinja2 SSTI payloads such as {{.*__class__.*}} or similar constructs
  • Monitor file system and process activity on systems running vulnerable versions of hass-cli

How to Mitigate CVE-2026-40602

Immediate Actions Required

  • Upgrade Home Assistant CLI to version 1.0.0 or later immediately
  • Audit any systems running vulnerable versions for signs of compromise
  • Review CLI usage logs for suspicious template injection patterns
  • Restrict local access to systems running the Home Assistant CLI

Patch Information

The vulnerability has been fixed in version 1.0.0 of the Home Assistant CLI. The fix implements a sandboxed Jinja2 environment that restricts access to Python internals and limits template capabilities to intended functionality. For details on the fix, refer to GitHub Pull Request #453.

Workarounds

  • If immediate upgrade is not possible, restrict access to the Home Assistant CLI to trusted users only
  • Implement network segmentation to limit the potential impact of exploitation
  • Consider temporarily disabling features that process user-supplied Jinja2 templates until the upgrade can be completed
bash
# Upgrade Home Assistant CLI to patched version
pip install --upgrade home-assistant-cli>=1.0.0

# Verify installed version
hass-cli --version

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeRCE

  • Vendor/TechHome Assistant

  • SeverityMEDIUM

  • CVSS Score5.6

  • EPSS Probability0.02%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:L/AC:H/PR:H/UI:R/S:U/C:H/I:H/A:N
  • Impact Assessment
  • ConfidentialityHigh
  • IntegrityHigh
  • AvailabilityNone
  • CWE References
  • CWE-94
  • Technical References
  • GitHub Pull Request #453

  • GitHub Security Advisory GHSA-33qf-q99x-wpm8
  • Related CVEs
  • CVE-2025-25305: Home Assistant Core SSL Vulnerability

  • CVE-2026-33045: Home Assistant XSS Vulnerability

  • CVE-2026-33044: Home Assistant XSS Vulnerability

  • CVE-2026-34205: Home Assistant Auth Bypass Vulnerability
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English