/

CVE-2026-66897

Severity:

CRITICAL RISK

(9.9)

Path Traversal (CWE-22) in LXD Instance Template Processing

CVE-2026-66897

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22, CWE-23

Impact:

Arbitrary Host File Overwrite and Host Root Code Execution

Severity:

CRITICAL RISK

(9.9)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal vulnerability in LXD instance template processing allows attackers to overwrite arbitrary files on the host with root privileges. The issue becomes critical when a user can edit container metadata or launch a crafted image containing malicious template paths.

Affected context

The vulnerability occurs in LXD deployments that process instance template paths supplied through image metadata.yaml files. It is relevant when an attacker can edit an instance or provide a crafted image and the template processing logic validates paths using a confined directory handle but later creates files through an unconfined string path.

Exploit preconditions

  • Attack surface: LXD instance template processing during instance creation or configuration - Required access: Container edit permissions or the ability to launch a crafted image - Trigger point: Processing of attacker-controlled target template paths from metadata.yaml - Why exploitation is possible: Path validation and file creation use different path-resolution mechanisms, allowing a path that passes confinement checks to escape the intended directory when opened

Why this happens

The underlying bug is inconsistent path handling across security-sensitive operations. LXD validates a template path relative to a confined os.Root directory handle, but subsequently passes an unconfined string path to os.Create. This check-use mismatch can bypass directory confinement and maps primarily to CWE-22, Improper Limitation of a Pathname to a Restricted Directory, with characteristics of CWE-23, Relative Path Traversal.

Potential impact

  • An attacker may overwrite root-owned host files.
  • Host services could be altered or disrupted.
  • The attacker could achieve code execution with host root privileges.
  • LXD-managed workloads and other tenants could be compromised.
  • System integrity, availability, and confidentiality could be affected.

General mitigation guidance

Mitigation generally focuses on maintaining a single trusted path-resolution model from validation through file creation. Secure-by-default designs should resolve and open paths through the same confined directory abstraction, reject absolute and traversal-based paths, and constrain templates to an explicit allowlisted destination. Input trust should be reduced by treating image metadata and instance configuration as untrusted, while file creation should use least-privilege service identities, restrictive permissions, and host isolation controls where practical.

How teams detect issues like this

Detection can include static analysis for validation performed with one path API followed by file access through a separate unconfined string API. Code review should flag path joins, normalization checks, and file creation that do not share the same confinement mechanism. Runtime monitoring can alert on LXD processes creating or modifying sensitive host paths, and policy enforcement can restrict template destinations and image metadata sources. Automated security review tools may help identify traversal and check-use inconsistencies.

Sources

SourceLink
github.comgithub.com/canonical/lxd/security/advisories/GHSA-q39m-8fx9-42fv

Frequently asked

questions

Exploitation is dependent on LXD access. It may be reachable by a user with container edit permissions or by anyone permitted to launch a crafted image, but it is not necessarily exposed as an unauthenticated network attack.

The attacker must generally be able to edit an instance or supply image metadata containing a crafted template path. The exact scope depends on the deployment's LXD authorization and image-import policies.

Use one confined, race-resistant path-resolution and file-opening mechanism for both validation and creation, and permit only explicitly allowed template destinations.

Treat image metadata as untrusted input, test absolute and relative traversal cases, apply least privilege to LXD components, and monitor writes to sensitive host locations.

Find out what's already
exploitable in your codebase.