Summary
Home Assistant Core contains a path traversal vulnerability in its backup-restore function, allowing crafted tar archives to write files to arbitrary absolute filesystem paths via symlink abuse.
When the process runs as root in the official Docker image, an attacker who can trigger backup restore may overwrite Python auto-import paths or component directories, potentially leading to remote code execution.
Affected context
The vulnerability occurs in Home Assistant Core backup restoration logic, specifically when processing tar archives that contain symbolic link entries.
It becomes relevant in deployments that:
- Accept backup archives from potentially untrusted or semi-trusted sources
- Run Home Assistant inside containers or hosts where the process has elevated privileges (commonly root)
- Allow backup restoration through exposed administration interfaces or automation
In these contexts, crafted tar contents can influence where restored files are ultimately written on the filesystem.
Exploit preconditions
- Attack surface: Backup import and restore interface of Home Assistant Core
- Required access: Ability to supply and trigger restoration of a crafted backup tar archive (e.g., access to admin UI, API, or backup upload channel)
- Trigger point: Execution of the backup-restore function that processes tar members, including symbolic links and subsequent regular file entries
- Why exploitation is possible: The tar extraction logic trusts the combination of a benign member name and an absolute
linknamein symlink entries without restricting paths to the intended extraction directory, enabling writes through the unvalidated symlink to arbitrary locations.
Why this happens
This issue stems from insufficient validation of filesystem paths during archive extraction.
The backup-restore implementation processes tar entries that include symbolic links (SYMTYPE) and follows those links when writing subsequent regular-file members.
Because it does not enforce that the resolved path remains within the designated extraction directory, an attacker can pair a harmless-looking tar member with a symlink whose linkname is an absolute path outside the restore location.
This pattern maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where the application fails to restrict file writes to safe, constrained directories when handling user-controlled paths.
Potential impact
- Attackers may write arbitrary files to absolute paths on the host or container filesystem.
- Attackers could overwrite Python auto-import targets such as
site-packages/sitecustomize.pyto execute code on application startup. - Attackers can modify or replace custom component directories to run malicious logic inside Home Assistant.
- Attackers may alter configuration or state files, potentially disrupting service or degrading integrity of automation rules.
- In privileged deployments, attackers could gain full remote code execution and pivot to broader system compromise.
General mitigation guidance
Effective mitigation focuses on constraining where restored files can be written and reducing the trust placed in archive contents.
Common defensive patterns include:
- Validating and normalizing all paths derived from archive entries, ensuring that resolved targets remain under a dedicated backup restore directory.
- Ignoring or strictly limiting processing of symbolic links, hard links, and other indirections when dealing with user-supplied archives.
- Using safer archive extraction helpers that explicitly enforce directory boundaries and reject absolute or parent-relative paths.
- Running the Home Assistant process with reduced privileges and restricting filesystem access to only what is required for normal operation.
- Separating executable code paths from writable data directories, so that even if arbitrary writes occur, they cannot easily modify code-loaded locations.
How teams detect issues like this
Organizations can detect and manage this class of vulnerability through:
- Static analysis rules and secure coding guidelines that flag unsafe tar or archive extraction patterns, especially where symlinks and absolute paths are honored.
- Code reviews that examine backup/restore and import/export logic for proper path normalization and directory confinement.
- Runtime monitoring or file integrity checks on critical code directories (e.g., Python site-packages, custom components) to detect unexpected changes following backup operations.
- Policy enforcement in CI/CD pipelines that disallow custom extraction helpers without explicit path boundary checks, and favor well-audited libraries or wrappers.

