Skip to content

Container: Restrict path of template files and targets#17550

Merged
tomponline merged 2 commits intocanonical:mainfrom
tomponline:tp-templates
Feb 3, 2026
Merged

Container: Restrict path of template files and targets#17550
tomponline merged 2 commits intocanonical:mainfrom
tomponline:tp-templates

Conversation

@tomponline
Copy link
Copy Markdown
Member

@tomponline tomponline commented Feb 3, 2026

Based on lxc/incus#2848

Related to GHSA-7f67-crqm-jgh7 (CVE-2026-23954)

This addresses a security issue that was responsibly disclosed to the Incus security team by Rory McNamara of snyk.io.

@tomponline tomponline self-assigned this Feb 3, 2026
@tomponline tomponline force-pushed the tp-templates branch 6 times, most recently from cf0f96e to 45f2df4 Compare February 3, 2026 11:33
@tomponline tomponline requested a review from sudhackar February 3, 2026 11:40
@tomponline tomponline marked this pull request as ready for review February 3, 2026 11:41
…targets

This fixes three security issues related to file templates:

 - The template target path could be made to be relative or gothrough
   symlinks in a way that could lead to arbitrary write to the host
   filesystem.

 - The template directory could be relative, allowing for arbitrary read
   from the host filesystem.

 - The template file itself could be made relative, allowing for
   arbitrary reads from the host filesystem.

In the case of the template target path, the new logic makes use of the
kernel's openat2 system call which brings a variety of flags that can be
used to restrict path resolution and detect potential issues.

For the template path itself, we now validate that it is a simple local
file and that the template directory isn't a symlink.

This fixes CVE-2026-23954

Reported-by: Rory McNamara <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]>
(cherry picked from commit c1d90bd34a7ccc224276b87644d7c75437f1cb64)
Signed-off-by: Thomas Parrott <[email protected]>
License: Apache-2.0
…llow error wrapping

Also:
 - Closes rootfs file handle earlier.
 - Handles errors if file handles error when closing.

Signed-off-by: Thomas Parrott <[email protected]>
Copy link
Copy Markdown
Contributor

@nmezhenskyi nmezhenskyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@tomponline tomponline merged commit 1eb34e8 into canonical:main Feb 3, 2026
121 of 122 checks passed
@tomponline tomponline deleted the tp-templates branch February 3, 2026 19:23
tomponline added a commit to tomponline/lxd-pkg-snap that referenced this pull request Feb 4, 2026
tomponline added a commit to canonical/lxd-pkg-snap that referenced this pull request Feb 4, 2026
tomponline added a commit that referenced this pull request Feb 6, 2026
tomponline added a commit to tomponline/lxd-pkg-snap that referenced this pull request Feb 9, 2026
tomponline added a commit to tomponline/lxd-pkg-snap that referenced this pull request Feb 9, 2026
tomponline added a commit to tomponline/lxd-pkg-snap that referenced this pull request Feb 9, 2026
tomponline added a commit to canonical/lxd-pkg-snap that referenced this pull request Feb 9, 2026
tomponline added a commit that referenced this pull request Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants