/

CVE-2026-23954

Severity:

HIGH RISK

(8.7)

Path Traversal / Filesystem Traversal in Incus Container

CVE-2026-23954

Analyzed

Vulnerability type

Category:

Path Traversal / Filesystem Traversal

CWE:

CWE-22

Impact:

Host File Read/Write and Potential Remote Code Execution

Severity:

HIGH RISK

(8.7)

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 flaw in Incus template processing allows users who can launch containers with custom images to read and write arbitrary files on the host through crafted metadata templates.

By abusing directory traversal and symbolic links in template source and target paths, an attacker may escalate from container-level control to arbitrary command execution on the host system.

Affected context

This vulnerability affects Incus system container and virtual machine environments, including IncusOS, where:

  • Users are permitted to launch containers or VMs with custom images.
  • Images can carry a metadata.yaml file defining templating behavior.
  • The templating engine runs with access to the host filesystem and applies templates during instance creation.

In such setups, both the template source and destination paths are processed without rigorous checks for directory traversal sequences or symbolic links, allowing crafted paths to escape intended directories.

Exploit preconditions

  • Attack surface: Incus daemon or host via the container/VM image import and launch workflow.
  • Required access: Ability to:
  • Supply or modify a custom Incus image, or
  • Launch containers from images that the attacker can control, including their metadata.yaml.

Typically this implies membership in the incus group or equivalent delegated control.

  • Trigger point: Instance creation or initialization when the templating functionality processes entries from metadata.yaml, copying or rendering files to specified locations.
  • Why exploitation is possible:
  • Template source and target paths in metadata.yaml are not normalized or constrained to a safe root.
  • Symbolic links are not resolved or filtered before use.
  • As a result, ../ sequences and symlink chains can direct operations to arbitrary paths on the host filesystem.

Why this happens

The root cause aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal').

The templating functionality responsible for processing metadata.yaml trusts path values provided in the image:

  • It does not sanitize or canonicalize paths to prevent ../ directory traversal.
  • It does not robustly handle or restrict symbolic links that may point outside the intended directory tree.

Because the template engine operates with host-level privileges, this lack of path restriction enables arbitrary file access on the host, turning what should be a scoped configuration mechanism into a powerful escalation primitive.

Potential impact

  • Reading sensitive host files (e.g., configuration files, secrets, credentials) that the Incus daemon can access.
  • Overwriting or creating arbitrary files on the host filesystem.
  • Planting or modifying scripts, configuration, or service units to execute attacker-controlled commands.
  • Escalating from container-level control to host-level arbitrary code execution.
  • Persistence on the host via modified startup or service configuration.
  • Lateral movement within the host environment through credential or key theft.

General mitigation guidance

Effective mitigation typically involves tightening how template paths are interpreted and reducing the trust boundary between images and the host:

  • Constrain template paths: Normalize and canonicalize all template source and target paths, and reject paths that resolve outside a defined, safe base directory.
  • Harden symlink handling: Disallow symlinks in template-controlled directories or ensure that symlink resolution is restricted to a safe root; consider treating unexpected symlinks as errors.
  • Apply strict validation to metadata.yaml: Enforce schema and policy checks on template entries, including allowed directories, filename patterns, and operation types.
  • Limit host privileges of templating routines: Run the templating process with minimal necessary permissions and access only to explicitly allowed directories.
  • Restrict who can provide custom images: Limit membership in the incus group or similar roles, and apply additional review or approval for externally supplied images.
  • Isolate image processing: Where possible, perform template expansion in a constrained environment (e.g., chroot, mount namespaces, or dedicated service accounts) that does not expose the full host filesystem.

How teams detect issues like this

Detection approaches can combine code-level analysis with operational monitoring:

  • Static analysis and code review:
  • Search for file operations that rely on unvalidated paths from metadata.yaml or other image-controlled inputs.
  • Flag uses of path concatenation without canonicalization and checks against a strict base directory.
  • Review handling of symlinks in template directories and ensure that APIs enforcing "no symlink escape" semantics are used.
  • Policy and configuration checks:
  • Enforce policies requiring path normalization and base-path enforcement in all templating components.
  • Require security review for changes to image import and templating logic.
  • Runtime monitoring and logging:
  • Enable detailed logging of templating activity, including source and target paths and any failures due to validation.
  • Monitor for template operations targeting unexpected host directories (e.g., /etc, /root, /var/lib/incus).
  • Use host intrusion detection systems to identify unusual file changes originating from Incus-related processes.
  • Automated tooling:
  • Incorporate specialized linters or SAST tools capable of recognizing path traversal patterns.
  • Use CI/CD checks to enforce that new code paths dealing with template metadata follow established safe patterns.

Sources

SourceLink
github.comgithub.com/lxc/incus/blob/HEAD/internal/server/instance/drivers/driver_lxc.go#L7215
github.comgithub.com/lxc/incus/blob/HEAD/internal/server/instance/drivers/driver_lxc.go#L7294
github.comgithub.com/lxc/incus/security/advisories/GHSA-7f67-crqm-jgh7
github.comgithub.com/user-attachments/files/24473599/template_arbitrary_write.sh
github.comgithub.com/user-attachments/files/24473601/templates_arbitrary_write.patch

Frequently asked

questions

Exploitation is constrained to environments where an attacker can provide or control container or VM images, typically via membership in the incus group or equivalent delegated permissions. Once that condition is met, the vulnerability has significant impact on the host.

Yes. An attacker generally needs authenticated local access or delegated control to launch instances with custom images or manipulate metadata.yaml. It is not typically exploitable by anonymous remote users without such capabilities.

The core fix pattern is to enforce strict path confinement: canonicalize all file paths derived from untrusted metadata, verify they reside within an allowed directory tree, and reject or abort on any path that attempts to escape that boundary or traverse via symlinks.

Establish a standard design rule that no untrusted input may directly influence filesystem paths without:

  • Canonicalization and validation against a fixed base directory.
  • Explicit checks for symlinks and other redirection mechanisms.
  • Security-focused code review for any component that maps user-controlled metadata to host file operations.
Find out what's already
exploitable in your codebase.